This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Use assumed information to determine side-effects
ClosedPublic

Authored by jdoerfert on Jan 23 2020, 4:55 PM.

Details

Summary

We relied on wouldInstructionBeTriviallyDead before but that functions
does not take assumed information, especially for calls, into account.
The replacement, AAIsDead::isAssumeSideEffectFree, does.

This change makes AAIsDeadCallSiteReturn more complex as we can have
a dead call or only dead users.

The test have been modified to include a side effect where there was
none in order to keep the coverage.

Diff Detail

Event Timeline

jdoerfert created this revision.Jan 23 2020, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2020, 4:55 PM

Sorry for the delay.

llvm/lib/Transforms/IPO/Attributor.cpp
2856

Few question:

  • should isSafeToSpeculativelyExecute also be checked here?
  • If we had AASpeculatable this could be replaced with that, right? Or is it better to use this for speculatable deduction?

While I am at it, speculatable could also be used for AAUndefinedBehaviour, rigtht?

Btw, I'll probably start working on speculatable this week.

2906–2911

Shouldn't I always be AssumedSideEffectFree at this point?

3015

typo: separately

jdoerfert marked 2 inline comments as done.Feb 4 2020, 10:14 PM
jdoerfert added inline comments.
llvm/lib/Transforms/IPO/Attributor.cpp
2856

should isSafeToSpeculativelyExecute also be checked here?

I don't think so. We can delete the code if it is side-effect free and has no live users.

If we had AASpeculatable this could be replaced with that, right? Or is it better to use this for speculatable deduction?

So AASpeculatable would derive the speculatable attribute, which allows us and other passes to move code out of control dependences, e.g.,
if (...) do_sth_speculatable(); can become do_sth_speculatable(); if (...) ;

While I am at it, speculatable could also be used for AAUndefinedBehaviour, rigtht?

Let's discuss that on the AAspeculatable patch, I'm not 100% sure right now what you mean.

Btw, I'll probably start working on speculatable this week.

That sounds great!

2906–2911

That's a good point. I'll check why this is here.

jdoerfert marked 3 inline comments as done.

Rebase and addressed comments

llvm/lib/Transforms/IPO/Attributor.cpp
2906–2911

It is because we conflate two things here, (1) dead users and (2) no side-effects. The former allows us to drop the returned values even if we have side-effects (for a function/call). I'll added a comment.

This revision is now accepted and ready to land.Feb 12 2020, 6:07 AM
This revision was automatically updated to reflect the committed changes.