[PATCH] D135832: Do not append terminating NUL to the string with embedded GPU binary.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 12 18:46:00 PDT 2022


efriedma added inline comments.


================
Comment at: clang/lib/CodeGen/CGCUDANV.cpp:95
                                llvm::ConstantInt::get(SizeTy, 0)};
-    auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
+    auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str(), AddNull);
     llvm::GlobalVariable *GV =
----------------
Please don't abuse GetAddrOfConstantCString like this.  Like the name says, it's meant for strings, in the normal sections strings would go in.  If you just want an array global, please just use "new llvm::GlobalVariable" directly.

(AddNull itself is not a big deal, but messing with the section/alignment/unnamed_addr of globals in CodeGenModule's ConstantStringMap is a bad idea.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135832/new/

https://reviews.llvm.org/D135832



More information about the cfe-commits mailing list