Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make InferAlignment pass support conditional on LLVM version
Browse files Browse the repository at this point in the history
This support is quite new so we need to guard the changes with an LLVM version.

Additionally, remove the Enable option.
dstutt committed Nov 16, 2023
1 parent 6dc1f24 commit f65c345
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lgc/patch/Patch.cpp
Original file line number Diff line number Diff line change
@@ -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"
@@ -107,10 +112,6 @@

using namespace llvm;

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

namespace lgc {

// =====================================================================================================================
@@ -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());

0 comments on commit f65c345

Please sign in to comment.