r184509 - Alternative fix for r184473.
David Blaikie
dblaikie at gmail.com
Thu Jun 20 17:40:50 PDT 2013
Author: dblaikie
Date: Thu Jun 20 19:40:50 2013
New Revision: 184509
URL: http://llvm.org/viewvc/llvm-project?rev=184509&view=rev
Log:
Alternative fix for r184473.
This just seems a bit tidier/more principled. Based on a patch provided
by Adrian - with the only minor tweak that it needed to use
"getTypeOrNull" rather than "getCompletedTypeOrNull" since we don't
store declarations in the CompletedTypes cache.
No intended functionality change.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=184509&r1=184508&r2=184509&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 20 19:40:50 2013
@@ -1886,22 +1886,6 @@ llvm::DIType CGDebugInfo::getTypeOrNull(
return llvm::DIType();
}
-/// ContainsFwdDecl - True if Ty is either a forward declaration or a
-/// derived type of a forward declaration.
-static bool ContainsFwdDecl(llvm::DIType Ty) {
- // Composite types such as structs inherit from DIDerivedType, so
- // check this first and do an early exit.
- if (Ty.isForwardDecl())
- return true;
-
- if (Ty.isDerivedType()) {
- llvm::DIDerivedType DTy(Ty);
- return ContainsFwdDecl(DTy.getTypeDerivedFrom());
- }
-
- return false;
-}
-
/// getCompletedTypeOrNull - Get the type from the cache or return null if it
/// doesn't exist.
llvm::DIType CGDebugInfo::getCompletedTypeOrNull(QualType Ty) {
@@ -1920,19 +1904,22 @@ llvm::DIType CGDebugInfo::getCompletedTy
}
// Verify that any cached debug info still exists.
- if (V != 0) {
- llvm::DIType CachedType(cast<llvm::MDNode>(V));
+ if (V != 0)
+ return llvm::DIType(cast<llvm::MDNode>(V));
- // Unless we are limiting debug info, attempt to resolve any
- // forward declarations.
- if (DebugKind > CodeGenOptions::LimitedDebugInfo &&
- ContainsFwdDecl(CachedType))
- return llvm::DIType();
+ return llvm::DIType();
+}
- return CachedType;
- }
+void CGDebugInfo::completeFwdDecl(const RecordDecl &RD) {
+ // In limited debug info we only want to do this if the complete type was
+ // required.
+ if (DebugKind <= CodeGenOptions::LimitedDebugInfo)
+ return;
- return llvm::DIType();
+ llvm::DIType T = getTypeOrNull(CGM.getContext().getRecordType(&RD));
+
+ if (T.Verify() && T.isForwardDecl())
+ getOrCreateType(QTy, getOrCreateFile(RD.getLocation());
}
/// getCachedInterfaceTypeOrNull - Get the type from the interface
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=184509&r1=184508&r2=184509&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jun 20 19:40:50 2013
@@ -289,6 +289,8 @@ public:
llvm::DIType getOrCreateInterfaceType(QualType Ty,
SourceLocation Loc);
+ void completeFwdDecls(const RecordDecl *TD);
+
private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=184509&r1=184508&r2=184509&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Thu Jun 20 19:40:50 2013
@@ -260,6 +260,11 @@ void CodeGenTypes::UpdateCompletedType(c
// yet, we'll just do it lazily.
if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
ConvertRecordDeclType(RD);
+
+ // If necessary, provide the full definition of a type only used with a
+ // declaration so far.
+ if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
+ DI->completeFwdDecls(RD);
}
static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
More information about the cfe-commits
mailing list