Skip to content

Commit a2ddfa8

Browse files
amielczaigcbot
authored andcommitted
Force LLVM Legacy Pass Names
Manually adjust legacy pass wrapper names
1 parent ae1a5dd commit a2ddfa8

File tree

25 files changed

+899
-19
lines changed

25 files changed

+899
-19
lines changed

IGC/AdaptorCommon/RayTracing/RayTracingInterface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ SPDX-License-Identifier: MIT
3939
#include <llvm/Transforms/Scalar.h>
4040
#include <llvm/Transforms/Utils.h>
4141
#include <llvm/Analysis/AliasAnalysis.h>
42+
#include "llvmWrapper/Transforms/Scalar/DeadStoreElimination.h"
43+
#include "llvmWrapper/Transforms/IPO/GlobalDCE.h"
44+
4245
#include "common/LLVMWarningsPop.hpp"
4346

4447
using namespace llvm;

IGC/AdaptorOCL/UnifyIROCL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SPDX-License-Identifier: MIT
2323
#include <llvm/Analysis/TargetLibraryInfo.h>
2424

2525
#include <llvmWrapper/Transforms/InstCombine/InstCombineWorklist.h>
26+
#include "llvmWrapper/Transforms/IPO/GlobalDCE.h"
2627
#include <llvm/Transforms/Utils.h>
2728

2829
#include "common/LLVMWarningsPop.hpp"
@@ -405,7 +406,7 @@ static void CommonOCLBasedPasses(OpenCLProgramContext *pContext) {
405406
mpm.add(createAlwaysInlinerLegacyPass());
406407
}
407408
// The inliner sometimes fails to delete unused functions, this cleans up the remaining mess.
408-
mpm.add(createGlobalDCEPass());
409+
mpm.add(IGCLLVM::createLegacyWrappedGlobalDCEPass());
409410

410411
// Check after GlobalDCE in case of doubles in dead functions
411412
mpm.add(new ErrorCheck());

IGC/BiFManager/BiFManagerTool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ SPDX-License-Identifier: MIT
2424
#include <llvm/IR/LegacyPassManager.h>
2525
#include <llvm/Support/FileSystem.h>
2626
#include <llvm/ADT/Triple.h>
27+
#include "llvmWrapper/Transforms/IPO/GlobalDCE.h"
28+
2729
#include "common/LLVMWarningsPop.hpp"
2830
#include "BiFManagerTool.hpp"
2931

@@ -391,7 +393,7 @@ void BiFManagerTool::generateSplitedBiFModules(llvm::Module *pMainModule) {
391393

392394
// Do cleanup.
393395
llvm::legacy::PassManager mpm;
394-
mpm.add(createGlobalDCEPass()); // Delete unreachable globals.
396+
mpm.add(IGCLLVM::createLegacyWrappedGlobalDCEPass()); // Delete unreachable globals.
395397
mpm.add(createStripDeadDebugInfoPass()); // Remove dead debug info.
396398
mpm.add(createStripDeadPrototypesPass()); // Remove dead func decls.
397399

IGC/BiFManager/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ target_include_directories("${IGC_BUILD__PROJ__BiFManager}" PRIVATE ${IGC_BUILD_
3737

3838

3939
add_executable("${IGC_BUILD__PROJ__BiFManager_EXE}"
40+
${IGC_WrapperLLVM_HDR}
41+
${IGC_WrapperLLVM_SRC}
4042
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
4143
"${CMAKE_CURRENT_SOURCE_DIR}/BiFManagerTool.cpp"
4244
"${CMAKE_CURRENT_SOURCE_DIR}/BiFManagerCommon.cpp"

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ SPDX-License-Identifier: MIT
157157
#include <llvm/Transforms/Scalar.h>
158158
#include <llvm/Bitcode/BitcodeWriter.h>
159159
#include "llvmWrapper/Transforms/Scalar/ADCE.h"
160+
#include "llvmWrapper/Transforms/Scalar/CorrelatedValuePropagation.h"
161+
#include "llvmWrapper/Transforms/Scalar/DeadStoreElimination.h"
162+
#include "llvmWrapper/Transforms/Scalar/JumpThreading.h"
163+
#include "llvmWrapper/Transforms/IPO/SCCP.h"
164+
#include "llvmWrapper/Transforms/IPO/GlobalDCE.h"
165+
#include "llvmWrapper/Transforms/Scalar/MemCpyOptimizer.h"
166+
160167
#include "common/LLVMWarningsPop.hpp"
161168
#include "Compiler/CISACodeGen/PatternMatchPass.hpp"
162169
#include "Compiler/CISACodeGen/EmitVISAPass.hpp"
@@ -651,7 +658,7 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
651658

652659
if (ctx.enableFunctionCall() || ctx.type == ShaderType::RAYTRACING_SHADER) {
653660
// Sort functions if subroutine/indirect fcall is enabled.
654-
mpm.add(llvm::createGlobalDCEPass());
661+
mpm.add(IGCLLVM::createLegacyWrappedGlobalDCEPass());
655662
mpm.add(new PurgeMetaDataUtils());
656663
mpm.add(createGenXCodeGenModulePass());
657664
}
@@ -745,7 +752,7 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
745752
const bool allowIPConstProp = !ctx.m_hasStackCalls && IGC_IS_FLAG_DISABLED(DisableIPConstantPropagation);
746753

747754
if (allowIPConstProp) {
748-
mpm.add(createIPSCCPPass());
755+
mpm.add(IGCLLVM::createLegacyWrappedIPSCCPPass());
749756
}
750757
mpm.add(createDeadCodeEliminationPass());
751758
mpm.add(createCFGSimplificationPass());
@@ -1221,7 +1228,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
12211228
const bool allowIPConstProp = !pContext->m_hasStackCalls && IGC_IS_FLAG_DISABLED(DisableIPConstantPropagation);
12221229

12231230
if (allowIPConstProp) {
1224-
mpm.add(createIPSCCPPass());
1231+
mpm.add(IGCLLVM::createLegacyWrappedIPSCCPPass());
12251232
}
12261233
// Note / todo: LLVM < 12 also runs simple constant propagation pass
12271234
// regardless of IPSCCP in this case. This pass is not available on
@@ -1262,7 +1269,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
12621269
mpm.add(createScopedNoAliasAAWrapperPass());
12631270

12641271
if (pContext->m_instrTypes.hasLoadStore) {
1265-
mpm.add(llvm::createDeadStoreEliminationPass());
1272+
mpm.add(IGCLLVM::createLegacyWrappedDeadStoreEliminationPass());
12661273
mpm.add(createMarkReadOnlyLoadPass());
12671274
}
12681275

@@ -1273,7 +1280,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
12731280

12741281

12751282
if (pContext->m_instrTypes.CorrelatedValuePropagationEnable) {
1276-
mpm.add(llvm::createCorrelatedValuePropagationPass());
1283+
mpm.add(IGCLLVM::createLegacyWrappedCorrelatedValuePropagationPass());
12771284
}
12781285

12791286
mpm.add(new BreakConstantExpr());
@@ -1527,7 +1534,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
15271534
#if LLVM_VERSION_MAJOR >= 15
15281535
// In LLVM-12.x an extra parameter InsertFreezeWhenUnfoldingSelect = false was added
15291536
// to JumpThreading pass, but since LLVM-15.x it was removed again.
1530-
mpm.add(llvm::createJumpThreadingPass(BBDuplicateThreshold));
1537+
mpm.add(IGCLLVM::createLegacyWrappedJumpThreadingPass(BBDuplicateThreshold));
15311538
#else // LLVM_VERSION_MAJOR
15321539
mpm.add(llvm::createJumpThreadingPass(false, BBDuplicateThreshold));
15331540
#endif // LLVM_VERSION_MAJOR
@@ -1662,8 +1669,8 @@ void OptimizeIR(CodeGenContext *const pContext) {
16621669
mpm.add(createGenSimplificationPass());
16631670

16641671
if (pContext->m_instrTypes.hasLoadStore) {
1665-
mpm.add(llvm::createDeadStoreEliminationPass());
1666-
mpm.add(llvm::createMemCpyOptPass());
1672+
mpm.add(IGCLLVM::createLegacyWrappedDeadStoreEliminationPass());
1673+
mpm.add(IGCLLVM::createLegacyWrappedMemCpyOptPass());
16671674
mpm.add(createLdShrinkPass());
16681675
}
16691676

IGC/VectorCompiler/lib/GenXCodeGen/GenXTargetMachine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ SPDX-License-Identifier: MIT
9393
#include "llvm/Transforms/Utils.h"
9494
#include "llvm/Transforms/Utils/Mem2Reg.h"
9595

96+
#include "llvmWrapper/Transforms/Scalar/CorrelatedValuePropagation.h"
97+
#include "llvmWrapper/Transforms/Scalar/JumpThreading.h"
98+
9699
using namespace llvm;
97100

98101
static cl::opt<std::string>

IGC/WrapperLLVM/CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,27 @@ set(IGC_WrapperLLVM_HDR
7070
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Utils/BasicBlockUtils.h"
7171
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/InitializePasses.h"
7272
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar/ADCE.h"
73+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar/CorrelatedValuePropagation.h"
74+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar/DeadStoreElimination.h"
75+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar/JumpThreading.h"
76+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.h"
77+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/IPO/GlobalDCE.h"
78+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/IPO/SCCP.h"
79+
"${CMAKE_CURRENT_SOURCE_DIR}/include/llvmWrapper/Transforms/InstCombine/InstructionCombining.h"
80+
7381
"${CMAKE_CURRENT_SOURCE_DIR}/include/lldWrapper/Common/Driver.h"
7482
)
7583

7684
set(IGC_WrapperLLVM_SRC
7785
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/Scalar/ADCE.cpp"
78-
)
79-
86+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/Scalar/CorrelatedValuePropagation.cpp"
87+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/Scalar/DeadStoreElimination.cpp"
88+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/Scalar/JumpThreading.cpp"
89+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/Scalar/MemCpyOptimizer.cpp"
90+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/IPO/GlobalDCE.cpp"
91+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/IPO/SCCP.cpp"
92+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/llvmWrapper/Transforms/InstCombine/InstructionCombining.cpp"
93+
)
8094
include_directories(
8195
"${CMAKE_CURRENT_SOURCE_DIR}/include"
8296
"${CMAKE_CURRENT_SOURCE_DIR}"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2025 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
#ifndef IGCLLVM_TRANSFORMS_IPO_GLOBALDCE_LEGACY_H
10+
#define IGCLLVM_TRANSFORMS_IPO_GLOBALDCE_LEGACY_H
11+
12+
#include "llvm/IR/LegacyPassManager.h"
13+
#include "llvm/Pass.h"
14+
#include "llvm/IR/PassManager.h"
15+
#include "llvm/Passes/PassBuilder.h"
16+
17+
using namespace llvm;
18+
19+
namespace IGCLLVM {
20+
21+
struct GlobalDCELegacyPassWrapper : public ModulePass {
22+
GlobalDCELegacyPassWrapper();
23+
static char ID;
24+
bool runOnModule(llvm::Module &M) override;
25+
virtual llvm::StringRef getPassName() const override { return "LegacyWrappedGlobalDCE"; }
26+
27+
private:
28+
PassBuilder PB;
29+
ModuleAnalysisManager MAM;
30+
};
31+
32+
ModulePass *createLegacyWrappedGlobalDCEPass();
33+
34+
} // end namespace IGCLLVM
35+
36+
#endif // IGCLLVM_TRANSFORMS_IPO_GLOBALDCE_LEGACY_H
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2025 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
#ifndef IGCLLVM_TRANSFORMS_IPO_SCCP_LEGACY_H
10+
#define IGCLLVM_TRANSFORMS_IPO_SCCP_LEGACY_H
11+
12+
#include "llvm/IR/LegacyPassManager.h"
13+
#include "llvm/Pass.h"
14+
#include "llvm/IR/PassManager.h"
15+
#include "llvm/Passes/PassBuilder.h"
16+
17+
using namespace llvm;
18+
19+
namespace IGCLLVM {
20+
21+
struct IPSCCPLegacyPassWrapper : public ModulePass {
22+
IPSCCPLegacyPassWrapper();
23+
static char ID;
24+
bool runOnModule(llvm::Module &M) override;
25+
void getAnalysisUsage(AnalysisUsage &AU) const override;
26+
virtual llvm::StringRef getPassName() const override { return "LegacyWrappedIPSCCP"; }
27+
28+
private:
29+
PassBuilder PB;
30+
LoopAnalysisManager LAM;
31+
FunctionAnalysisManager FAM;
32+
CGSCCAnalysisManager CGAM;
33+
ModuleAnalysisManager MAM;
34+
};
35+
36+
ModulePass *createLegacyWrappedIPSCCPPass();
37+
38+
} // end namespace IGCLLVM
39+
40+
#endif // IGCLLVM_TRANSFORMS_IPO_SCCP_LEGACY_H

IGC/WrapperLLVM/include/llvmWrapper/Transforms/InitializePasses.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ class PassRegistry;
1414
}
1515

1616
void initializeADCELegacyPassWrapperPass(llvm::PassRegistry &);
17-
17+
void initializeCorrelatedValuePropagationLegacyPassWrapperPass(llvm::PassRegistry &);
18+
void initializeDSELegacyPassWrapperPass(llvm::PassRegistry &);
19+
void initializeJumpThreadingPassWrapperPass(llvm::PassRegistry &);
20+
void initializeMemCpyOptLegacyPassWrapperPass(llvm::PassRegistry &);
21+
void initializeGlobalDCELegacyPassWrapperPass(llvm::PassRegistry &);
22+
void initializeIPSCCPLegacyPassWrapperPass(llvm::PassRegistry &);
23+
void initializeInstructionCombiningPassWrapperPass(llvm::PassRegistry &);
1824
#endif // IGCLLVM_TRANSFORMS_INITIALIZE_PASSES_H

0 commit comments

Comments
 (0)