http://llvm.org/bugs/show_bug.cgi?id=15495
Bug ID: 15495
Summary: dead store pass ignores memory clobbering asm
statement
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Consider this function:
#include <string.h>
void foo(int x) {
char buf[10];
int i;
for (i=0; i<sizeof(buf); ++i)
buf[i]=x++;
memset(buf,0,sizeof(buf));
}
llvm removes all the write accesses to buf. OK so far.
Now let's add an asm statement to tell the optimizer that it cannot remove
writes to buf:
void foo(int x) {
char buf[10];
int i;
for (i=0; i<sizeof(buf); ++i)
buf[i]=x++;
memset(buf,0,sizeof(buf));
asm("" : : : "memory");
}
llvm ignores the asm statement and still removes all stores to the local
buffer.
I think this is a bug. At least gcc and icc honor the asm statement and don't
remove the stores if it is present.
I was using:
clang version 3.3 (trunk 176552)
Target: x86_64-unknown-linux-gnu
Thread model: posix
This bug is quite important because it may introduce security problems in
crypto code attempting to cleanse keys from memory.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs