This patch makes the dead_on_return parameter attribute optionally require a number
of bytes to be passed in to specify the number of bytes known to be dead
upon function return/unwind. This is aimed at enabling annotating the
this pointer in C++ destructors with dead_on_return in clang. We need
this to handle cases like the following:
```
struct X {
int n;
~X() {
this[n].n = 0;
}
};
void f() {
X xs[] = {42, -1};
}
```
Where we only certain that sizeof(X) bytes are dead upon return of ~X.
Otherwise DSE would be able to eliminate the store in ~X which would not
be correct.
This patch only does the wiring within IR. Future patches will make
clang emit correct sizing information and update DSE to only delete
stores to objects marked dead_on_return that are provably in bounds of
the number of bytes specified to be dead_on_return.
Reviewers: nikic, alinas, antoniofrighetto
Pull Request: https://github.com/llvm/llvm-project/pull/171712
20 lines
731 B
C
20 lines
731 B
C
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s \
|
|
// RUN: | FileCheck %s --check-prefix=CHECK-GNU64
|
|
// __float128 is unsupported on MSVC
|
|
|
|
__float128 fp128_ret(void) { return 0; }
|
|
// CHECK-GNU64: define dso_local <2 x i64> @fp128_ret()
|
|
|
|
__float128 fp128_args(__float128 a, __float128 b) { return a * b; }
|
|
// CHECK-GNU64: define dso_local <2 x i64> @fp128_args(ptr noundef dead_on_return %0, ptr noundef dead_on_return %1)
|
|
|
|
void fp128_vararg(int a, ...) {
|
|
// CHECK-GNU64-LABEL: define dso_local void @fp128_vararg
|
|
__builtin_va_list ap;
|
|
__builtin_va_start(ap, a);
|
|
__float128 i = __builtin_va_arg(ap, __float128);
|
|
// CHECK-GNU64: load ptr, ptr
|
|
// CHECK-GNU64: load fp128, ptr
|
|
__builtin_va_end(ap);
|
|
}
|