[clang] [HIP] disable sanitizer for `__hip_cuid` (PR #141581)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 27 04:39:49 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Yaxun (Sam) Liu (yxsamliu)
<details>
<summary>Changes</summary>
Global variable `__hip_cuid_*` is for identifying purpose and does not need sanitization, therefore disable it for sanitizers.
---
Full diff: https://github.com/llvm/llvm-project/pull/141581.diff
2 Files Affected:
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1)
- (added) clang/test/CodeGenCUDA/nosanitize-cuid.hip (+6)
``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 16e010adbeb5f..039507bc03510 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -971,6 +971,7 @@ void CodeGenModule::Release() {
getModule(), Int8Ty, false, llvm::GlobalValue::ExternalLinkage,
llvm::Constant::getNullValue(Int8Ty),
"__hip_cuid_" + getContext().getCUIDHash());
+ getSanitizerMetadata()->disableSanitizerForGlobal(GV);
addCompilerUsedGlobal(GV);
}
emitLLVMUsed();
diff --git a/clang/test/CodeGenCUDA/nosanitize-cuid.hip b/clang/test/CodeGenCUDA/nosanitize-cuid.hip
new file mode 100644
index 0000000000000..4af83c91ac883
--- /dev/null
+++ b/clang/test/CodeGenCUDA/nosanitize-cuid.hip
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsanitize=address -fcuda-is-device \
+// RUN: -emit-llvm -cuid=abcd -o - %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: @__hip_cuid_{{.*}} = {{.*}} no_sanitize_address
``````````
</details>
https://github.com/llvm/llvm-project/pull/141581
More information about the cfe-commits
mailing list