aboutsummaryrefslogtreecommitdiffstats
path: root/test/CFrontend
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-01-26 06:41:49 +0000
committerDuncan Sands <baldrick@free.fr>2008-01-26 06:41:49 +0000
commitdb1b10a0ce4284fe5c4cdcc26122ff85ca2bf798 (patch)
tree7f7dbbfbc07420afb181db8f9bf65a70e73282af /test/CFrontend
parent17e6f1aecb9037995f9bad30a288b1c8794fd86f (diff)
downloadexternal_llvm-db1b10a0ce4284fe5c4cdcc26122ff85ca2bf798.zip
external_llvm-db1b10a0ce4284fe5c4cdcc26122ff85ca2bf798.tar.gz
external_llvm-db1b10a0ce4284fe5c4cdcc26122ff85ca2bf798.tar.bz2
Create an explicit copy for byval parameters even
when inlining a readonly function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CFrontend')
-rw-r--r--test/CFrontend/2008-01-26-ReadOnlyByVal.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CFrontend/2008-01-26-ReadOnlyByVal.c b/test/CFrontend/2008-01-26-ReadOnlyByVal.c
new file mode 100644
index 0000000..cea6d1e
--- /dev/null
+++ b/test/CFrontend/2008-01-26-ReadOnlyByVal.c
@@ -0,0 +1,19 @@
+// RUN: %llvmgcc %s -S -O1 -o - | llvm-as | opt -std-compile-opts | llvm-dis | not grep add
+
+struct S { int A; int B; int C; int D; };
+
+int f(struct S x) __attribute__ ((const));
+
+static int __attribute__ ((const)) g(struct S x) {
+ x.A = x.B;
+ return f(x);
+}
+
+int h(void) {
+ struct S x;
+ int r;
+ x.A = 0;
+ x.B = 9;
+ r = g(x);
+ return r + x.A;
+}