
Let Clang emit `dead_on_return` attribute on pointer arguments that are passed indirectly, namely, large aggregates that the ABI mandates be passed by value; thus, the parameter is destroyed within the callee. Writes to such arguments are not observable by the caller after the callee returns. This should desirably enable further MemCpyOpt/DSE optimizations. Previous discussion: https://discourse.llvm.org/t/rfc-add-dead-on-return-attribute/86871.
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 dead_on_return noundef %0, ptr dead_on_return noundef %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);
|
|
}
|