xref: /aosp_15_r20/external/clang/test/CodeGen/2008-01-25-ByValReadNone.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // It could hit in @llvm.memcpy with "-triple x86_64-(mingw32|win32)".
4*67e74705SXin Li // CHECK-NOT: readonly
5*67e74705SXin Li // CHECK-NOT: readnone
6*67e74705SXin Li 
7*67e74705SXin Li // The struct being passed byval means that we cannot mark the
8*67e74705SXin Li // function readnone.  Readnone would allow stores to the arg to
9*67e74705SXin Li // be deleted in the caller.  We also don't allow readonly since
10*67e74705SXin Li // the callee might write to the byval parameter.  The inliner
11*67e74705SXin Li // would have to assume the worse and introduce an explicit
12*67e74705SXin Li // temporary when inlining such a function, which is costly for
13*67e74705SXin Li // the common case in which the byval argument is not written.
14*67e74705SXin Li struct S { int A[1000]; };
f(struct S x)15*67e74705SXin Li int __attribute__ ((const)) f(struct S x) { x.A[1] = 0; return x.A[0]; }
16*67e74705SXin Li int g(struct S x) __attribute__ ((pure));
h(struct S x)17*67e74705SXin Li int h(struct S x) { return g(x); }
18