[LLVMbugs] [Bug 17303] New: name of parameter Alloca is lost in LLVM_ENABLE_ASSERTIONS=OFF build of clang
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Sep 20 04:26:15 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17303
Bug ID: 17303
Summary: name of parameter Alloca is lost in
LLVM_ENABLE_ASSERTIONS=OFF build of clang
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: kcc at google.com
CC: chandlerc at gmail.com, llvmbugs at cs.uiuc.edu,
samsonov at google.com
Classification: Unclassified
AddressSanitizer relies on the AllocaInst name to produce informative results
for stack-buffer-overflow and stack-use-after-return bugs.
For local variables the AllocaInstr always has a name, whether the build
has LLVM_ENABLE_ASSERTIONS=OFF or ON:
void foo(int *a);
void bar() {
int ABCDE;
foo(&ABCDE);
}
% clang++ -O -S -o - -emit-llvm stack2.cc | grep alloca
%ABCDE = alloca i32, align 4
% noassert_clang++ -O -S -o - -emit-llvm stack2.cc | grep alloca
%ABCDE = alloca i32, align 4
But for parameters the AllocaInst has a name only with assertion
LLVM_ENABLE_ASSERTIONS=ON,
so with the release clang build AddressSanitizer produces a less informative
report.
void bar(int *a);
void foo(int ABC) {
bar(&ABC);
}
% clang++ -O -S -o - -emit-llvm param.cc | grep alloca
%ABC.addr = alloca i32, align 4
% noassert_clang++ -O -S -o - -emit-llvm param.cc | grep alloca
%1 = alloca i32, align 4
IMHO, the names in AllocaInst should be present in all builds, and a very
simple patch is sufficient:
--- lib/CodeGen/CGExpr.cpp (revision 191075)
+++ lib/CodeGen/CGExpr.cpp (working copy)
@@ -52,8 +52,6 @@
/// block.
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
const Twine &Name) {
- if (!Builder.isNamePreserving())
- return new llvm::AllocaInst(Ty, 0, "", AllocaInsertPt);
return new llvm::AllocaInst(Ty, 0, Name, AllocaInsertPt);
}
Chandler however thinks that we need to extract the names from debug info
and never rely on the SSA variable names.
This is potentially doable, but will require a special subset of -g to
be always on with asan/msan, which is quite a bit of maintenance work
compared to a very simple patch above.
Thoughts?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130920/6b98f849/attachment.html>
More information about the llvm-bugs
mailing list