[clang] [clang][Sema] Add noinline check for __builtin_frame_address and __builtin_return_address (PR #82966)

Nick Desaulniers via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 12:44:02 PST 2024


nickdesaulniers wrote:

> Does anyone understand why Linux uses __builtin_return_address there? 

Grep turns up 257 callers of `__builtin_return_address` in the linux kernel sources. Hard to say definitely for all cases.  It's possible that some are incorrect, or should have their callers explicitly marked `always_inline` or `noinline`.

> Have we consider the alternative of just disabling inlining when a function uses __builtin_return_address?

Is that what GCC does ([Looks like no](https://godbolt.org/z/8zKfGKrzq))?  Perhaps useful to match behavior of this compiler builtin, if so.  Or document ways in which we intentionally diverge.

> Is there any case in Linux where it's a correctness issue to use a caller's address?

257 call sites. hard to say

https://github.com/llvm/llvm-project/pull/82966


More information about the cfe-commits mailing list