[cfe-dev] Problem with generation of function names if prototype has already been used.

Oliver Hunt oliver at apple.com
Sat Dec 1 18:49:39 PST 2007


A relatively simple piece of code:
// RUN: clang -emit-llvm %s
int g(int);

int foo(int i) {
	return g(i);
}

int g(int i) {
	return i;
}

Is compiled incorrectly to:
; ModuleID = 'foo'
target triple = "i686-apple-darwin9"

define i32 @foo(i32 %i) {
entry:
...
	%call = call i32 @g( i32 %tmp )		; <i32> [#uses=1]
	ret i32 %call
}

declare i32 @g(i32)

define i32 @g1(i32 %i) {
entry:
...
}

This only occurs if the prototyped function (in this case 'g') is  
called before it is actually defined.

--Oliver 



More information about the cfe-dev mailing list