From dc43bb3409f80e4f87bfa2ecae17e565c9e036cb Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Wed, 7 Jul 2021 14:25:24 -0700 Subject: [PATCH] [AMDGPU] Disable garbage collection passes Differential Revision: https://reviews.llvm.org/D105593 --- include/llvm/CodeGen/Passes.h | 8 ++++++++ lib/CodeGen/CodeGen.cpp | 1 + lib/CodeGen/GCRootLowering.cpp | 1 + lib/CodeGen/ShadowStackGCLowering.cpp | 1 + lib/CodeGen/TargetPassConfig.cpp | 4 ++-- lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 3 +++ test/CodeGen/AMDGPU/llc-pipeline.ll | 22 ++++++---------------- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index d0fe1a264b7..76667eac051 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -270,11 +270,19 @@ namespace llvm { /// operations. FunctionPass *createGCLoweringPass(); + /// GCLowering Pass - Used by gc.root to perform its default lowering + /// operations. + extern char &GCLoweringID; + /// ShadowStackGCLowering - Implements the custom lowering mechanism /// used by the shadow stack GC. Only runs on functions which opt in to /// the shadow stack collector. FunctionPass *createShadowStackGCLoweringPass(); + /// ShadowStackGCLowering - Implements the custom lowering mechanism + /// used by the shadow stack GC. + extern char &ShadowStackGCLoweringID; + /// GCMachineCodeAnalysis - Target-independent pass to mark safe points /// in machine code. Must be added very late during code generation, just /// prior to output, and importantly after all CFG transformations (such as diff --git a/lib/CodeGen/CodeGen.cpp b/lib/CodeGen/CodeGen.cpp index d2400d0371e..708325298aa 100644 --- a/lib/CodeGen/CodeGen.cpp +++ b/lib/CodeGen/CodeGen.cpp @@ -99,6 +99,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeRegisterCoalescerPass(Registry); initializeRenameIndependentSubregsPass(Registry); initializeSafeStackLegacyPassPass(Registry); + initializeShadowStackGCLoweringPass(Registry); initializeShrinkWrapPass(Registry); initializeSjLjEHPreparePass(Registry); initializeSlotIndexesPass(Registry); diff --git a/lib/CodeGen/GCRootLowering.cpp b/lib/CodeGen/GCRootLowering.cpp index faf0fb7f09a..58269e172c5 100644 --- a/lib/CodeGen/GCRootLowering.cpp +++ b/lib/CodeGen/GCRootLowering.cpp @@ -85,6 +85,7 @@ INITIALIZE_PASS_END(LowerIntrinsics, "gc-lowering", "GC Lowering", false, false) FunctionPass *llvm::createGCLoweringPass() { return new LowerIntrinsics(); } char LowerIntrinsics::ID = 0; +char &llvm::GCLoweringID = LowerIntrinsics::ID; LowerIntrinsics::LowerIntrinsics() : FunctionPass(ID) { initializeLowerIntrinsicsPass(*PassRegistry::getPassRegistry()); diff --git a/lib/CodeGen/ShadowStackGCLowering.cpp b/lib/CodeGen/ShadowStackGCLowering.cpp index 36752ef8652..86b559fd641 100644 --- a/lib/CodeGen/ShadowStackGCLowering.cpp +++ b/lib/CodeGen/ShadowStackGCLowering.cpp @@ -89,6 +89,7 @@ private: } // end anonymous namespace char ShadowStackGCLowering::ID = 0; +char &llvm::ShadowStackGCLoweringID = ShadowStackGCLowering::ID; INITIALIZE_PASS_BEGIN(ShadowStackGCLowering, DEBUG_TYPE, "Shadow Stack GC Lowering", false, false) diff --git a/lib/CodeGen/TargetPassConfig.cpp b/lib/CodeGen/TargetPassConfig.cpp index 2d8ecd5025f..2a4f6bfd98b 100644 --- a/lib/CodeGen/TargetPassConfig.cpp +++ b/lib/CodeGen/TargetPassConfig.cpp @@ -857,8 +857,8 @@ void TargetPassConfig::addIRPasses() { // Run GC lowering passes for builtin collectors // TODO: add a pass insertion point here - addPass(createGCLoweringPass()); - addPass(createShadowStackGCLoweringPass()); + addPass(&GCLoweringID); + addPass(&ShadowStackGCLoweringID); addPass(createLowerConstantIntrinsicsPass()); // Make sure that no unreachable blocks are instruction selected. diff --git a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index f611c893cde..7f74204229c 100644 --- a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -763,6 +763,9 @@ public: // anything. disablePass(&StackMapLivenessID); disablePass(&FuncletLayoutID); + // Garbage collection is not supported. + disablePass(&GCLoweringID); + disablePass(&ShadowStackGCLoweringID); } AMDGPUTargetMachine &getAMDGPUTargetMachine() const { diff --git a/test/CodeGen/AMDGPU/llc-pipeline.ll b/test/CodeGen/AMDGPU/llc-pipeline.ll index 4d423073276..80d05799281 100644 --- a/test/CodeGen/AMDGPU/llc-pipeline.ll +++ b/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -22,8 +22,8 @@ ; GCN-O0-NEXT: Target Transform Information ; GCN-O0-NEXT: Assumption Cache Tracker ; GCN-O0-NEXT: Profile summary info -; GCN-O0-NEXT: Create Garbage Collector Module Metadata ; GCN-O0-NEXT: Argument Register Usage Information Storage +; GCN-O0-NEXT: Create Garbage Collector Module Metadata ; GCN-O0-NEXT: Register Usage Information Storage ; GCN-O0-NEXT: Machine Branch Probability Analysis ; GCN-O0-NEXT: ModulePass Manager @@ -43,9 +43,7 @@ ; GCN-O0-NEXT: Lower OpenCL enqueued blocks ; GCN-O0-NEXT: Lower uses of LDS variables from non-kernel functions ; GCN-O0-NEXT: FunctionPass Manager -; GCN-O0-NEXT: Expand Atomic instructions -; GCN-O0-NEXT: Lower Garbage Collection Instructions -; GCN-O0-NEXT: Shadow Stack GC Lowering +; GCN-O0-NEXT: Expand Atomic instructions ; GCN-O0-NEXT: Lower constant intrinsics ; GCN-O0-NEXT: Remove unreachable blocks from the CFG ; GCN-O0-NEXT: Expand vector predication intrinsics @@ -165,8 +163,8 @@ ; GCN-O1-NEXT: External Alias Analysis ; GCN-O1-NEXT: Type-Based Alias Analysis ; GCN-O1-NEXT: Scoped NoAlias Alias Analysis -; GCN-O1-NEXT: Create Garbage Collector Module Metadata ; GCN-O1-NEXT: Argument Register Usage Information Storage +; GCN-O1-NEXT: Create Garbage Collector Module Metadata ; GCN-O1-NEXT: Machine Branch Probability Analysis ; GCN-O1-NEXT: Register Usage Information Storage ; GCN-O1-NEXT: ModulePass Manager @@ -209,8 +207,6 @@ ; GCN-O1-NEXT: Lazy Branch Probability Analysis ; GCN-O1-NEXT: Lazy Block Frequency Analysis ; GCN-O1-NEXT: Expand memcmp() to load/stores -; GCN-O1-NEXT: Lower Garbage Collection Instructions -; GCN-O1-NEXT: Shadow Stack GC Lowering ; GCN-O1-NEXT: Lower constant intrinsics ; GCN-O1-NEXT: Remove unreachable blocks from the CFG ; GCN-O1-NEXT: Natural Loop Information @@ -413,8 +409,8 @@ ; GCN-O1-OPTS-NEXT: External Alias Analysis ; GCN-O1-OPTS-NEXT: Type-Based Alias Analysis ; GCN-O1-OPTS-NEXT: Scoped NoAlias Alias Analysis -; GCN-O1-OPTS-NEXT: Create Garbage Collector Module Metadata ; GCN-O1-OPTS-NEXT: Argument Register Usage Information Storage +; GCN-O1-OPTS-NEXT: Create Garbage Collector Module Metadata ; GCN-O1-OPTS-NEXT: Machine Branch Probability Analysis ; GCN-O1-OPTS-NEXT: Register Usage Information Storage ; GCN-O1-OPTS-NEXT: ModulePass Manager @@ -475,8 +471,6 @@ ; GCN-O1-OPTS-NEXT: Lazy Branch Probability Analysis ; GCN-O1-OPTS-NEXT: Lazy Block Frequency Analysis ; GCN-O1-OPTS-NEXT: Expand memcmp() to load/stores -; GCN-O1-OPTS-NEXT: Lower Garbage Collection Instructions -; GCN-O1-OPTS-NEXT: Shadow Stack GC Lowering ; GCN-O1-OPTS-NEXT: Lower constant intrinsics ; GCN-O1-OPTS-NEXT: Remove unreachable blocks from the CFG ; GCN-O1-OPTS-NEXT: Natural Loop Information @@ -694,8 +688,8 @@ ; GCN-O2-NEXT: External Alias Analysis ; GCN-O2-NEXT: Type-Based Alias Analysis ; GCN-O2-NEXT: Scoped NoAlias Alias Analysis -; GCN-O2-NEXT: Create Garbage Collector Module Metadata ; GCN-O2-NEXT: Argument Register Usage Information Storage +; GCN-O2-NEXT: Create Garbage Collector Module Metadata ; GCN-O2-NEXT: Machine Branch Probability Analysis ; GCN-O2-NEXT: Register Usage Information Storage ; GCN-O2-NEXT: ModulePass Manager @@ -756,8 +750,6 @@ ; GCN-O2-NEXT: Lazy Branch Probability Analysis ; GCN-O2-NEXT: Lazy Block Frequency Analysis ; GCN-O2-NEXT: Expand memcmp() to load/stores -; GCN-O2-NEXT: Lower Garbage Collection Instructions -; GCN-O2-NEXT: Shadow Stack GC Lowering ; GCN-O2-NEXT: Lower constant intrinsics ; GCN-O2-NEXT: Remove unreachable blocks from the CFG ; GCN-O2-NEXT: Natural Loop Information @@ -976,8 +968,8 @@ ; GCN-O3-NEXT: External Alias Analysis ; GCN-O3-NEXT: Type-Based Alias Analysis ; GCN-O3-NEXT: Scoped NoAlias Alias Analysis -; GCN-O3-NEXT: Create Garbage Collector Module Metadata ; GCN-O3-NEXT: Argument Register Usage Information Storage +; GCN-O3-NEXT: Create Garbage Collector Module Metadata ; GCN-O3-NEXT: Machine Branch Probability Analysis ; GCN-O3-NEXT: Register Usage Information Storage ; GCN-O3-NEXT: ModulePass Manager @@ -1043,8 +1035,6 @@ ; GCN-O3-NEXT: Lazy Branch Probability Analysis ; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: Expand memcmp() to load/stores -; GCN-O3-NEXT: Lower Garbage Collection Instructions -; GCN-O3-NEXT: Shadow Stack GC Lowering ; GCN-O3-NEXT: Lower constant intrinsics ; GCN-O3-NEXT: Remove unreachable blocks from the CFG ; GCN-O3-NEXT: Natural Loop Information