Replace a pile of calls with an instance variable that's set

once. Should be no functional change.

llvm-svn: 181964
This commit is contained in:
Eric Christopher 2013-05-16 00:45:23 +00:00
parent 2ec1211c87
commit 75e1768b46
2 changed files with 20 additions and 17 deletions

View File

@ -41,7 +41,8 @@ using namespace clang;
using namespace clang::CodeGen; using namespace clang::CodeGen;
CGDebugInfo::CGDebugInfo(CodeGenModule &CGM) CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
: CGM(CGM), DBuilder(CGM.getModule()), : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
DBuilder(CGM.getModule()),
BlockLiteralGenericSet(false) { BlockLiteralGenericSet(false) {
CreateCompileUnit(); CreateCompileUnit();
} }
@ -602,7 +603,7 @@ llvm::DIDescriptor CGDebugInfo::createContextChain(const Decl *Context) {
/// then emit record's fwd if debug info size reduction is enabled. /// then emit record's fwd if debug info size reduction is enabled.
llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy, llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy,
llvm::DIFile Unit) { llvm::DIFile Unit) {
if (CGM.getCodeGenOpts().getDebugInfo() != CodeGenOptions::LimitedDebugInfo) if (DebugKind != CodeGenOptions::LimitedDebugInfo)
return getOrCreateType(PointeeTy, Unit); return getOrCreateType(PointeeTy, Unit);
// Limit debug info for the pointee type. // Limit debug info for the pointee type.
@ -1367,7 +1368,7 @@ CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,
/// getOrCreateRecordType - Emit record type's standalone debug info. /// getOrCreateRecordType - Emit record type's standalone debug info.
llvm::DIType CGDebugInfo::getOrCreateRecordType(QualType RTy, llvm::DIType CGDebugInfo::getOrCreateRecordType(QualType RTy,
SourceLocation Loc) { SourceLocation Loc) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
llvm::DIType T = getOrCreateType(RTy, getOrCreateFile(Loc)); llvm::DIType T = getOrCreateType(RTy, getOrCreateFile(Loc));
return T; return T;
} }
@ -1376,7 +1377,7 @@ llvm::DIType CGDebugInfo::getOrCreateRecordType(QualType RTy,
/// debug info. /// debug info.
llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D, llvm::DIType CGDebugInfo::getOrCreateInterfaceType(QualType D,
SourceLocation Loc) { SourceLocation Loc) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
llvm::DIType T = getOrCreateType(D, getOrCreateFile(Loc)); llvm::DIType T = getOrCreateType(D, getOrCreateFile(Loc));
RetainedTypes.push_back(D.getAsOpaquePtr()); RetainedTypes.push_back(D.getAsOpaquePtr());
return T; return T;
@ -2083,7 +2084,7 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
StringRef RDName = getClassName(RD); StringRef RDName = getClassName(RD);
llvm::DIDescriptor RDContext; llvm::DIDescriptor RDContext;
if (CGM.getCodeGenOpts().getDebugInfo() == CodeGenOptions::LimitedDebugInfo) if (DebugKind == CodeGenOptions::LimitedDebugInfo)
RDContext = createContextChain(cast<Decl>(RD->getDeclContext())); RDContext = createContextChain(cast<Decl>(RD->getDeclContext()));
else else
RDContext = getContextDescriptor(cast<Decl>(RD->getDeclContext())); RDContext = getContextDescriptor(cast<Decl>(RD->getDeclContext()));
@ -2293,10 +2294,10 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
if (LinkageName == Name || if (LinkageName == Name ||
(!CGM.getCodeGenOpts().EmitGcovArcs && (!CGM.getCodeGenOpts().EmitGcovArcs &&
!CGM.getCodeGenOpts().EmitGcovNotes && !CGM.getCodeGenOpts().EmitGcovNotes &&
CGM.getCodeGenOpts().getDebugInfo() <= CodeGenOptions::DebugLineTablesOnly)) DebugKind <= CodeGenOptions::DebugLineTablesOnly))
LinkageName = StringRef(); LinkageName = StringRef();
if (CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) { if (DebugKind >= CodeGenOptions::LimitedDebugInfo) {
if (const NamespaceDecl *NSDecl = if (const NamespaceDecl *NSDecl =
dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext())) dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
FDContext = getOrCreateNameSpace(NSDecl); FDContext = getOrCreateNameSpace(NSDecl);
@ -2325,7 +2326,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
llvm::DIType DIFnType; llvm::DIType DIFnType;
llvm::DISubprogram SPDecl; llvm::DISubprogram SPDecl;
if (HasDecl && if (HasDecl &&
CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo) { DebugKind >= CodeGenOptions::LimitedDebugInfo) {
DIFnType = getOrCreateFunctionType(D, FnType, Unit); DIFnType = getOrCreateFunctionType(D, FnType, Unit);
SPDecl = getFunctionDeclaration(D); SPDecl = getFunctionDeclaration(D);
} else { } else {
@ -2514,7 +2515,7 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
llvm::Value *Storage, llvm::Value *Storage,
unsigned ArgNo, CGBuilderTy &Builder) { unsigned ArgNo, CGBuilderTy &Builder) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
llvm::DIFile Unit = getOrCreateFile(VD->getLocation()); llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
@ -2654,7 +2655,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD,
llvm::Value *Storage, llvm::Value *Storage,
CGBuilderTy &Builder) { CGBuilderTy &Builder) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, 0, Builder); EmitDeclare(VD, llvm::dwarf::DW_TAG_auto_variable, Storage, 0, Builder);
} }
@ -2675,7 +2676,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD,
llvm::Value *Storage, llvm::Value *Storage,
CGBuilderTy &Builder, CGBuilderTy &Builder,
const CGBlockInfo &blockInfo) { const CGBlockInfo &blockInfo) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
if (Builder.GetInsertBlock() == 0) if (Builder.GetInsertBlock() == 0)
@ -2744,7 +2745,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD,
void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI, void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
unsigned ArgNo, unsigned ArgNo,
CGBuilderTy &Builder) { CGBuilderTy &Builder) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, ArgNo, Builder); EmitDeclare(VD, llvm::dwarf::DW_TAG_arg_variable, AI, ArgNo, Builder);
} }
@ -2762,7 +2763,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
llvm::Value *Arg, llvm::Value *Arg,
llvm::Value *LocalAddr, llvm::Value *LocalAddr,
CGBuilderTy &Builder) { CGBuilderTy &Builder) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
ASTContext &C = CGM.getContext(); ASTContext &C = CGM.getContext();
const BlockDecl *blockDecl = block.getBlockDecl(); const BlockDecl *blockDecl = block.getBlockDecl();
@ -2928,7 +2929,7 @@ llvm::DIDerivedType CGDebugInfo::getStaticDataMemberDeclaration(const Decl *D) {
/// EmitGlobalVariable - Emit information about a global variable. /// EmitGlobalVariable - Emit information about a global variable.
void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
const VarDecl *D) { const VarDecl *D) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
// Create global variable debug descriptor. // Create global variable debug descriptor.
llvm::DIFile Unit = getOrCreateFile(D->getLocation()); llvm::DIFile Unit = getOrCreateFile(D->getLocation());
unsigned LineNo = getLineNumber(D->getLocation()); unsigned LineNo = getLineNumber(D->getLocation());
@ -2963,7 +2964,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
/// EmitGlobalVariable - Emit information about an objective-c interface. /// EmitGlobalVariable - Emit information about an objective-c interface.
void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
ObjCInterfaceDecl *ID) { ObjCInterfaceDecl *ID) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
// Create global variable debug descriptor. // Create global variable debug descriptor.
llvm::DIFile Unit = getOrCreateFile(ID->getLocation()); llvm::DIFile Unit = getOrCreateFile(ID->getLocation());
unsigned LineNo = getLineNumber(ID->getLocation()); unsigned LineNo = getLineNumber(ID->getLocation());
@ -2989,7 +2990,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
/// EmitGlobalVariable - Emit global variable's debug info. /// EmitGlobalVariable - Emit global variable's debug info.
void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
llvm::Constant *Init) { llvm::Constant *Init) {
assert(CGM.getCodeGenOpts().getDebugInfo() >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
// Create the descriptor for the variable. // Create the descriptor for the variable.
llvm::DIFile Unit = getOrCreateFile(VD->getLocation()); llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
StringRef Name = VD->getName(); StringRef Name = VD->getName();

View File

@ -18,6 +18,7 @@
#include "clang/AST/Expr.h" #include "clang/AST/Expr.h"
#include "clang/AST/Type.h" #include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceLocation.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/DIBuilder.h" #include "llvm/DIBuilder.h"
#include "llvm/DebugInfo.h" #include "llvm/DebugInfo.h"
@ -46,6 +47,7 @@ namespace CodeGen {
/// the backend. /// the backend.
class CGDebugInfo { class CGDebugInfo {
CodeGenModule &CGM; CodeGenModule &CGM;
CodeGenOptions::DebugInfoKind DebugKind;
llvm::DIBuilder DBuilder; llvm::DIBuilder DBuilder;
llvm::DICompileUnit TheCU; llvm::DICompileUnit TheCU;
SourceLocation CurLoc, PrevLoc; SourceLocation CurLoc, PrevLoc;
@ -274,7 +276,7 @@ public:
/// getOrCreateInterfaceType - Emit an objective c interface type standalone /// getOrCreateInterfaceType - Emit an objective c interface type standalone
/// debug info. /// debug info.
llvm::DIType getOrCreateInterfaceType(QualType Ty, llvm::DIType getOrCreateInterfaceType(QualType Ty,
SourceLocation Loc); SourceLocation Loc);
private: private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration. /// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.