
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.
22 lines
539 B
C++
22 lines
539 B
C++
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=ppc64-windows-msvc | FileCheck %s
|
|
|
|
// The purpose of this test is to see that we do something reasonable for
|
|
// architectures where we haven't checked what MSVC does.
|
|
|
|
struct A {
|
|
A() : a(42) {}
|
|
A(const A &o) : a(o.a) {}
|
|
~A() {}
|
|
int a;
|
|
};
|
|
|
|
struct B {
|
|
A foo(A o);
|
|
};
|
|
|
|
A B::foo(A x) {
|
|
return x;
|
|
}
|
|
|
|
// CHECK-LABEL: define{{.*}} void @"?foo@B@@QEAA?AUA@@U2@@Z"(ptr {{[^,]*}} %this, ptr dead_on_unwind noalias writable sret(%struct.A) align 4 %agg.result, ptr dead_on_return noundef %x)
|