This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Add helper to change an instruction to `unreachable` inst
ClosedPublic

Authored by uenoku on Dec 26 2019, 9:27 AM.

Details

Summary

Calling changeToUnreachable in manifest from different places might cause really unpredictable problems. As other deleting functions are doing, we need to change these instructions after all manifest.

Diff Detail

Event Timeline

uenoku created this revision.Dec 26 2019, 9:27 AM
Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert accepted this revision.Dec 26 2019, 9:31 AM

This makes sense and LGTM.

FWIW. We have to go over the entire "rewrite after manifest" stuff soon.

This revision is now accepted and ready to land.Dec 26 2019, 9:31 AM

This makes sense and LGTM.

FWIW. We have to go over the entire "rewrite after manifest" stuff soon.

I think so too.

uenoku retitled this revision from [Attributor] Add helper to change an instruction to `unrechable` inst to [Attributor] Add helper to change an instruction to `unreachable` inst.Dec 26 2019, 9:38 AM
uenoku edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.
baziotis added inline comments.
llvm/include/llvm/Transforms/IPO/Attributor.h
1040–1041

How about a SmallVector here? I think it makes sense since we never lookup values on this set (which is I guess the primary reason to make a set), it should have amortized O(1) and it is easier to loop over.

1040–1041

Oh my bad, I just saw it was committed.

uenoku marked an inline comment as done.Dec 26 2019, 10:04 AM
uenoku added inline comments.
llvm/include/llvm/Transforms/IPO/Attributor.h
1040–1041

I think SmallVector isn't a set. We don't want to change the same instruction to unreachable twice so SmallPtrSet seems good to me.

baziotis added inline comments.Dec 26 2019, 10:11 AM
llvm/include/llvm/Transforms/IPO/Attributor.h
1040–1041

Yes, that's a safer way.