This is an archive of the discontinued LLVM Phabricator instance.

[Local] Don't DCE calls that may not return
AbandonedPublic

Authored by nikic on Jan 22 2021, 12:31 PM.

Details

Summary

Calls that aren't willreturn should not be eliminated, as this may remove an infinite loop. In languages where infinite side-effect free loops are undefined behavior, willreturn is inferred from readnone+mustprogress by D94502. Such languages should see no regressions from this change. For languages where infinite loops are well-defined, D94633 infers willreturn for straight-line code.

This patch is a slightly more conservative variation on D94106 which assumes that intrinsics are willreturn, as most target intrinsics have not been properly annotated yet, and we don't want to break DCE for them.

In conjunction with the recently implemented willreturn inference, I hope this is conservative enough to land before LLVM 12 branches.

Diff Detail

Event Timeline

nikic created this revision.Jan 22 2021, 12:31 PM
nikic requested review of this revision.Jan 22 2021, 12:31 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
nikic updated this revision to Diff 318633.Jan 22 2021, 1:00 PM

Rebase after pre-committing some of the libcall willreturn annotations.

Calls that aren't willreturn should not be eliminated, as this may remove an infinite loop.

I think this is a bit misleading on it's own (not wrong though). Maybe provide the link to the willreturn deduction and mention that it is deduced for readonly + mustprogress functions now, consequently, we don't loose optimization opportunities for languages with mustprogress guarantees.

nikic edited the summary of this revision. (Show Details)Jan 22 2021, 1:38 PM
nikic abandoned this revision.Jan 22 2021, 2:56 PM

Dropping this as @fhahn has updated D94106 in the same general direction.

fhahn added a comment.Jan 22 2021, 2:57 PM

Dropping this as @fhahn has updated D94106 in the same general direction.

yeah, sorry for the delay!