Enable ASAN in amdgpu toolchain for OpenCL (#96262)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "clang/Driver/DriverDiagnostic.h"
|
||||
#include "clang/Driver/InputInfo.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "clang/Driver/SanitizerArgs.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
@@ -946,6 +947,11 @@ void ROCMToolChain::addClangTargetOptions(
|
||||
DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
|
||||
FastRelaxedMath, CorrectSqrt, ABIVer, false));
|
||||
|
||||
if (getSanitizerArgs(DriverArgs).needsAsanRt()) {
|
||||
CC1Args.push_back("-mlink-bitcode-file");
|
||||
CC1Args.push_back(
|
||||
DriverArgs.MakeArgString(RocmInstallation->getAsanRTLPath()));
|
||||
}
|
||||
for (StringRef BCFile : BCLibs) {
|
||||
CC1Args.push_back("-mlink-builtin-bitcode");
|
||||
CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
|
||||
|
||||
@@ -140,6 +140,9 @@ public:
|
||||
getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
|
||||
const std::string &GPUArch,
|
||||
bool isOpenMP = false) const;
|
||||
SanitizerMask getSupportedSanitizers() const override {
|
||||
return SanitizerKind::Address;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace toolchains
|
||||
|
||||
@@ -132,9 +132,20 @@
|
||||
// RUN: %S/opencl.cl \
|
||||
// RUN: 2>&1 | FileCheck --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900,WAVE64 %s
|
||||
|
||||
// RUN: %clang -### -target amdgcn-amd-amdhsa \
|
||||
// RUN: -x cl -mcpu=gfx908:xnack+ -fsanitize=address \
|
||||
// RUN: --rocm-path=%S/Inputs/rocm \
|
||||
// RUN: %s \
|
||||
// RUN: 2>&1 | FileCheck --check-prefixes=ASAN,COMMON %s
|
||||
|
||||
// RUN: %clang -### -target amdgcn-amd-amdhsa \
|
||||
// RUN: -x cl -mcpu=gfx908:xnack+ \
|
||||
// RUN: --rocm-path=%S/Inputs/rocm \
|
||||
// RUN: %s \
|
||||
// RUN: 2>&1 | FileCheck --check-prefixes=NOASAN %s
|
||||
|
||||
// COMMON: "-triple" "amdgcn-amd-amdhsa"
|
||||
// ASAN-SAME: "-mlink-bitcode-file" "{{.*}}/amdgcn/bitcode/asanrtl.bc"
|
||||
// COMMON-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/opencl.bc"
|
||||
// COMMON-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/ocml.bc"
|
||||
// COMMON-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/ockl.bc"
|
||||
@@ -169,6 +180,11 @@
|
||||
// COMMON-UNSAFE-MATH-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/oclc_finite_only_off.bc"
|
||||
// COMMON-UNSAFE-MATH-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc"
|
||||
|
||||
// ASAN-SAME: "-fsanitize=address"
|
||||
|
||||
// NOASAN-NOT: "-fsanitize=address"
|
||||
// NOASAN-NOT: amdgcn/bitcode/asanrtl.bc
|
||||
|
||||
// WAVE64: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/oclc_wavefrontsize64_on.bc"
|
||||
// WAVE32: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/oclc_wavefrontsize64_off.bc"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user