diff options
author | Manman Ren <mren@apple.com> | 2013-02-01 23:54:37 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2013-02-01 23:54:37 +0000 |
commit | 945e828003b746f6bbe86390940cf1433d18b0a1 (patch) | |
tree | ce478175601898beddd51e8d7b4e0b1c9695ac6d /lib/CodeGen | |
parent | dbc86b98f2acd459ab3270cd8500afd32eba7b09 (diff) | |
download | external_llvm-945e828003b746f6bbe86390940cf1433d18b0a1.zip external_llvm-945e828003b746f6bbe86390940cf1433d18b0a1.tar.gz external_llvm-945e828003b746f6bbe86390940cf1433d18b0a1.tar.bz2 |
[Dwarf] avoid emitting multiple AT_const_value for static memebers.
Testing case is reduced from MultiSource/BenchMarks/Prolangs-C++/deriv1.
rdar://problem/13071590
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index f0655e6..dad1054 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1286,6 +1286,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { // If this is a static data member definition, some attributes belong // to the declaration DIE. DIE *VariableDIE = NULL; + bool IsStaticMember = false; DIDerivedType SDMDecl = GV.getStaticDataMemberDeclaration(); if (SDMDecl.Verify()) { assert(SDMDecl.isStaticMember() && "Expected static member decl"); @@ -1295,6 +1296,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { getOrCreateContextDIE(SDMDecl.getContext()); VariableDIE = getDIE(SDMDecl); assert(VariableDIE && "Static member decl has no context?"); + IsStaticMember = true; } // If this is not a static data member definition, create the variable @@ -1348,9 +1350,13 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) { addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, getRealLinkageName(LinkageName)); } else if (const ConstantInt *CI = - dyn_cast_or_null<ConstantInt>(GV.getConstant())) - addConstantValue(VariableDIE, CI, GTy.isUnsignedDIType()); - else if (const ConstantExpr *CE = getMergedGlobalExpr(N->getOperand(11))) { + dyn_cast_or_null<ConstantInt>(GV.getConstant())) { + // AT_const_value was added when the static memeber was created. To avoid + // emitting AT_const_value multiple times, we only add AT_const_value when + // it is not a static member. + if (!IsStaticMember) + addConstantValue(VariableDIE, CI, GTy.isUnsignedDIType()); + } else if (const ConstantExpr *CE = getMergedGlobalExpr(N->getOperand(11))) { addToAccelTable = true; // GV is a merged global. DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); |