From fce2219764f00e1b6de75bca08d9b10a212165b5 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 5 Oct 2015 23:11:20 +0000 Subject: [PATCH] dsymutil: Don't prune forward declarations inside of an imported TAG_module if there exists not definition for the type. For this to work, we need to clone the imported modules before building the decl context chains of the DIEs in the non-skeleton CUs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249362 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/dsymutil/Inputs/submodules/1.o | Bin 2208 -> 2232 bytes .../dsymutil/Inputs/submodules/Parent.pcm | Bin 25104 -> 25260 bytes test/tools/dsymutil/X86/submodules.m | 16 +++++++++++++++- tools/dsymutil/DwarfLinker.cpp | 17 +++++++++++------ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/test/tools/dsymutil/Inputs/submodules/1.o b/test/tools/dsymutil/Inputs/submodules/1.o index f95b70cd05cd20746926f53cecef077746164d19..d38e30f67c2c4f8031669ae48cdde5743400ef9b 100644 GIT binary patch delta 519 zcmZ1=xI=J)gJ3T+0~mZ@fzZ7Z1Mf4|Og3b67n}hRfs-ARI~ncaqWw_uj>$I}?IqP2 zA>3O~QE@g1qhYckler)x6I2*VeVkm$WDgg$fs395irPZesz60`CrdKh3nrq822Rcd zinc;U)1YcgC+}pom;3+~HGqmfU}s7Mm-BKrSA%)SV2M{AOggU;VD3p$zVE=WMi6G0dfhPS5O4z%>$AQ z?3qAI~ncaqWw_urpY%M?Ijf% zA>3n7Q9(8cBV)25leyq?s4P^H;rirCCVRN34OIC0c7I{ z4h{wekYi^|p2;#n!otMTOjAK4C#Nh|zoe)%FI&OL1Sn=c*^yOxauVxS#u<|(*jxe` zSQynTfSOoA=74|*5Hp6y0ZAtHW+2JNG_fKbnOBel=5+x{2KHni!OFq`3Q&$IAc4Zk z2ia6OYbLIJ3gj^aOn%3vF90$OG`5R7|0;v4569yQzOj@ds2G&U=%aDT7|# zd-vYYIp=%NJ@@jG*U=Z>qNGop>w`ku=8OG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HeBXn~x~Va+eJ4DY+Rtf%=eHINME35x`4p0ZjJg2apJZ720w-9cxNoI`%w z%lup~&IZYwe{khrT*3Hlzx3*zI{q9ary0MsNmr*+@Q^1={U7Skv4^ZQ)LX-PZJxG} zE!{NS2b#FA*eN@=!rff?&Kw07ZmFd_i^1iaJ{}63kKHbP^D`Er~Xv{$a&{z#r z(lrPRhH9<|(Rph&JP!Rxz6qbz(Y=OXNGII&-M_ypAzj%T(e+igpMGLsL ztqRR6#=g0weWEeKndiXrDPWF>=C^|7d(u418DldAJ@f-m#PLk+Gs#i$?~ZJ*>N}E z1`gu&5oijSI^|c1si#P4>g)=Ksye|@nYn3< zUtuH1La}hii7L%UWV+X!4Y&nq$FLwi*sX7HkLJ~6NfE%I$raV_5TiUNKV0^j)DZ*& zMVu3x8uMjre+9rn%G>r^o$e*Hjo#!kwOa-_Lw44b)iUa0;#Cl6Ppu|kLsxfuI2P(S z;iswVbd+^PdX7bVg;GfqUTOkZU}hLHRr9!bv1d1VV`Bs@o^`k#>(`B6zuTt1Ep-g^ z3dL-}0SxCWxQ}fJs@f4ug%AjL$l2x?QpmUFP3x(4k=DXqI&P?ediQ6gy2Hg_xu?xx zbPXnf7W)!WO%iMCB_gzj33r4(@5zzYQ3lybW6;ZCg#`r#getAttributeValueAsUnsignedConstant( &CU.getOrigUnit(), dwarf::DW_AT_declaration, 0); + // Don't prune it if there is no definition for the DIE. + Info.Prune &= Info.Ctxt && Info.Ctxt->getCanonicalDIEOffset(); + return Info.Prune; } @@ -3338,21 +3341,23 @@ bool DwarfLinker::link(const DebugMap &Map) { DWARFContextInMemory DwarfContext(*ErrOrObj); startDebugObject(DwarfContext, *Obj); - // In a first phase, just read in the debug info and store the DIE - // parent links that we will use during the next phase. + // In a first phase, just read in the debug info and load all clang modules. for (const auto &CU : DwarfContext.compile_units()) { auto *CUDie = CU->getUnitDIE(false); if (Options.Verbose) { outs() << "Input compilation unit:"; CUDie->dump(outs(), CU.get(), 0); } - if (!registerModuleReference(*CUDie, *CU, ModuleMap)) { + + if (!registerModuleReference(*CUDie, *CU, ModuleMap)) Units.emplace_back(*CU, UnitID++, !Options.NoODR, ""); - analyzeContextInfo(CUDie, 0, Units.back(), &ODRContexts.getRoot(), - StringPool, ODRContexts); - } } + // Now build the DIE parent links that we will use during the next phase. + for (auto &CurrentUnit : Units) + analyzeContextInfo(CurrentUnit.getOrigUnit().getUnitDIE(), 0, CurrentUnit, + &ODRContexts.getRoot(), StringPool, ODRContexts); + // Then mark all the DIEs that need to be present in the linked // output and collect some information about them. Note that this // loop can not be merged with the previous one becaue cross-cu -- 2.34.1