please review: preserve temp names under asan/msan (PR17303)

Kostya Serebryany kcc at
Mon Oct 21 05:11:27 PDT 2013


Sending a patch according to

--- lib/CodeGen/CGExpr.cpp      (revision 193069)
+++ lib/CodeGen/CGExpr.cpp      (working copy)
@@ -52,7 +52,9 @@
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
                                                     const Twine &Name) {
-  if (!Builder.isNamePreserving())
+  // AddressSanitizer and MemorySanitizer need temp names.
+  // FIXME: this may need a better solution, see PR17303.
+  if (!Builder.isNamePreserving() && !SanOpts->Address && !SanOpts->Memory)
     return new llvm::AllocaInst(Ty, 0, "", AllocaInsertPt);
   return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);

I did not find a way to test it in clang w/o depending on asan/msan.
If I do a lit test in test/CodeGen/ and invoke clang with -emit-llvm
it actually runs the asan LLVM pass and only then emits IR.
Is there some standard way to output IR before it goes into optimizations?
I tried adding -disable-llvm-optzns (per Chandler's suggestion) -- did not
I'll make another test in compiler-rt anyway.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the cfe-commits mailing list