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(
858
858
CC1Args.push_back (" -fapply-global-visibility-to-externs" );
859
859
}
860
860
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
+
861
875
if (DeviceOffloadingKind == Action::OFK_None)
862
876
addOpenCLBuiltinsLib (getDriver (), DriverArgs, CC1Args);
863
877
}
Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ void HIPAMDToolChain::addClangTargetOptions(
261
261
// with options that match the user-supplied ones.
262
262
if (!DriverArgs.hasArg (options::OPT_fembed_bitcode_marker))
263
263
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" );
264
270
return ; // No DeviceLibs for SPIR-V.
265
271
}
266
272
Original file line number Diff line number Diff line change 206
206
// Check mixed AMDGCNSPIRV and concrete GPU arch.
207
207
//
208
208
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]]"
210
210
// AMDGCNSPIRV: {{".*llvm-link.*"}} "-o" "[[AMDGCNSPV_TMP:.*out]]" "[[AMDGCNSPV_BC]]"
211
211
// AMDGCNSPIRV: {{".*llvm-spirv.*"}} "--spirv-max-version=1.6" "--spirv-ext=+all" {{.*}} "[[AMDGCNSPV_TMP]]" {{.*}}"-o" "[[AMDGCNSPV_CO:.*out]]"
212
212
// 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 14
14
15
15
// RUN: %clang -### --target=spirv64-amd-amdhsa %s -nogpulib -nogpuinc 2>&1 \
16
16
// 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"
18
18
// INVOCATION: "{{.*}}llvm-link" "-o" "a.out" "[[OUTPUT]]"
19
19
// 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