This is an archive of the discontinued LLVM Phabricator instance.

Inliner: don't mark call sites as 'nounwind' if that would be redundant
ClosedPublic

Authored by nhaehnle on Jul 15 2022, 8:18 AM.

Details

Summary

When F calls G calls H, G is nounwind, and G is inlined into F, then the
inlined call-site to H should be effectively nounwind so as not to lose
information during inlining.

If H itself is nounwind (which often happens when H is an intrinsic), we
no longer mark the callsite explicitly as nounwind. Previously, there
were cases where the inlined call-site of H differs from a pre-existing
call-site of H in F *only* in the explicitly added nounwind attribute,
thus preventing common subexpression elimination.

Diff Detail

Event Timeline

nhaehnle created this revision.Jul 15 2022, 8:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2022, 8:18 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nhaehnle requested review of this revision.Jul 15 2022, 8:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2022, 8:18 AM
nikic added a subscriber: nikic.Jul 15 2022, 8:31 AM
nikic added inline comments.
llvm/lib/Transforms/Utils/InlineFunction.cpp
2210

Writing this as !CI->doesNotThrow() might be more elegant? That checks the function attribute as well.

nhaehnle updated this revision to Diff 445484.Jul 18 2022, 7:18 AM

Address review comment

nhaehnle marked an inline comment as done.Jul 18 2022, 7:19 AM
nhaehnle added inline comments.
llvm/lib/Transforms/Utils/InlineFunction.cpp
2210

I like that idea.

rnk accepted this revision.Jul 18 2022, 7:58 AM

Sounds good to me.

This revision is now accepted and ready to land.Jul 18 2022, 7:58 AM
This revision was landed with ongoing or failed builds.Jul 18 2022, 8:29 AM
This revision was automatically updated to reflect the committed changes.
nhaehnle marked an inline comment as done.