Debug info questy (was Re: [llvm] r256003 - [ThinLTO/LTO] Don't link in unneeded metadata)

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 6 14:22:36 PST 2016


On Wed, Jan 6, 2016 at 1:33 PM, Teresa Johnson <tejohnson at google.com> wrote:
> Here is the change I made which fixes the test case. I can add some
> comments and a test case, but let me know if this looks ok otherwise.
> As Eric noted, the DISubroutine for a() is marked as a definition,
> which it isn't actually, but this was the behavior before this patch
> and seems to work ok.

FWIW, this patch [0] fixes the issue [1] for me.

Thanks for taking care of this Teresa!
-Ahmed

[0] on r256768 and with a fix for the unrelated PR25919
[1] llc build, OS X, -O2 -flto -g

> Thanks,
> Teresa
>
> diff --git a/lib/Linker/IRMover.cpp b/lib/Linker/IRMover.cpp
> index 309690f..9900ecc 100644
> --- a/lib/Linker/IRMover.cpp
> +++ b/lib/Linker/IRMover.cpp
> @@ -1211,6 +1211,12 @@ void
> IRLinker::findNeededSubprograms(ValueToValueMapTy &ValueMap) {
>    for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) {
>      auto *CU = cast<DICompileUnit>(CompileUnits->getOperand(I));
>      assert(CU && "Expected valid compile unit");
> +    SmallPtrSet<DISubprogram *, 8> ImportedEntitySPs;
> +    for (auto *IE : CU->getImportedEntities()) {
> +      assert(IE->getEntity());
> +      if (auto *SP = dyn_cast<DISubprogram>(IE->getEntity()))
> +        ImportedEntitySPs.insert(SP);
> +    }
>      for (auto *Op : CU->getSubprograms()) {
>        // Unless we were doing function importing and deferred metadata linking,
>        // any needed SPs should have been mapped as they would be reached
> @@ -1218,7 +1224,7 @@ void
> IRLinker::findNeededSubprograms(ValueToValueMapTy &ValueMap) {
>        // function bodies, or from DILocation on inlined instructions).
>        assert(!(ValueMap.MD()[Op] && IsMetadataLinkingPostpass) &&
>               "DISubprogram shouldn't be mapped yet");
> -      if (!ValueMap.MD()[Op])
> +      if (!ValueMap.MD()[Op] && !ImportedEntitySPs.count(Op))
>          UnneededSubprograms.insert(Op);
>      }
>    }


More information about the llvm-commits mailing list