This is an archive of the discontinued LLVM Phabricator instance.

[InstructionCombining] prepareICWorklistFromFunction halts in infinite loop with instructions of token type
ClosedPublic

Authored by chenli on Jan 4 2016, 10:45 AM.

Details

Summary

This patch fixes a bug in prepareICWorklistFromFunction, where the loop becomes infinite with instructions of token type. The patch checks if the instruction is token type, and if so it updates EndInst with the current instruction.

Diff Detail

Repository
rL LLVM

Event Timeline

chenli updated this revision to Diff 43899.Jan 4 2016, 10:45 AM
chenli retitled this revision from to [InstructionCombining] prepareICWorklistFromFunction halts in infinite loop with instructions of token type.
chenli updated this object.
chenli added a reviewer: majnemer.
chenli added a subscriber: llvm-commits.
majnemer added inline comments.Jan 4 2016, 1:54 PM
lib/Transforms/InstCombine/InstructionCombining.cpp
3022–3032 ↗(On Diff #43899)

Would anything go wrong if we simply had:

if (!Inst->use_empty())
  Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
if (Inst->isEHPad()) {
  EndInst = Inst;
  continue;
}
if (!isa<DbgInfoIntrinsic>(Inst)) {
  ++NumDeadInst;
  MadeIRChange = true;
}

Inst->eraseFromParent();
chenli added inline comments.Jan 4 2016, 2:31 PM
lib/Transforms/InstCombine/InstructionCombining.cpp
3022–3032 ↗(On Diff #43899)

It will actually hit a verifier assertion failure if gc.relocate instruction takes an undef gc.statepoint token. But the verifier could be fixed in a later patch if we'd like to have the code you suggested. I dont know if there's similar issues for uses of cleanuppad or catchpad.

majnemer accepted this revision.Jan 4 2016, 2:41 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 4 2016, 2:41 PM
This revision was automatically updated to reflect the committed changes.