This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare] Fix zapping dead operands of assume
ClosedPublic

Authored by yrouban on Sep 9 2020, 10:46 PM.

Details

Summary

This patch fixes a problem of the commit
52cc97a0 Zap the argument of llvm.assume when deleting it
A test case is created to demonstrate the crash caused by the instruction iterator invalidated by the recursive removal of dead operands of assume. The solution restarts from the first instruction in case CurInstIterator is invalidated by RecursivelyDeleteTriviallyDeadInstructions().

Diff Detail

Event Timeline

yrouban created this revision.Sep 9 2020, 10:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 10:46 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
yrouban requested review of this revision.Sep 9 2020, 10:46 PM

Thanks. Can we just wrap it in resetIteratorIfInvalidatedWhileCalling like the call a few lines later? That seems less error prone.

Thanks. Can we just wrap it in resetIteratorIfInvalidatedWhileCalling like the call a few lines later? That seems less error prone.

Ok, but it will be less efficient.

yrouban updated this revision to Diff 291159.Sep 11 2020, 1:48 AM

RecursivelyDeleteTriviallyDeadInstructions() call is wrapped with resetIteratorIfInvalidatedWhileCalling().

yrouban edited the summary of this revision. (Show Details)Sep 11 2020, 1:49 AM
bkramer accepted this revision.Sep 11 2020, 2:15 AM

Thanks, I prefer simplicity over efficiency here.

This revision is now accepted and ready to land.Sep 11 2020, 2:15 AM
This revision was automatically updated to reflect the committed changes.