This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Function body reduction: don't forget to unset comdat
ClosedPublic

Authored by Tyker on Aug 22 2020, 11:52 AM.

Details

Summary

althought the interstingness test should usually fail when the module is invalid
this changes reduces the frequency at which llvm-reduce generate invalid IR.

Diff Detail

Event Timeline

Tyker created this revision.Aug 22 2020, 11:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2020, 11:52 AM
Tyker requested review of this revision.Aug 22 2020, 11:52 AM
lebedev.ri retitled this revision from [llvm-reduce] Prevent llvm-reduce from generated invalid moduels in some cases. to [llvm-reduce] Function body reduction: don't forget to unset comdat.Aug 22 2020, 11:58 AM

Needs two tests - i agree that comdat makes sense, but i'm not sure about linkage.

Tyker added a comment.EditedAug 22 2020, 12:08 PM

Needs two tests - i agree that comdat makes sense, but i'm not sure about linkage.

always setting it to external is perhaps not the best decision here but some linkages like linkonce_odr are only valid on definitions.

lebedev.ri requested changes to this revision.Aug 22 2020, 12:36 PM

After looking a bit more, i believe deleteBody() should do that.

llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
33

Actually, deleteBody() already does that.

This revision now requires changes to proceed.Aug 22 2020, 12:36 PM
Tyker updated this revision to Diff 287214.Aug 22 2020, 12:57 PM

yeah linkage was already changed.
added a test

lebedev.ri accepted this revision.Aug 22 2020, 1:45 PM

LGTM.
It's an improvement, but i really think this should be moved into deleteBody() itself.

I believe you might also need to fix basic block and instruction reducers - can they not end up deleting everything?

llvm/test/Reduce/remove-function-bodies-comdat.ll
3

Should we also check that the opt -verify passes?

This revision is now accepted and ready to land.Aug 22 2020, 1:45 PM

Commit this? It's an improvement anyways.