[llvm-commits] [llvm] r61558 - in /llvm/trunk: include/llvm/Assembly/ lib/AsmParser/ lib/VMCore/ test/Assembler/ test/Feature/ test/Integer/ test/Linker/ test/Transforms/GlobalOpt/ test/Verifier/ tools/bugpoint/ tools/llvm-as/

Chris Lattner clattner at apple.com
Sun Jan 4 12:24:15 PST 2009


On Jan 3, 2009, at 5:28 PM, Bill Wendling wrote:
>> It's probably some weird Makefile issue that's not resolved. This
>> check in is my best guess as to what's causing it. Here's the full
>> log file:
>>
>> 	http://bwendling.apple.com:8020/builders/full-llvm-OSX/builds/380/steps/shell/logs/stdio
>>
>> Do you have an idea of what's happening?
>>
> Some more information: When GCC builds LLVM first, there are many
> definitions of llvm::PATypeHolder::get() hanging around:
>
> $ nm -Am *.a | c++filt | grep PATypeHolder::get
> libLLVMAnalysis.a:AliasAnalysis.o: 000021d0 (__TEXT,__textcoal_nt)
> weak external llvm::PATypeHolder::get() const
> ...
> libLLVMCodeGen.a:ELFWriter.o:          (undefined [lazy bound])
> external llvm::PATypeHolder::get() const
> ...
>
> But when LLVM compiles itself, there are no definitions of
> llvm::PATypeHolder::get():

Interesting.  I imagine that this is just a difference in inlining,  
both compiler should be inlining those methods, but I guess only LLVM  
does consistently.

> $ nm -Am *.a | c++filt | grep PATypeHolder::get
> libLLVMCodeGen.a:ELFWriter.o:          (undefined) external
> llvm::PATypeHolder::get() const
>
> llvm::PATypeHolder::get() is defined like so in Type.h:
>
> inline Type* PATypeHolder::get() const {
>   const Type *NewTy = Ty->getForwardedType();
>   if (!NewTy) return const_cast<Type*>(Ty);
>   return *const_cast<PATypeHolder*>(this) = NewTy;
> }
>
> Could it be something with the inliner going awry? Before the changes
> in the parser, we got this:
>
> $ nm -Am *.a | c++filt | grep PATypeHolder::get
> libLLVMAsmParser.a:llvmAsmParser.o: 0001b1a0 (__TEXT,__textcoal_nt)
> weak external llvm::PATypeHolder::get() const
> libLLVMCodeGen.a:ELFWriter.o:          (undefined) external
> llvm::PATypeHolder::get() const
>
> So the libLLVMAsmParser.a supplied the missing symbol -- probably
> wrongly.

Your fix (adding the #include) is the right one.  The issue is that  
PATypeHolder::get really needs to be inlined for performance, so it is  
declared as an inline function.  However, the PATypeHolder and Type  
classes have circular dependences, so it can only be defined after  
both are seen.  If a file #includes AbstractTypeUser.h without  
#including Type.h, they can generate an unresolved reference to the  
function.

Thanks for tracking this down Bill!

-Chris



More information about the llvm-commits mailing list