This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Use make_early_inc_range() while deleting instructions
ClosedPublic

Authored by aheejin on May 26 2021, 9:47 AM.

Details

Summary

We are deleting phi nodes within the for loop, so this makes sure we
increment the iterator before we delete the instruction pointed by the
iterator.

This started to break in
https://github.com/llvm/llvm-project/commit/a0be08164622bf938855ff5d19dd8e9d0c96b9b3.

Diff Detail

Event Timeline

aheejin created this revision.May 26 2021, 9:47 AM
aheejin requested review of this revision.May 26 2021, 9:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 9:47 AM
aheejin edited the summary of this revision. (Show Details)May 26 2021, 9:49 AM
dschuff accepted this revision.May 26 2021, 9:57 AM

Looks straightforward, thanks for tracking this down.

This revision is now accepted and ready to land.May 26 2021, 9:57 AM

nice small reproducer too.

lebedev.ri added inline comments.May 26 2021, 10:00 AM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4503

Use make_early_inc_range()?

aheejin updated this revision to Diff 348037.May 26 2021, 11:35 AM
aheejin marked an inline comment as done.

Use make_early_inc_range()

aheejin retitled this revision from [SimplifyCFG] Don't use phis() while deleting instructions to [SimplifyCFG] Use make_early_inc_range() while deleting instructions.May 26 2021, 11:36 AM
aheejin edited the summary of this revision. (Show Details)
lebedev.ri accepted this revision.May 26 2021, 11:38 AM

LG, thank you, and sorry for the trouble!

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4503

Is llvm:: really needed?

aheejin marked an inline comment as done.May 26 2021, 11:41 AM
aheejin added inline comments.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4503

No it isn't. Thanks; removed.

aheejin updated this revision to Diff 348041.May 26 2021, 11:41 AM
aheejin marked an inline comment as done.

Remove unnecessary llvm::

This revision was landed with ongoing or failed builds.May 26 2021, 11:43 AM
This revision was automatically updated to reflect the committed changes.