summaryrefslogtreecommitdiffstats
path: root/llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c
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
commitc4dc3dc3a2b00c138484ce941914a77b429ae48a (patch)
treea9f24e6251f6c3164658d42f26a25e750cfb69b1 /llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c
parent8a88c3815a95f1f9de79efc4378f2e0f0b3fd900 (diff)
downloadbcm5719-llvm-c4dc3dc3a2b00c138484ce941914a77b429ae48a.tar.gz
bcm5719-llvm-c4dc3dc3a2b00c138484ce941914a77b429ae48a.zip
Create an explicit copy for byval parameters even
when inlining a readonly function. llvm-svn: 46393
Diffstat (limited to 'llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c')
-rw-r--r--llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c b/llvm/test/CFrontend/2008-01-26-ReadOnlyByVal.c
new file mode 100644
index 00000000000..cea6d1e1522
--- /dev/null
+++ b/llvm/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;
+}
OpenPOWER on IntegriCloud