[PATCH] D116216: Prevent adding module flag - amdgpu_hostcall multiple times.

praveen velliengiri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 23 03:03:02 PST 2021


pvellien created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, kzhuravl.
pvellien requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

HIP program with printf call fails to compile with -fsanitize=address option, because of appending module flag - amdgpu_hostcall twice, one for printf and one for sanitize option. This patch fixes that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116216

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -565,7 +565,9 @@
         "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
         llvm::GlobalVariable::NotThreadLocal);
     addCompilerUsedGlobal(Var);
-    getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+    if (!getModule().getModuleFlag("amdgpu_hostcall")) {
+      getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+    }
   }
 
   emitLLVMUsed();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116216.396002.patch
Type: text/x-patch
Size: 614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211223/54aa5708/attachment-0001.bin>


More information about the cfe-commits mailing list