This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Skip debug location check for some non-inlinable functions
ClosedPublic

Authored by ychen on Aug 31 2022, 3:13 PM.

Details

Summary

If a callee function is not interposable, skip debug location check for its callsites. Doing this is instrumentation-friendly otherwise under some conditions this check triggers for some un-inlinable call sites.

Diff Detail

Event Timeline

ychen created this revision.Aug 31 2022, 3:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 3:13 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
ychen requested review of this revision.Aug 31 2022, 3:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 3:13 PM

This comment from GlobalValue::isDefinitionExact() makes me wonder if this is the right condition? Sounds like there are some non-exact functions that may be inlined?

/// Inlining is okay across non-exact linkage types as long as they're not
/// interposable (see \c isInterposable), since in such cases the currently
/// visible variant is *a* correct implementation of the original source
/// function; it just isn't the *only* correct implementation.
ychen added a comment.Sep 1 2022, 3:35 PM

This comment from GlobalValue::isDefinitionExact() makes me wonder if this is the right condition? Sounds like there are some non-exact functions that may be inlined?

/// Inlining is okay across non-exact linkage types as long as they're not
/// interposable (see \c isInterposable), since in such cases the currently
/// visible variant is *a* correct implementation of the original source
/// function; it just isn't the *only* correct implementation.

Hmm, thanks for catching that. There are actually a bunch of other attributes that matter (https://github.com/llvm/llvm-project/blob/fdec50182d85ec0b8518af3baae37ae28b102f1c/llvm/lib/Analysis/InlineCost.cpp#L2861). However, I think checking linkages should avoid most of the unnecessary firing of this assertion. I'll change it to check isInterposable.

ychen updated this revision to Diff 457444.Sep 1 2022, 4:51 PM
  • use isInterposable

I wish we had an "isInlineable" function call.

llvm/lib/IR/Verifier.cpp
3448

Can you add a comment here that the intention is to ignore non-inlineable functions? Future readers will probably wonder what isInterposable even means.

aprantl accepted this revision.Sep 2 2022, 8:43 AM

LGTM with the comment added.

This revision is now accepted and ready to land.Sep 2 2022, 8:43 AM
ychen retitled this revision from [Verifier] Skip debug location check for non-exact functions to [Verifier] Skip debug location check for some non-inlinable functions.Sep 2 2022, 10:39 AM
ychen edited the summary of this revision. (Show Details)
ychen updated this revision to Diff 457635.Sep 2 2022, 10:46 AM
  • add comment
This revision was landed with ongoing or failed builds.Sep 2 2022, 11:04 AM
This revision was automatically updated to reflect the committed changes.
ychen marked an inline comment as done.
ychen added a comment.Sep 2 2022, 11:04 AM

Thanks for the review.