Problem with generation of function names if prototype has already been used.

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