File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -858,6 +858,20 @@ void AMDGPUToolChain::addClangTargetOptions(
858858 CC1Args.push_back (" -fapply-global-visibility-to-externs" );
859859 }
860860
861+ // For SPIR-V we want to retain the pristine output of Clang CodeGen, since
862+ // optimizations might lose structure / information that is necessary for
863+ // generating optimal concrete AMDGPU code.
864+ // TODO: using the below option is a temporary placeholder until Clang
865+ // provides the required functionality, which essentially boils down to
866+ // -O0 being refactored / reworked to not imply optnone / remove TBAA.
867+ // Once that is added, we should pivot to that functionality, being
868+ // mindful to not corrupt the user provided and subsequently embedded
869+ // command-line (i.e. if the user asks for -O3 this is what the
870+ // finalisation should use).
871+ if (getTriple ().isSPIRV () &&
872+ !DriverArgs.hasArg (options::OPT_disable_llvm_optzns))
873+ CC1Args.push_back (" -disable-llvm-optzns" );
874+
861875 if (DeviceOffloadingKind == Action::OFK_None)
862876 addOpenCLBuiltinsLib (getDriver (), DriverArgs, CC1Args);
863877}
Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ void HIPAMDToolChain::addClangTargetOptions(
261261 // with options that match the user-supplied ones.
262262 if (!DriverArgs.hasArg (options::OPT_fembed_bitcode_marker))
263263 CC1Args.push_back (" -fembed-bitcode=marker" );
264+ // For SPIR-V we want to retain the pristine output of Clang CodeGen, since
265+ // optimizations might lose structure / information that is necessary for
266+ // generating optimal concrete AMDGPU code. We duplicate this because the
267+ // HIP TC doesn't invoke the base AMDGPU TC addClangTargetOptions.
268+ if (!DriverArgs.hasArg (options::OPT_disable_llvm_passes))
269+ CC1Args.push_back (" -disable-llvm-passes" );
264270 return ; // No DeviceLibs for SPIR-V.
265271 }
266272
Original file line number Diff line number Diff line change 206206// Check mixed AMDGCNSPIRV and concrete GPU arch.
207207//
208208
209- // AMDGCNSPIRV: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-emit-llvm-bc" {{.*}} "-o" "[[AMDGCNSPV_BC:.*bc]]"
209+ // AMDGCNSPIRV: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-emit-llvm-bc" {{.*}}"-fembed-bitcode=marker" "-disable-llvm-passes" {{.*}} "-o" "[[AMDGCNSPV_BC:.*bc]]"
210210// AMDGCNSPIRV: {{".*llvm-link.*"}} "-o" "[[AMDGCNSPV_TMP:.*out]]" "[[AMDGCNSPV_BC]]"
211211// AMDGCNSPIRV: {{".*llvm-spirv.*"}} "--spirv-max-version=1.6" "--spirv-ext=+all" {{.*}} "[[AMDGCNSPV_TMP]]" {{.*}}"-o" "[[AMDGCNSPV_CO:.*out]]"
212212// AMDGCNSPIRV: "-cc1" "-triple" "amdgcn-amd-amdhsa" {{.*}}"-emit-obj" {{.*}}"-target-cpu" "gfx900"{{.*}} "-o" "[[GFX900_OBJ:.*o]]"
Original file line number Diff line number Diff line change 1414
1515// RUN: %clang -### --target=spirv64-amd-amdhsa %s -nogpulib -nogpuinc 2>&1 \
1616// RUN: | FileCheck %s --check-prefix=INVOCATION
17- // INVOCATION: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-o" "[[OUTPUT:.+]]" "-x" "c"
17+ // INVOCATION: "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}}"-disable-llvm-optzns" {{.*}} "-o" "[[OUTPUT:.+]]" "-x" "c"
1818// INVOCATION: "{{.*}}llvm-link" "-o" "a.out" "[[OUTPUT]]"
1919// INVOCATION: "{{.*}}llvm-spirv" "--spirv-max-version=1.6" "--spirv-ext=+all" "--spirv-allow-unknown-intrinsics" "--spirv-lower-const-expr" "--spirv-preserve-auxdata" "--spirv-debug-info-version=nonsemantic-shader-200" "a.out" "-o" "a.out"
You can’t perform that action at this time.
0 commit comments