This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Do not crash when accessing landingpads of invokes.
ClosedPublic

Authored by fhahn on Nov 15 2022, 3:59 PM.

Details

Summary

Unconditionally removing landing pads results in invalid IR,
if there is a different invoke that uses it. Update the code
to only remove the landing pad if the current invoke is the only
user. Also carefully avoid creating plain branches to bbs with
landing pads we couldn't remove.

Diff Detail

Event Timeline

fhahn created this revision.Nov 15 2022, 3:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 3:59 PM
fhahn requested review of this revision.Nov 15 2022, 3:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2022, 3:59 PM
Herald added a subscriber: wdng. · View Herald Transcript

If it's temporarily invalid as in will fall the verifier, probably should try to avoid getting there in the first place

llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
2

Should add -abort-on-invalid-reduction

arsenm requested changes to this revision.Nov 16 2022, 2:56 PM
This revision now requires changes to proceed.Nov 16 2022, 2:56 PM
fhahn updated this revision to Diff 476236.Nov 17 2022, 2:04 PM

If it's temporarily invalid as in will fall the verifier, probably should try to avoid getting there in the first place

Fair point! I updated the code to only remove the landing pad instruction if the current invoke is the only invoke using it. This also requires extra care when we cannot remove the landing pad and it would be the destination for the branch.

fhahn marked an inline comment as done.Nov 17 2022, 2:04 PM
fhahn added inline comments.
llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
2

Done, thanks!

fhahn edited the summary of this revision. (Show Details)Nov 17 2022, 2:06 PM
arsenm accepted this revision.Nov 17 2022, 2:15 PM
This revision is now accepted and ready to land.Nov 17 2022, 2:15 PM
aeubanks added inline comments.Nov 17 2022, 2:50 PM
llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
2

looks like this wasn't done

aeubanks accepted this revision.Nov 17 2022, 2:51 PM

otherwise lgtm

This revision was landed with ongoing or failed builds.Nov 18 2022, 7:20 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.
fhahn marked an inline comment as done.Nov 18 2022, 9:44 AM
fhahn added inline comments.
llvm/test/tools/llvm-reduce/invoke-with-missing-landingpad.ll
2

Missed to include this in the recent update, fixed in the committed version.