Skip to content

Commit f738420

Browse files
committed
[NFC] Remove std::tuple for GPUSan.
Don't require std::tuple<bool,const SanitizerArgs> parameter. Simplify it to single boolean 'GPUSan'.
1 parent da6fbed commit f738420

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -950,13 +950,7 @@ void ROCMToolChain::addClangTargetOptions(
950950
ABIVer))
951951
return;
952952

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-
958953
bool Wave64 = isWave64(DriverArgs, Kind);
959-
960954
// TODO: There are way too many flags that change this. Do we need to check
961955
// them all?
962956
bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
@@ -969,6 +963,12 @@ void ROCMToolChain::addClangTargetOptions(
969963
bool CorrectSqrt =
970964
DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt);
971965

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+
972972
// Add the OpenCL specific bitcode library.
973973
llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs;
974974
BCLibs.emplace_back(RocmInstallation->getOpenCLPath().str());
@@ -1009,31 +1009,25 @@ llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
10091009
RocmInstallationDetector::getCommonBitcodeLibs(
10101010
const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64,
10111011
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 {
10151014
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
10161015

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-
10221016
auto AddBCLib = [&](ToolChain::BitCodeLibraryInfo BCLib,
10231017
bool Internalize = true) {
10241018
BCLib.ShouldInternalize = Internalize;
10251019
BCLibs.emplace_back(BCLib);
10261020
};
10271021
auto AddSanBCLibs = [&]() {
1028-
if (GPUSanEnabled)
1022+
if (GPUSan)
10291023
AddBCLib(getAsanRTLPath(), false);
10301024
};
10311025

10321026
AddSanBCLibs();
10331027
AddBCLib(getOCMLPath());
10341028
if (!isOpenMP)
10351029
AddBCLib(getOCKLPath());
1036-
else if (GPUSanEnabled && isOpenMP)
1030+
else if (GPUSan && isOpenMP)
10371031
AddBCLib(getOCKLPath(), false);
10381032
AddBCLib(getDenormalsAreZeroPath(DAZ));
10391033
AddBCLib(getUnsafeMathPath(UnsafeMathOpt || FastRelaxedMath));
@@ -1065,10 +1059,6 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
10651059
// If --hip-device-lib is not set, add the default bitcode libraries.
10661060
// TODO: There are way too many flags that change this. Do we need to check
10671061
// 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));
10721062
bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
10731063
options::OPT_fno_gpu_flush_denormals_to_zero,
10741064
getDefaultDenormsAreZeroForTarget(Kind));
@@ -1084,6 +1074,12 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
10841074
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true);
10851075
bool Wave64 = isWave64(DriverArgs, Kind);
10861076

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+
10871083
return RocmInstallation->getCommonBitcodeLibs(
10881084
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
10891085
FastRelaxedMath, CorrectSqrt, ABIVer, GPUSan, isOpenMP);

clang/lib/Driver/ToolChains/ROCm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class RocmInstallationDetector {
178178
const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile,
179179
bool Wave64, bool DAZ, bool FiniteOnly, bool UnsafeMathOpt,
180180
bool FastRelaxedMath, bool CorrectSqrt, DeviceLibABIVersion ABIVer,
181-
const std::tuple<bool, const SanitizerArgs> &GPUSan, bool isOpenMP) const;
181+
bool GPUSan, bool isOpenMP) const;
182182
/// Check file paths of default bitcode libraries common to AMDGPU based
183183
/// toolchains. \returns false if there are invalid or missing files.
184184
bool checkCommonBitcodeLibs(StringRef GPUArch, StringRef LibDeviceFile,

0 commit comments

Comments
 (0)