This is an archive of the discontinued LLVM Phabricator instance.

SROA: Defer migrating the debug info for new allocas until after all partitions are created.
ClosedPublic

Authored by aprantl on Dec 22 2014, 4:15 PM.

Details

Reviewers
chandlerc
Summary

SROA: Defer migrating the debug info for new allocas until after all partitions are created.
As discussed on #llvm today.

Diff Detail

Event Timeline

aprantl updated this revision to Diff 17580.Dec 22 2014, 4:15 PM
aprantl retitled this revision from to SROA: Defer migrating the debug info for new allocas until after all partitions are created..
aprantl updated this object.
aprantl edited the test plan for this revision. (Show Details)
aprantl added a reviewer: chandlerc.
aprantl set the repository for this revision to rL LLVM.
aprantl added a subscriber: Unknown Object (MLST).
chandlerc added inline comments.Dec 22 2014, 4:20 PM
lib/Transforms/Scalar/SROA.cpp
3593

Rather than a member, how about a local here...

3607–3612

And change rewritePartition so that if it makes changes it returns the changed alloca. We can compare against &AI to handle the case that we got back the same alloca that went in, and we'll never get back the same alloca when we end up with more than one.

aprantl updated this revision to Diff 17582.Dec 22 2014, 6:00 PM
aprantl removed rL LLVM as the repository for this revision.
chandlerc edited edge metadata.Dec 22 2014, 6:07 PM

Is it possible to craft a test case for this? I'm thinking an alloca which needs rewriting but not splitting...

lib/Transforms/Scalar/SROA.cpp
3600

Just call the parameters the same name as the members. This does the right thing in the initializer list. I would probably use AI, Offset, and Size.

3603

I think you at least want a smallvector with 1 piece in it.

3611–3612

Any reason not to actually handle the null case for now? I think the code would be pretty clean:

if (AllocaInst *NewAI = rewritePartition(AI, AS, P)) {
  Changed = true;
  if (NewAI != &AI)
    Pieces.push_back(...);
}
++NumPartitions;
3627

I would say:

bool IsSplit = ...;
aprantl updated this revision to Diff 17606.Dec 23 2014, 12:46 PM
aprantl edited edge metadata.
  • Addressed all of Chandler's comments.
  • Added a testcase were the alloca is rewritten but not repartitioned.
aprantl updated this revision to Diff 17611.Dec 23 2014, 3:13 PM

Tiny update: Don't add the dbg.declare to DeadInsts. It's redundant because it will get removed automatically when the alloca is removed. It's also a bad idea to remove the same instruction more than once.

aprantl updated this revision to Diff 17615.Dec 23 2014, 4:56 PM

When compiling really large programs the pointer values in the DbgDeclares map may actually get recycled.

  • clear the pointer map when entering a function
  • remove values after the dbg.declare has been deleted

tested via an assertion.

chandlerc accepted this revision.Dec 23 2014, 6:31 PM
chandlerc edited edge metadata.

Just want to say this LGTM in whatever form you decide to commit it.

I know there was a revert in between, so feel free to just commit the new version, or re-apply the old one and then commit this on top. Whatever works.

This revision is now accepted and ready to land.Dec 23 2014, 6:31 PM
aprantl closed this revision.Aug 18 2015, 10:42 AM

This was r226598.