summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2015-07-10 18:44:40 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2015-07-10 18:44:40 +0000
commit10bdb2b144cfb93d4d140e13efc66878a3f534f3 (patch)
treec1ccbf81c03f8d8d374633f68d0c155d31cb0a76 /clang/test/CodeGen
parent425b1a5106def460811aaf6a472750f2524b7134 (diff)
downloadbcm5719-llvm-10bdb2b144cfb93d4d140e13efc66878a3f534f3.tar.gz
bcm5719-llvm-10bdb2b144cfb93d4d140e13efc66878a3f534f3.zip
[inlineasm] Attach readonly and readnone to inline-asm instructions.
Previously, clang/llvm treated inline-asm instructions conservatively, choosing not to eliminate the instructions or hoisting them out of a loop even when it was safe to do so. This commit makes changes to attach a readonly or readnone attribute to an inline-asm instruction, which enables passes such as LICM and EarlyCSE to move or optimize away the instruction. rdar://problem/11358192 Differential Revision: http://reviews.llvm.org/D10546 llvm-svn: 241930
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r--clang/test/CodeGen/asm-attrs.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/CodeGen/asm-attrs.c b/clang/test/CodeGen/asm-attrs.c
new file mode 100644
index 00000000000..ae7287953e0
--- /dev/null
+++ b/clang/test/CodeGen/asm-attrs.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: call i32 asm "foo0", {{.*}} [[READNONE:#[0-9]+]]
+// CHECK: call i32 asm "foo1", {{.*}} [[READNONE]]
+// CHECK: call i32 asm "foo2", {{.*}} [[NOATTRS:#[0-9]+]]
+// CHECK: call i32 asm sideeffect "foo3", {{.*}} [[NOATTRS]]
+// CHECK: call i32 asm "foo4", {{.*}} [[READONLY:#[0-9]+]]
+// CHECK: call i32 asm "foo5", {{.*}} [[READONLY]]
+// CHECK: call i32 asm "foo6", {{.*}} [[NOATTRS]]
+// CHECK: call void asm sideeffect "foo7", {{.*}} [[NOATTRS]]
+// CHECK: call void asm "foo8", {{.*}} [[NOATTRS]]
+
+// CHECK: attributes [[READNONE]] = { nounwind readnone }
+// CHECK: attributes [[NOATTRS]] = { nounwind }
+// CHECK: attributes [[READONLY]] = { nounwind readonly }
+
+int g0, g1;
+
+struct S {
+ int i;
+} g2;
+
+void test_attrs(int a) {
+ __asm__ ("foo0" : "=r"(g1) : "r"(a));
+ __asm__ ("foo1" : "=r"(g1) : "r"(a) : "cc");
+ __asm__ ("foo2" : "=r"(g1) : "r"(a) : "memory");
+ __asm__ volatile("foo3" : "=r"(g1) : "r"(a));
+ __asm__ ("foo4" : "=r"(g1) : "r"(a), "m"(g0));
+ __asm__ ("foo5" : "=r"(g1) : "r"(a), "Q"(g0));
+ __asm__ ("foo6" : "=r"(g1), "=m"(g0) : "r"(a));
+ __asm__ ("foo7" : : "r"(a));
+ __asm__ ("foo8" : "=r"(g2) : "r"(a));
+}
OpenPOWER on IntegriCloud