[LLVMbugs] [Bug 18029] New: miscompilation on i386 with -fPIC (recent regression)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 22 01:32:54 PST 2013


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

            Bug ID: 18029
           Summary: miscompilation on i386 with -fPIC (recent regression)
           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: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

r195419 on x86 linux: 


% cat b.cc 
#include <stdio.h>
int Bar(int *a) {
  return *a;
}
int Foo(int *a) {
  return Bar(a);
}
int main() {
  int a[7] = {0, 1, 2, 3, 4, 5, 6};
  printf("result: %d (should be 3)\n", Foo(&a[3]));
}

% clang -m32  -O1 b.cc; ./a.out 
result: 3 (should be 3)

% clang  -O1 b.cc; ./a.out 
result: 3 (should be 3)

% clang -m32  -O1 b.cc  -fPIC ; ./a.out 
result: 69485705 (should be 3)
% 

The code looks like this: 
08048400 <_Z3FooPi>:
 8048400:       e8 eb ff ff ff          call   80483f0 <_Z3BarPi>
 8048405:       c3                      ret    

This is obviously wrong, you can not call a function with a parameter like
this on i386, where the parameters are passed via stack. 

This is a very recent regression.

-- 
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/20131122/c4a7d5e4/attachment.html>


More information about the llvm-bugs mailing list