[llvm-commits] [llvm] r147010 - /llvm/trunk/lib/Linker/LinkModules.cpp

Bill Wendling wendling at apple.com
Tue Dec 20 17:07:32 PST 2011


Yay! This was also making LTO fail.

-bw

On Dec 20, 2011, at 3:14 PM, Chris Lattner wrote:

> Author: lattner
> Date: Tue Dec 20 17:14:57 2011
> New Revision: 147010
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=147010&view=rev
> Log:
> Fix a nasty bug in the type remapping stuff that I added that is breaking kc++ on 
> the build bot in some cases.  The basic issue happens when a source module contains
> both a "%foo" type and a "%foo.42" type.  It will see the later one, check to see if
> the destination module contains a "%foo" type, and it will return true... because
> both the source and destination modules are in the same LLVMContext.  We don't want
> to map source types to other source types, so don't do the remapping if the mapped
> type came from the source module.
> 
> Unfortunately, I've been unable to reduce a decent testcase for this, kc++ is 
> pretty great that way.
> 
> Modified:
>    llvm/trunk/lib/Linker/LinkModules.cpp
> 
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=147010&r1=147009&r2=147010&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Dec 20 17:14:57 2011
> @@ -148,6 +148,7 @@
>   if (PointerType *PT = dyn_cast<PointerType>(DstTy)) {
>     if (PT->getAddressSpace() != cast<PointerType>(SrcTy)->getAddressSpace())
>       return false;
> +    
>   } else if (FunctionType *FT = dyn_cast<FunctionType>(DstTy)) {
>     if (FT->isVarArg() != cast<FunctionType>(SrcTy)->isVarArg())
>       return false;
> @@ -567,6 +568,9 @@
>   std::vector<StructType*> SrcStructTypes;
>   SrcM->findUsedStructTypes(SrcStructTypes);
> 
> +  SmallPtrSet<StructType*, 32> SrcStructTypesSet(SrcStructTypes.begin(),
> +                                                 SrcStructTypes.end());
> +  
>   for (unsigned i = 0, e = SrcStructTypes.size(); i != e; ++i) {
>     StructType *ST = SrcStructTypes[i];
>     if (!ST->hasName()) continue;
> @@ -579,7 +583,10 @@
> 
>     // Check to see if the destination module has a struct with the prefix name.
>     if (StructType *DST = DstM->getTypeByName(ST->getName().substr(0, DotPos)))
> -      TypeMap.addTypeMapping(DST, ST);
> +      // Don't use it if this actually came from the source module.  They're in
> +      // the same LLVMContext after all.
> +      if (!SrcStructTypesSet.count(DST))
> +        TypeMap.addTypeMapping(DST, ST);
>   }
> 
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list