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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to