Add support for `__builtin_stack_address` builtin. The semantics match those of GCC's builtin with the same name. `__builtin_stack_address` returns the starting address of the stack region that may be used by called functions. It may or may not include the space used for on-stack arguments passed to a callee (See [GCC Bug/121013](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121013)). Fixes #82632.
23 lines
580 B
C++
23 lines
580 B
C++
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | llvm-cxxfilt | FileCheck %s
|
|
|
|
struct S {
|
|
void *a();
|
|
};
|
|
|
|
// CHECK-LABEL: @S::a()
|
|
// CHECK: call ptr @llvm.stackaddress.p0()
|
|
void *S::a() {
|
|
return __builtin_stack_address();
|
|
}
|
|
|
|
// CHECK-LABEL: define {{[^@]+}} @two()
|
|
// CHECK: call {{[^@]+}} @"two()::$_0::operator()() const"
|
|
//
|
|
// CHECK-LABEL: define {{[^@]+}} @"two()::$_0::operator()() const"
|
|
// CHECK: [[PTR:%.*]] = call ptr @llvm.stackaddress.p0()
|
|
// CHECK: ret ptr [[PTR]]
|
|
void *two() {
|
|
auto l = []() { return __builtin_stack_address(); };
|
|
return l();
|
|
}
|