This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] Skip updating calls where OldF isn't the called fn.
ClosedPublic

Authored by fhahn on Sep 14 2021, 6:29 AM.

Details

Summary

When replacing function calls, skip call instructions where the old
function is not the called function, but e.g. the old function is passed
as an argument.

This fixes a crash due to trying to construct invalid IR for the test
case.

Diff Detail

Event Timeline

fhahn requested review of this revision.Sep 14 2021, 6:29 AM
fhahn created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2021, 6:29 AM

What if we are calling bitcasted OldF?

fhahn added a comment.Sep 14 2021, 7:09 AM

What if we are calling bitcasted OldF?

It's undefined behavior, so that's not great.

But already we replace all remaining uses of the old function with a bitcast'd version of the new function, so it shouldn't make things worse much. E.g. I think even without this patch, we could have something like 'store OldF', 'load the stored fn' and call it. Or a no-op bit cast of OldF which is then passed to a call. Or a const global array which contains OldF. Those instances would have the same issue when replacing OldF with the bitcast'd version of NewF.

I guess we could skip replacing functions if there are non-call users, but that might be a bit limiting in terms of reduction power. Or keep around the old function as declaration or something.

aeubanks accepted this revision.Sep 15 2021, 4:40 PM
This revision is now accepted and ready to land.Sep 15 2021, 4:40 PM