Skip to content

Commit

Permalink
Make InferAlignment pass support conditional on LLVM version (GPUOpen…
Browse files Browse the repository at this point in the history
…-Drivers#2820)

This support is quite new so we need to guard the changes with an LLVM version.

Additionally, remove the Enable option.
  • Loading branch information
dstutt authored Nov 16, 2023
1 parent 6dc1f24 commit 317bdfb
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
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

0 comments on commit 317bdfb

Please sign in to comment.