[LLVMbugs] [Bug 9855] New: trying to call an inlined function, causing link failure
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 6 01:43:55 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9855
Summary: trying to call an inlined function, causing link
failure
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: release blocker
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: if.html at gmail.com
CC: llvmbugs at cs.uiuc.edu
code:
#include <stdio.h>
inline unsigned int f(unsigned int x){
if(x%2==0) {
return x/2;
} else {
return 3*x+1;
}
}
int main(){
unsigned int x;
for(scanf("%d",&x); x!=1; printf("%d\n", x))
x=f(x);
return 0;
}
---------
what clang compiles to:
.def _main;
.scl 2;
.type 32;
.endef
.text
.globl _main
.align 16, 0x90
_main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
calll ___main
leal L_.str, %eax
leal -8(%ebp), %ecx
movl $0, -4(%ebp)
movl %eax, (%esp)
movl %ecx, 4(%esp)
calll _scanf
movl %eax, -12(%ebp)
LBB0_1:
cmpl $1, -8(%ebp)
je LBB0_4
movl -8(%ebp), %eax
movl %eax, (%esp)
calll _f ; <=== here
movl %eax, -8(%ebp)
leal L_.str1, %eax
movl -8(%ebp), %ecx
movl %eax, (%esp)
movl %ecx, 4(%esp)
calll _printf
movl %eax, -16(%ebp)
jmp LBB0_1
LBB0_4:
movl $0, %eax
addl $24, %esp
popl %ebp
ret
.data
L_.str:
.asciz "%d"
L_.str1:
.asciz "%d\n"
------
BTW, with -O2 option, clang generates correct assembly
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list