-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed as not planned
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillainline-asminvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:codegen
Description
| Bugzilla Link | 15495 |
| Version | trunk |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @echristo,@noloader,@pageexec,@pogo59,@socketpair |
Extended Description
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.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillainline-asminvalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:codegen