[cfe-commits] r82324 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h

Chris Lattner clattner at apple.com
Sat Sep 19 16:48:52 PDT 2009


On Sep 19, 2009, at 1:17 PM, Daniel Dunbar wrote:

> Author: ddunbar
> Date: Sat Sep 19 15:17:48 2009
> New Revision: 82324
>
> URL: http://llvm.org/viewvc/llvm-project?rev=82324&view=rev
> Log:
> Ok, an AssertingVH definitely doesn't work for now because we free  
> our cache after the optimizer may have hacked on the module. Use a  
> WeakVH instead.

Ok, seems reasonable.  However, shouldn't the DIFoo classes use an  
AssertingVH internally?

-Chris

>
> Modified:
>    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>    cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=82324&r1=82323&r2=82324&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Sep 19 15:17:48 2009
> @@ -752,10 +752,13 @@
>     return llvm::DIType();
>
>   // Check for existing entry.
> -  std::map<void *, llvm::AssertingVH<llvm::MDNode> >::iterator it =
> +  std::map<void *, llvm::WeakVH>::iterator it =
>     TypeCache.find(Ty.getAsOpaquePtr());
> -  if (it != TypeCache.end())
> -    return llvm::DIType(it->second);
> +  if (it != TypeCache.end()) {
> +    // Verify that the debug info still exists.
> +    if (&*it->second)
> +      return llvm::DIType(cast<llvm::MDNode>(it->second));
> +  }
>
>   // Otherwise create the type.
>   llvm::DIType Res = CreateTypeNode(Ty, Unit);
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=82324&r1=82323&r2=82324&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Sat Sep 19 15:17:48 2009
> @@ -49,7 +49,7 @@
>
>   /// TypeCache - Cache of previously constructed Types.
>   // FIXME: Eliminate this map.  Be careful of iterator invalidation.
> -  std::map<void *, llvm::AssertingVH<llvm::MDNode> > TypeCache;
> +  std::map<void *, llvm::WeakVH> TypeCache;
>
>   bool BlockLiteralGenericSet;
>   llvm::DIType BlockLiteralGeneric;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list