llc would fail with this IR:
; RUN:llc -mtriple=x86_64-linux-gnu -o - %s @_ZTV1B_rv = constant i32 trunc (i64 sub (i64 ptrtoint (void ()* dso_local_equivalent @_ZN1B1fEi to i64), i64 ptrtoint (i32* getelementptr inbounds (i32, i32* @_ZTV1B_rv, i32 0) to i64)) to i32) define void @_ZN1B1fEi() { ret void } bin/llc: error: bin/llc: /usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-2/llvm/test/ThinLTO/X86/dso_local_equivalent.ll:6:66: error: constant expression type mismatch: got type 'i8*' but expected 'void ()*'
The issue is that the forward referenced placeholder globalvariable is being type-checked with _ZN1B1fEi once we finish parsing its name and type. This patch ensures the placeholder will only be established if we know what type it should be. In globals, this is straightforward where the expected type is given before dso_local_equivalent. For calls where we may not know the type of the forward-referenced callee, we can lazily create the placeholder until the type is known.