[LLVMbugs] [Bug 16099] New: if a loop body contains both a VLA and a call to alloca, we still generate stacksave/stackrestore

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 21 18:02:54 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16099

            Bug ID: 16099
           Summary: if a loop body contains both a VLA and a call to
                    alloca, we still generate stacksave/stackrestore
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

LLVM miscompiles this code:

_Bool g(int*);
int *h(void*);
int f(int n) {
  int *p;
  for (int i = 1; i < n; ++i) {
    int arr[i];
    if (g(arr)) p = h(alloca(i));
  }
  return *p;
}

We wrap the loop body in @llvm.stacksave() / @llvm.stackrestore() calls, which
nuke both the VLA *and* the alloca. We should warn on this, and presumably also
omit the stacksave/stackrestore in this case. Or hey, maybe compile the VLA to
malloc/free? :)

-- 
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/20130522/3337be14/attachment.html>


More information about the llvm-bugs mailing list