Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -967,6 +967,10 @@ void AMDGPUPassConfig::addIRPasses() { const AMDGPUTargetMachine &TM = getAMDGPUTargetMachine(); + Triple::ArchType Arch = TM.getTargetTriple().getArch(); + if (RemoveIncompatibleFunctions && Arch == Triple::amdgcn) + addPass(createAMDGPURemoveIncompatibleFunctionsPass(&TM)); + // There is no reason to run these. disablePass(&StackMapLivenessID); disablePass(&FuncletLayoutID); @@ -981,7 +985,7 @@ addPass(createAlwaysInlinerLegacyPass()); // Handle uses of OpenCL image2d_t, image3d_t and sampler_t arguments. - if (TM.getTargetTriple().getArch() == Triple::r600) + if (Arch == Triple::r600) addPass(createR600OpenCLImageTypeLoweringPass()); // Replace OpenCL enqueued block function pointers with global variables. @@ -1050,9 +1054,6 @@ void AMDGPUPassConfig::addCodeGenPrepare() { if (TM->getTargetTriple().getArch() == Triple::amdgcn) { - if (RemoveIncompatibleFunctions) - addPass(createAMDGPURemoveIncompatibleFunctionsPass(TM)); - // FIXME: This pass adds 2 hacky attributes that can be replaced with an // analysis, and should be removed. addPass(createAMDGPUAnnotateKernelFeaturesPass()); Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -28,6 +28,7 @@ ; GCN-O0-NEXT: FunctionPass Manager ; GCN-O0-NEXT: Expand large div/rem ; GCN-O0-NEXT: Expand large fp convert +; GCN-O0-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O0-NEXT: AMDGPU Printf lowering ; GCN-O0-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O0-NEXT: AMDGPU Inline All Functions @@ -45,7 +46,6 @@ ; GCN-O0-NEXT: Expand vector predication intrinsics ; GCN-O0-NEXT: Scalarize Masked Memory Intrinsics ; GCN-O0-NEXT: Expand reduction intrinsics -; GCN-O0-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O0-NEXT: CallGraph Construction ; GCN-O0-NEXT: Call Graph SCC Pass Manager ; GCN-O0-NEXT: AMDGPU Annotate Kernel Features @@ -170,6 +170,7 @@ ; GCN-O1-NEXT: FunctionPass Manager ; GCN-O1-NEXT: Expand large div/rem ; GCN-O1-NEXT: Expand large fp convert +; GCN-O1-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O1-NEXT: AMDGPU Printf lowering ; GCN-O1-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O1-NEXT: AMDGPU Inline All Functions @@ -221,7 +222,6 @@ ; GCN-O1-NEXT: Expand reduction intrinsics ; GCN-O1-NEXT: Natural Loop Information ; GCN-O1-NEXT: TLS Variable Hoist -; GCN-O1-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O1-NEXT: CallGraph Construction ; GCN-O1-NEXT: Call Graph SCC Pass Manager ; GCN-O1-NEXT: AMDGPU Annotate Kernel Features @@ -442,6 +442,7 @@ ; GCN-O1-OPTS-NEXT: FunctionPass Manager ; GCN-O1-OPTS-NEXT: Expand large div/rem ; GCN-O1-OPTS-NEXT: Expand large fp convert +; GCN-O1-OPTS-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O1-OPTS-NEXT: AMDGPU Printf lowering ; GCN-O1-OPTS-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O1-OPTS-NEXT: AMDGPU Inline All Functions @@ -501,7 +502,6 @@ ; GCN-O1-OPTS-NEXT: Natural Loop Information ; GCN-O1-OPTS-NEXT: TLS Variable Hoist ; GCN-O1-OPTS-NEXT: Early CSE -; GCN-O1-OPTS-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O1-OPTS-NEXT: CallGraph Construction ; GCN-O1-OPTS-NEXT: Call Graph SCC Pass Manager ; GCN-O1-OPTS-NEXT: AMDGPU Annotate Kernel Features @@ -736,6 +736,7 @@ ; GCN-O2-NEXT: FunctionPass Manager ; GCN-O2-NEXT: Expand large div/rem ; GCN-O2-NEXT: Expand large fp convert +; GCN-O2-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O2-NEXT: AMDGPU Printf lowering ; GCN-O2-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O2-NEXT: AMDGPU Inline All Functions @@ -803,7 +804,6 @@ ; GCN-O2-NEXT: Natural Loop Information ; GCN-O2-NEXT: TLS Variable Hoist ; GCN-O2-NEXT: Early CSE -; GCN-O2-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O2-NEXT: CallGraph Construction ; GCN-O2-NEXT: Call Graph SCC Pass Manager ; GCN-O2-NEXT: AMDGPU Annotate Kernel Features @@ -1040,6 +1040,7 @@ ; GCN-O3-NEXT: FunctionPass Manager ; GCN-O3-NEXT: Expand large div/rem ; GCN-O3-NEXT: Expand large fp convert +; GCN-O3-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O3-NEXT: AMDGPU Printf lowering ; GCN-O3-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O3-NEXT: AMDGPU Inline All Functions @@ -1119,7 +1120,6 @@ ; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: Optimization Remark Emitter ; GCN-O3-NEXT: Global Value Numbering -; GCN-O3-NEXT: AMDGPU Remove Incompatible Functions ; GCN-O3-NEXT: CallGraph Construction ; GCN-O3-NEXT: Call Graph SCC Pass Manager ; GCN-O3-NEXT: AMDGPU Annotate Kernel Features