[LLVMbugs] [Bug 15495] New: dead store pass ignores memory clobbering asm statement

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 12 03:19:13 PDT 2013


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: unassignedbugs at nondot.org
          Reporter: felix-llvm at fefe.de
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130312/cf7d391f/attachment.html>


More information about the llvm-bugs mailing list