@@ -950,13 +950,7 @@ void ROCMToolChain::addClangTargetOptions(
950
950
ABIVer))
951
951
return ;
952
952
953
- std::tuple<bool , const SanitizerArgs> GPUSan (
954
- DriverArgs.hasFlag (options::OPT_fgpu_sanitize,
955
- options::OPT_fno_gpu_sanitize, true ),
956
- getSanitizerArgs (DriverArgs));
957
-
958
953
bool Wave64 = isWave64 (DriverArgs, Kind);
959
-
960
954
// TODO: There are way too many flags that change this. Do we need to check
961
955
// them all?
962
956
bool DAZ = DriverArgs.hasArg (options::OPT_cl_denorms_are_zero) ||
@@ -969,6 +963,12 @@ void ROCMToolChain::addClangTargetOptions(
969
963
bool CorrectSqrt =
970
964
DriverArgs.hasArg (options::OPT_cl_fp32_correctly_rounded_divide_sqrt);
971
965
966
+ // GPU Sanitizer currently only supports ASan and is enabled through host
967
+ // ASan.
968
+ bool GPUSan = DriverArgs.hasFlag (options::OPT_fgpu_sanitize,
969
+ options::OPT_fno_gpu_sanitize, true ) &&
970
+ getSanitizerArgs (DriverArgs).needsAsanRt ();
971
+
972
972
// Add the OpenCL specific bitcode library.
973
973
llvm::SmallVector<BitCodeLibraryInfo, 12 > BCLibs;
974
974
BCLibs.emplace_back (RocmInstallation->getOpenCLPath ().str ());
@@ -1009,31 +1009,25 @@ llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
1009
1009
RocmInstallationDetector::getCommonBitcodeLibs (
1010
1010
const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64,
1011
1011
bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath,
1012
- bool CorrectSqrt, DeviceLibABIVersion ABIVer,
1013
- const std::tuple<bool , const SanitizerArgs> &GPUSan,
1014
- bool isOpenMP = false ) const {
1012
+ bool CorrectSqrt, DeviceLibABIVersion ABIVer, bool GPUSan,
1013
+ bool isOpenMP) const {
1015
1014
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12 > BCLibs;
1016
1015
1017
- // GPU Sanitizer currently only supports ASan and is enabled through host
1018
- // ASan.
1019
- bool GPUSanEnabled = std::get<bool >(GPUSan) &&
1020
- std::get<const SanitizerArgs>(GPUSan).needsAsanRt ();
1021
-
1022
1016
auto AddBCLib = [&](ToolChain::BitCodeLibraryInfo BCLib,
1023
1017
bool Internalize = true ) {
1024
1018
BCLib.ShouldInternalize = Internalize;
1025
1019
BCLibs.emplace_back (BCLib);
1026
1020
};
1027
1021
auto AddSanBCLibs = [&]() {
1028
- if (GPUSanEnabled )
1022
+ if (GPUSan )
1029
1023
AddBCLib (getAsanRTLPath (), false );
1030
1024
};
1031
1025
1032
1026
AddSanBCLibs ();
1033
1027
AddBCLib (getOCMLPath ());
1034
1028
if (!isOpenMP)
1035
1029
AddBCLib (getOCKLPath ());
1036
- else if (GPUSanEnabled && isOpenMP)
1030
+ else if (GPUSan && isOpenMP)
1037
1031
AddBCLib (getOCKLPath (), false );
1038
1032
AddBCLib (getDenormalsAreZeroPath (DAZ));
1039
1033
AddBCLib (getUnsafeMathPath (UnsafeMathOpt || FastRelaxedMath));
@@ -1065,10 +1059,6 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
1065
1059
// If --hip-device-lib is not set, add the default bitcode libraries.
1066
1060
// TODO: There are way too many flags that change this. Do we need to check
1067
1061
// them all?
1068
- std::tuple<bool , const SanitizerArgs> GPUSan (
1069
- DriverArgs.hasFlag (options::OPT_fgpu_sanitize,
1070
- options::OPT_fno_gpu_sanitize, true ),
1071
- getSanitizerArgs (DriverArgs));
1072
1062
bool DAZ = DriverArgs.hasFlag (options::OPT_fgpu_flush_denormals_to_zero,
1073
1063
options::OPT_fno_gpu_flush_denormals_to_zero,
1074
1064
getDefaultDenormsAreZeroForTarget (Kind));
@@ -1084,6 +1074,12 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
1084
1074
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true );
1085
1075
bool Wave64 = isWave64 (DriverArgs, Kind);
1086
1076
1077
+ // GPU Sanitizer currently only supports ASan and is enabled through host
1078
+ // ASan.
1079
+ bool GPUSan = DriverArgs.hasFlag (options::OPT_fgpu_sanitize,
1080
+ options::OPT_fno_gpu_sanitize, true ) &&
1081
+ getSanitizerArgs (DriverArgs).needsAsanRt ();
1082
+
1087
1083
return RocmInstallation->getCommonBitcodeLibs (
1088
1084
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
1089
1085
FastRelaxedMath, CorrectSqrt, ABIVer, GPUSan, isOpenMP);
0 commit comments