This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Try harder to not create invalid aliases
ClosedPublic

Authored by aeubanks on Aug 9 2022, 9:18 AM.

Details

Summary

This was done by adding --abort-on-invalid-reduction to remove-function-bodies-used-in-globals.ll and fixing the fallout.

Aliases must have a GlobalValue or ConstantExpr aliasee and the aliasee must be a definition if it's a GlobalValue.
Don't RAUW functions with null if there's an alias pointing to it, and similarly don't delete the body of a function.
Don't delete the entire body of a function when reducing blocks, preserve at least one block.

Also make debugging these sorts of things easier by dumping the module when --abort-on-invalid-reduction triggers.

Diff Detail

Event Timeline

aeubanks created this revision.Aug 9 2022, 9:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 9:18 AM
aeubanks requested review of this revision.Aug 9 2022, 9:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 9:18 AM

LGTM

I like the debug output and I also like making more test cases abort on invalid IR, we definitely have some bugs to flush out here.

regehr accepted this revision.Aug 10 2022, 3:50 PM
This revision is now accepted and ready to land.Aug 10 2022, 3:50 PM
This revision was landed with ongoing or failed builds.Aug 12 2022, 10:39 AM
This revision was automatically updated to reflect the committed changes.