[IR] remove assert since always_inline can appear on CallBase
authorNick Desaulniers <ndesaulniers@google.com>
Mon, 28 Jun 2021 20:53:55 +0000 (13:53 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Mon, 28 Jun 2021 20:53:57 +0000 (13:53 -0700)
commit8aee282f57f42773570fc5d29f03a03361ff7fb4
tree5c960242b5c562e04e08022d0bafbf390b66c6f7
parenta00ad8599045ce7d0b5d2a64a8d22267df37bd14
[IR] remove assert since always_inline can appear on CallBase

I added an assertion in D91816 (documenting behavior added in D93422)
that callers and callees with mismatched fn attr's related to stack
protectors should not occur unless the callee was attributed
always_inline.

This falls apart when a call, invoke, or callbr (any instruction
inheriting from CallBase) itself has an always_inline attribute. Clang
will emit such attributes on Instructions when __attribute__((flatten))
is used to recursively force inlining from a caller.

Since these assertions only had the caller and callee Functions, and not
the call site (CallBase derived classes), we would have to search the
caller for such instructions to reconstruct the call site information.
But at that point, inlining has already occurred; the call site has
already been removed from the caller.

Remove the assertions, add a unit test for always_inline call sites, and
update the LangRef.

Another curiosity is that the always_inline Attribute on Instructions is
only expanded by the inline pass, not the always_inline pass.

Thanks to @pcc on this report when building Android's RunTime (ART)
interpreter.

Reviewed By: pcc, MaskRay

Differential Revision: https://reviews.llvm.org/D104944
llvm/docs/LangRef.rst
llvm/lib/IR/Attributes.cpp
llvm/test/Transforms/Inline/inline_nossp.ll