Skip to content

Commit eb7d24b

Browse files
peplaigcbot
authored andcommitted
Refactor removing dead code for LLVM versions < 14
Refactor removing dead code for LLVM versions < 14
1 parent 345d3fa commit eb7d24b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+14
-920
lines changed

IGC/AdaptorOCL/OCL/sp/spp_g8.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,8 @@ bool CGen8OpenCLProgram::GetZEBinary(llvm::raw_pwrite_stream &programBinary, uns
388388
}
389389
} else {
390390
linkErr.str(); // Flush contents to the associated string
391-
392391
linkOut.str(); // Flush contents to the associated string
393392
linkErrStr.append(linkOutStr);
394-
395393
if (!linkErrStr.empty()) {
396394
if (ctx) {
397395
ctx->EmitError(linkErrStr.c_str(), nullptr);

IGC/Compiler/CISACodeGen/PushAnalysis.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,9 @@ bool PushAnalysis::IsSafeToPushNonStaticBufferLoad(llvm::Instruction *inst) {
389389
bool searchForRetBBBeforeDiscard = false;
390390
BasicBlock *retBB = m_PDT->getRootNode()->getBlock();
391391
if (!retBB) {
392-
#if LLVM_VERSION_MAJOR <= 10
393-
auto &roots = m_PDT->getRoots();
394-
IGC_ASSERT_MESSAGE(roots.size() == 1, "Unexpected multiple roots");
395-
retBB = roots[0];
396-
#else
397392
auto roots = m_PDT->root_begin();
398393
IGC_ASSERT_MESSAGE(m_PDT->root_size() == 1, "Unexpected multiple roots");
399394
retBB = *roots;
400-
#endif
401395
}
402396

403397
for (auto &II : m_pFunction->getEntryBlock()) {

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,6 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
659659
if (!isOptDisabled && ctx.m_instrTypes.hasLoadStore && IGC_IS_FLAG_DISABLED(DisableMemOpt) &&
660660
!ctx.getModuleMetaData()->disableMemOptforNegativeOffsetLoads) {
661661

662-
663662
if ((ctx.type == ShaderType::RAYTRACING_SHADER || ctx.hasSyncRTCalls()) &&
664663
IGC_IS_FLAG_DISABLED(DisablePrepareLoadsStores)) {
665664
mpm.add(createPrepareLoadsStoresPass());
@@ -728,7 +727,6 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
728727
if (allowIPConstProp) {
729728
mpm.add(createIPSCCPPass());
730729
}
731-
732730
mpm.add(createDeadCodeEliminationPass());
733731
mpm.add(createCFGSimplificationPass());
734732
}

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,11 +2948,7 @@ void RecursivelyDeleteDeadInstructions(Instruction *I, const TargetLibraryInfo *
29482948
void RecursivelyDeleteDeadInstructions(const SmallVectorImpl<Instruction *> &DeadInsts, const TargetLibraryInfo *TLI,
29492949
MemorySSAUpdater *MSSAU,
29502950
const std::function<void(Value *)> &AboutToDeleteCallback) {
2951-
#if LLVM_VERSION_MAJOR < 11
2952-
SmallVector<Instruction *, 16> trivialDeadInsts;
2953-
#else
29542951
SmallVector<WeakTrackingVH, 16> trivialDeadInsts;
2955-
#endif
29562952
for (auto II : DeadInsts) {
29572953
Instruction &I = *II;
29582954
IGC_ASSERT(I.use_empty() && "Instructions with uses are not dead.");
@@ -2983,11 +2979,7 @@ void RecursivelyDeleteDeadInstructions(const SmallVectorImpl<Instruction *> &Dea
29832979
}
29842980

29852981
if (!trivialDeadInsts.empty()) {
2986-
#if LLVM_VERSION_MAJOR < 13
2987-
RecursivelyDeleteTriviallyDeadInstructions(trivialDeadInsts, TLI, MSSAU);
2988-
#else
29892982
RecursivelyDeleteTriviallyDeadInstructions(trivialDeadInsts, TLI, MSSAU, AboutToDeleteCallback);
2990-
#endif
29912983
}
29922984
}
29932985

IGC/Compiler/Optimizer/CodeAssumption.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ bool CodeAssumption::addAssumption(Function *F, AssumptionCache *AC) {
238238
// Register assumption
239239
if (AC) {
240240
AC->registerAssumption(
241-
#if LLVM_VERSION_MAJOR < 13
242-
assumeInst
243-
#else
244241
dyn_cast<AssumeInst>(assumeInst)
245-
#endif
246242
);
247243
}
248244

IGC/Compiler/Optimizer/IGCInstCombiner/IGCInstructionCombining.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ SPDX-License-Identifier: MIT
1717
#include "llvm/Transforms/InstCombine/InstCombine.h"
1818

1919
namespace IGC {
20-
#if LLVM_VERSION_MAJOR <= 10
21-
inline llvm::FunctionPass *createIGCInstructionCombiningPass() { return llvm::createInstructionCombiningPass(false); }
22-
#else
2320
inline llvm::FunctionPass *createIGCInstructionCombiningPass() { return llvm::createInstructionCombiningPass(); }
24-
#endif
2521
} // namespace IGC
2622

2723
#endif // IGC_INSTCOMBINE_INSTCOMBINE_H

IGC/Compiler/Optimizer/OpenCLPasses/BfloatFuncs/BfloatFuncsResolution.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ void BfloatFuncsResolution::visitCallInst(CallInst &CI) {
6666
if (!DName.startswith("__builtin_bf16"))
6767
return;
6868

69-
#if LLVM_VERSION_MAJOR < 14
70-
m_ctx->EmitError("__builtin_bf16* function was used with unsupported IGC "
71-
"version (LLVM version < 14)",
72-
&CI);
73-
return;
74-
}
75-
#else
76-
7769
m_builder->SetInsertPoint(&CI);
7870

7971
m_changed = true;
@@ -309,7 +301,6 @@ void BfloatFuncsResolution::handleMath(llvm::CallInst &CI, llvm::Intrinsic::ID O
309301
CI.replaceAllUsesWith(Res);
310302
m_instructionsToRemove.push_back(&CI);
311303
}
312-
#endif // LLVM_VERSION_MAJOR < 14
313304
/*
314305
Supported functions list:
315306

IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,12 +1191,6 @@ bool RegisterPressureTracker::fitsPressureThreshold(ReductionCandidateGroup &C)
11911191

11921192
void RegisterPressureTracker::updatePressure(ReductionCandidateGroup &C, SCEVExpander &E) {
11931193

1194-
#if LLVM_VERSION_MAJOR < 14
1195-
BBsToUpdate.clear();
1196-
Function *F = C.getLoop()->getLoopPreheader()->getParent();
1197-
RPE.rerunLivenessAnalysis(*F);
1198-
return;
1199-
#else
12001194

12011195
// Refresh all BBs in loop.
12021196
BBsToUpdate.insert(C.getLoop()->getBlocks().begin(), C.getLoop()->getBlocks().end());
@@ -1254,7 +1248,6 @@ void RegisterPressureTracker::updatePressure(ReductionCandidateGroup &C, SCEVExp
12541248
RPE.rerunLivenessAnalysis(*F, &BBsToUpdate);
12551249
BBsToUpdate.clear();
12561250
}
1257-
#endif // LLVM_VERSION_MAJOR
12581251
}
12591252

12601253
bool Reducer::reduce(SmallVectorImpl<ReductionCandidateGroup> &Candidates) {
@@ -1319,12 +1312,8 @@ void Reducer::cleanup(ReductionCandidateGroup &C) {
13191312
// Delete GEP instructions together with index calculations. Inform Register
13201313
// Pressure Estimator about removed instructions.
13211314
for (auto *GEP : C.getReduced()) {
1322-
#if LLVM_VERSION_MAJOR < 14
1323-
RecursivelyDeleteTriviallyDeadInstructions(GEP);
1324-
#else
13251315
RecursivelyDeleteTriviallyDeadInstructions(GEP, nullptr, nullptr,
13261316
[&](Value *V) { RPT.trackDeletedInstruction(V); });
1327-
#endif
13281317
}
13291318
}
13301319

IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,11 +2861,7 @@ DIType *getOrCreateType(Type *T, Module *M) {
28612861
if (T->isPointerTy()) {
28622862

28632863
uint align = 0;
2864-
#if LLVM_VERSION_MAJOR < 10
2865-
align = IGCLLVM::getPrefTypeAlign(Layout, T);
2866-
#else
28672864
align = IGCLLVM::getPrefTypeAlign(Layout, T).value();
2868-
#endif
28692865

28702866
std::optional<unsigned int> opt(std::nullopt);
28712867
diType = Builder.createPointerType(nullptr, Layout.getPointerTypeSizeInBits(T), align * CHAR_BIT,

IGC/Compiler/Optimizer/OpenCLPasses/KernelFunctionCloning/KernelFunctionCloning.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ bool KernelFunctionCloning::runOnModule(Module &M) {
144144
continue;
145145
}
146146
IGCLLVM::CallSite *call = nullptr;
147-
#if LLVM_VERSION_MAJOR < 11
148-
IGCLLVM::CallSite callSite(U);
149-
call = &callSite;
150-
#else
151147
call = dyn_cast<IGCLLVM::CallSite>(U);
152-
#endif
153148
if (!call)
154149
continue;
155150
KernelsToClone.push_back(&F);
@@ -180,12 +175,7 @@ bool KernelFunctionCloning::runOnModule(Module &M) {
180175
// function clone at the callsites.
181176
for (auto &U : originalKernelFunctionUsers) {
182177
IGCLLVM::CallSite *call = nullptr;
183-
#if LLVM_VERSION_MAJOR < 11
184-
IGCLLVM::CallSite callSite(U);
185-
call = &callSite;
186-
#else
187178
call = dyn_cast<IGCLLVM::CallSite>(U);
188-
#endif
189179
if (!call)
190180
continue;
191181

0 commit comments

Comments
 (0)