
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.
21 lines
459 B
C++
21 lines
459 B
C++
// RUN: %clang_cc1 %s -triple=arm-unknown-linux-gnueabi -target-abi aapcs -emit-llvm -o - | FileCheck %s
|
|
|
|
class SMLoc {
|
|
const char *Ptr;
|
|
public:
|
|
SMLoc();
|
|
SMLoc(const SMLoc &RHS);
|
|
};
|
|
SMLoc foo(void *p);
|
|
void bar(void *x) {
|
|
foo(x);
|
|
}
|
|
void zed(SMLoc x);
|
|
void baz() {
|
|
SMLoc a;
|
|
zed(a);
|
|
}
|
|
|
|
// CHECK: declare void @_Z3fooPv(ptr dead_on_unwind writable sret(%class.SMLoc) align 4, ptr noundef)
|
|
// CHECK: declare void @_Z3zed5SMLoc(ptr dead_on_return noundef)
|