Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make InferAlignment pass support conditional on LLVM version #2820

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lgc/patch/Patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/IndVarSimplify.h"
#if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 475156
// Old version of the code
#else
// New version of the code (also handles unknown version, which we treat as latest)
#include "llvm/Transforms/Scalar/InferAlignment.h"
#endif
#include "llvm/Transforms/Scalar/InstSimplifyPass.h"
#include "llvm/Transforms/Scalar/LICM.h"
#include "llvm/Transforms/Scalar/LoopDeletion.h"
Expand All @@ -107,10 +112,6 @@

using namespace llvm;

namespace llvm {
extern cl::opt<bool> EnableInferAlignmentPass;
} // namespace llvm

namespace lgc {

// =====================================================================================================================
Expand Down Expand Up @@ -415,8 +416,12 @@ void Patch::addOptimizationPasses(lgc::PassManager &passMgr, uint32_t optLevel)
fpm.addPass(SROAPass(SROAOptions::ModifyCFG));
// uses UniformityAnalysis
fpm.addPass(PatchReadFirstLane());
if (EnableInferAlignmentPass)
fpm.addPass(InferAlignmentPass());
#if LLVM_MAIN_REVISION && LLVM_MAIN_REVISION < 475156
// Old version of the code
#else
// New version of the code (also handles unknown version, which we treat as latest)
fpm.addPass(InferAlignmentPass());
#endif
fpm.addPass(InstCombinePass());
passMgr.addPass(createModuleToFunctionPassAdaptor(std::move(fpm)));
passMgr.addPass(ConstantMergePass());
Expand Down
Loading