Index: llvm/include/llvm/CodeGen/Passes.h =================================================================== --- llvm/include/llvm/CodeGen/Passes.h +++ llvm/include/llvm/CodeGen/Passes.h @@ -270,11 +270,19 @@ /// 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 Index: llvm/lib/CodeGen/CodeGen.cpp =================================================================== --- llvm/lib/CodeGen/CodeGen.cpp +++ llvm/lib/CodeGen/CodeGen.cpp @@ -99,6 +99,7 @@ initializeRegisterCoalescerPass(Registry); initializeRenameIndependentSubregsPass(Registry); initializeSafeStackLegacyPassPass(Registry); + initializeShadowStackGCLoweringPass(Registry); initializeShrinkWrapPass(Registry); initializeSjLjEHPreparePass(Registry); initializeSlotIndexesPass(Registry); Index: llvm/lib/CodeGen/GCRootLowering.cpp =================================================================== --- llvm/lib/CodeGen/GCRootLowering.cpp +++ llvm/lib/CodeGen/GCRootLowering.cpp @@ -85,6 +85,7 @@ FunctionPass *llvm::createGCLoweringPass() { return new LowerIntrinsics(); } char LowerIntrinsics::ID = 0; +char &llvm::GCLoweringID = LowerIntrinsics::ID; LowerIntrinsics::LowerIntrinsics() : FunctionPass(ID) { initializeLowerIntrinsicsPass(*PassRegistry::getPassRegistry()); Index: llvm/lib/CodeGen/ShadowStackGCLowering.cpp =================================================================== --- llvm/lib/CodeGen/ShadowStackGCLowering.cpp +++ llvm/lib/CodeGen/ShadowStackGCLowering.cpp @@ -89,6 +89,7 @@ } // end anonymous namespace char ShadowStackGCLowering::ID = 0; +char &llvm::ShadowStackGCLoweringID = ShadowStackGCLowering::ID; INITIALIZE_PASS_BEGIN(ShadowStackGCLowering, DEBUG_TYPE, "Shadow Stack GC Lowering", false, false) Index: llvm/lib/CodeGen/TargetPassConfig.cpp =================================================================== --- llvm/lib/CodeGen/TargetPassConfig.cpp +++ llvm/lib/CodeGen/TargetPassConfig.cpp @@ -857,8 +857,8 @@ // 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. Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -763,6 +763,9 @@ // anything. disablePass(&StackMapLivenessID); disablePass(&FuncletLayoutID); + // Garbage collection is not supported. + disablePass(&GCLoweringID); + disablePass(&ShadowStackGCLoweringID); } AMDGPUTargetMachine &getAMDGPUTargetMachine() const { Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ llvm/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