[PATCH] D15798: Fix for Bug 24852 (crash with -debug -instcombine)
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 6 14:37:21 PST 2016
> On 2016-Jan-06, at 14:28, Mehdi AMINI <mehdi.amini at apple.com> wrote:
>
> joker.eph added a comment.
>
> David: I have the same question. It turns out that to reproduce you need to print an instruction that has a metadata attached, but does not have a parent.
That seems easier to reproduce with a unit test rather than a
lit test.
>
> Here is the offending code in InstCombine (with comment from me on what happens):
>
> DEBUG(raw_string_ostream SS(OrigI); I->print(SS); OrigI = SS.str(););
> DEBUG(dbgs() << "IC: Visiting: " << OrigI << '\n');
>
> if (Instruction *Result = visit(*I)) { // <-- Result does not have a parent, neither a dbgloc at this point
> ++NumCombined;
> // Should we replace the old instruction with a new one?
> if (Result != I) {
> DEBUG(dbgs() << "IC: Old = " << *I << '\n'
> << " New = " << *Result << '\n'); // <-- This print succeed because there is no debug location
>
> if (I->getDebugLoc())
> Result->setDebugLoc(I->getDebugLoc()); // <-- here we set the debug location, still no parent
> // Everything uses the new instruction now.
> I->replaceAllUsesWith(Result); // <- we are in a state where we have user but still no parent, is it valid?
>
> // Move the name to the new instruction first.
> Result->takeName(I);
>
> // Push the new instruction and any users onto the worklist.
> Worklist.Add(Result); // <- This is where we will try to print again, but this time with a debug location and no parent (->crash)
> Worklist.AddUsersToWorkList(*Result);
>
> // Insert the new instruction into the basic block...
> BasicBlock *InstParent = I->getParent();
> BasicBlock::iterator InsertPos = I->getIterator();
>
>
> http://reviews.llvm.org/D15798
>
>
>
More information about the llvm-commits
mailing list