[clang] [Clang] Refactor the tests to be more uniform (PR #191944)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 13:53:09 PDT 2026
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/191944
>From 93c70146ed1c31cf0d1bf56fcfa288f25a152385 Mon Sep 17 00:00:00 2001
From: Bill Wendling <morbo at google.com>
Date: Mon, 13 Apr 2026 21:59:09 -0700
Subject: [PATCH 1/4] [Clang] Expand test to include x86_64 and i386 both -O0
and -O2
---
clang/test/CodeGen/asm.c | 657 +++++++++++++++++++++++++++++++--------
1 file changed, 533 insertions(+), 124 deletions(-)
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index 9687c993e6464..8c1437f91d603 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -1,103 +1,265 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
-
-// PR10415
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O0 %s -o - | FileCheck %s -check-prefix=X86_64-O0
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O2 %s -o - | FileCheck %s -check-prefix=X86_64-O2
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -O0 %s -o - | FileCheck %s -check-prefix=I386-O0
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -O2 %s -o - | FileCheck %s -check-prefix=I386-O2
+
+// PR10415:
+//
+// X86_64-O0: module asm "foo1"
+// X86_64-O0-NEXT: module asm "foo2"
+// X86_64-O0-NEXT: module asm "foo3"
+//
+// X86_64-O2: module asm "foo1"
+// X86_64-O2-NEXT: module asm "foo2"
+// X86_64-O2-NEXT: module asm "foo3"
+//
+// I386-O0: module asm "foo1"
+// I386-O0-NEXT: module asm "foo2"
+// I386-O0-NEXT: module asm "foo3"
+//
+// I386-O2: module asm "foo1"
+// I386-O2-NEXT: module asm "foo2"
+// I386-O2-NEXT: module asm "foo3"
__asm__ ("foo1");
__asm__ ("foo2");
__asm__ ("foo3");
-// CHECK: module asm "foo1"
-// CHECK-NEXT: module asm "foo2"
-// CHECK-NEXT: module asm "foo3"
void t1(int len) {
- __asm__ volatile("" : "=&r"(len), "+&r"(len));
+ // X86_64-O0-LABEL: define{{.*}} void @t1
+ // X86_64-O0: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (i32 [[T1:%[.a-z0-9]+]])
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t1
+ // X86_64-O2: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (i32 [[T1:%[.a-z0-9]+]])
+ //
+ // I386-O0-LABEL: define{{.*}} void @t1
+ // I386-O0: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (i32 [[T1:%[.a-z0-9]+]])
+ //
+ // I386-O2-LABEL: define{{.*}} void @t1
+ // I386-O2: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (i32 [[T1:%[.a-z0-9]+]])
+ __asm__ volatile ("" : "=&r" (len), "+&r" (len));
}
void t2(unsigned long long t) {
- __asm__ volatile("" : "+m"(t));
+ // X86_64-O0-LABEL: define{{.*}} void @t2
+ // X86_64-O0: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (ptr elementtype(i64) [[T2:%[a-z0-9.]+]], ptr elementtype(i64) [[T2]])
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t2
+ // X86_64-O2: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (ptr nonnull elementtype(i64) [[T2:%[.a-z0-9]+]], ptr nonnull elementtype(i64) [[T2]])
+ //
+ // I386-O0-LABEL: define{{.*}} void @t2
+ // I386-O0: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (ptr elementtype(i64) [[T2:%[.0-9a-z]+]], ptr elementtype(i64) [[T2]])
+ //
+ // I386-O2-LABEL: define{{.*}} void @t2
+ // I386-O2: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (ptr nonnull elementtype(i64) [[T2:%[.a-z0-9]+]], ptr nonnull elementtype(i64) [[T2]])
+ __asm__ volatile ("" : "+m" (t));
}
void t3(unsigned char *src, unsigned long long temp) {
- __asm__ volatile("" : "+m"(temp), "+r"(src));
+ // X86_64-O0-LABEL: define{{.*}} void @t3
+ // X86_64-O0: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (ptr elementtype(i64) [[T3:%[a-z0-9.]+]], ptr elementtype(i64) [[T3]], ptr %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t3
+ // X86_64-O2: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (ptr nonnull elementtype(i64) [[T3:%[a-z0-9.]+]], ptr nonnull elementtype(i64) [[T3]], ptr %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t3
+ // I386-O0: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (ptr elementtype(i64) [[T3:%[a-z0-9.]+]], ptr elementtype(i64) [[T3]], ptr %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t3
+ // I386-O2: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (ptr nonnull elementtype(i64) [[T3:%[a-z0-9.]+]], ptr nonnull elementtype(i64) [[T3]], ptr %{{.*}})
+ __asm__ volatile ("" : "+m" (temp), "+r" (src));
}
void t4(void) {
+ // X86_64-O0-LABEL: define{{.*}} void @t4
+ // X86_64-O0: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (ptr elementtype(i64) %{{.*}}, ptr elementtype(%struct.reg) %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t4
+ // X86_64-O2: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (ptr nonnull elementtype(i64) %{{.*}}, ptr nonnull elementtype(%struct.reg) %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t4
+ // I386-O0: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (ptr elementtype(i64) %{{.*}}, ptr elementtype(%struct.reg) %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t4
+ // I386-O2: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (ptr nonnull elementtype(i64) %{{.*}}, ptr nonnull elementtype(%struct.reg) %{{.*}})
unsigned long long a;
struct reg { unsigned long long a, b; } b;
- __asm__ volatile ("":: "m"(a), "m"(b));
+ __asm__ volatile ("":: "m" (a), "m" (b));
}
// PR3417
void t5(int i) {
- asm("nop" : "=r"(i) : "0"(t5));
+ // X86_64-O0-LABEL: define{{.*}} void @t5
+ // X86_64-O0: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t5
+ // X86_64-O2: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @t5)
+ //
+ // I386-O0-LABEL: define{{.*}} void @t5
+ // I386-O0: call i32 asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
+ //
+ // I386-O2-LABEL: define{{.*}} void @t5
+ // I386-O2: call i32 asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @t5)
+ asm ("nop" : "=r" (i) : "0" (t5));
}
// PR3641
void t6(void) {
- __asm__ volatile("" : : "i" (t6));
+ // X86_64-O0-LABEL: define{{.*}} void @t6
+ // X86_64-O0: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr @{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t6
+ // X86_64-O2: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t6
+ // I386-O0: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr @{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t6
+ // I386-O2: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @{{.*}})
+ __asm__ volatile ("" : : "i" (t6));
}
void t7(int a) {
- __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
- // CHECK: @t7(i32
- // CHECK: T7 NAMED: $1
+ // X86_64-O0-LABEL: define{{.*}} void @t7
+ // X86_64-O0: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (i32 4, i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t7
+ // X86_64-O2: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (i32 4, i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t7
+ // I386-O0: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (i32 4, i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t7
+ // I386-O2: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (i32 4, i32 %{{.*}})
+ __asm__ volatile ("T7 NAMED: %[input]" : "+r" (a): [input] "i" (4));
}
void t8(void) {
- __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
- // CHECK: @t8()
- // CHECK: T8 NAMED MODIFIER: ${0:c}
+ // X86_64-O0-LABEL: define{{.*}} void @t8
+ // X86_64-O0: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t8
+ // X86_64-O2: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
+ //
+ // I386-O0-LABEL: define{{.*}} void @t8
+ // I386-O0: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
+ //
+ // I386-O2-LABEL: define{{.*}} void @t8
+ // I386-O2: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
+ __asm__ volatile ("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
}
// PR3682
unsigned t9(unsigned int a) {
- asm("bswap %0 %1" : "+r" (a));
+ // X86_64-O0-LABEL: define{{.*}} i32 @t9
+ // X86_64-O0: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t9
+ // X86_64-O2: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t9
+ // I386-O0: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t9
+ // I386-O2: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ asm ("bswap %0 %1" : "+r" (a));
return a;
}
// PR3908
void t10(int r) {
- __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
-
-// CHECK: @t10(
-// CHECK:PR3908 $1 $3 $2 $0
+ // X86_64-O0-LABEL: define{{.*}} void @t10
+ // X86_64-O0: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t10
+ // X86_64-O2: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t10
+ // I386-O0: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t10
+ // I386-O2: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
+ __asm__ ("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
}
// PR3373
unsigned t11(signed char input) {
+ // X86_64-O0-LABEL: define{{.*}} i32 @t11
+ // X86_64-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t11
+ // X86_64-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t11
+ // I386-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t11
+ // I386-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned output;
- __asm__("xyz"
- : "=a" (output)
- : "0" (input));
+
+ __asm__ ("xyz" : "=a" (output) : "0" (input));
return output;
}
// PR3373
unsigned char t12(unsigned input) {
+ // X86_64-O0-LABEL: define{{.*}} i8 @t12
+ // X86_64-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i8 @t12
+ // X86_64-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i8 @t12
+ // I386-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i8 @t12
+ // I386-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned char output;
- __asm__("xyz"
- : "=a" (output)
- : "0" (input));
+
+ __asm__ ("xyz" : "=a" (output) : "0" (input));
return output;
}
unsigned char t13(unsigned input) {
+ // X86_64-O0-LABEL: define{{.*}} i8 @t13
+ // X86_64-O0: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i8 @t13
+ // X86_64-O2: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i8 @t13
+ // I386-O0: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i8 @t13
+ // I386-O2: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned char output;
- __asm__("xyz %1"
- : "=a" (output)
- : "0" (input));
- return output;
-}
-
-struct large {
- int x[1000];
-};
-unsigned long t15(int x, struct large *P) {
- __asm__("xyz "
- : "=r" (x)
- : "m" (*P), "0" (x));
- return x;
+ __asm__ ("xyz %1" : "=a" (output) : "0" (input));
+ return output;
}
// bitfield destination of an asm.
@@ -106,168 +268,398 @@ struct S {
};
void t14(struct S *P) {
- __asm__("abc %0" : "=r"(P->a) );
+ // X86_64-O0-LABEL: define{{.*}} void @t14
+ // X86_64-O0: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t14
+ // X86_64-O2: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
+ //
+ // I386-O0-LABEL: define{{.*}} void @t14
+ // I386-O0: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
+ //
+ // I386-O2-LABEL: define{{.*}} void @t14
+ // I386-O2: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
+ __asm__ ("abc %0" : "=r" (P->a));
+}
+
+struct large {
+ int x[1000];
+};
+
+unsigned long t15(int x, struct large *P) {
+ // X86_64-O0-LABEL: define{{.*}} i64 @t15
+ // X86_64-O0: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i64 @t15
+ // X86_64-O2: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (ptr elementtype(%struct.large) %P, i32 %x)
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t15
+ // I386-O0: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t15
+ // I386-O2: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (ptr elementtype(%struct.large) %P, i32 %x)
+ __asm__ ("xyz " : "=r" (x) : "m" (*P), "0" (x));
+ return x;
}
// PR4938
int t16(void) {
- int a,b;
- asm ( "nop;"
- :"=%c" (a)
- : "r" (b)
- );
+ // X86_64-O0-LABEL: define{{.*}} i32 @t16
+ // X86_64-O0: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t16
+ // X86_64-O2: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 undef)
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t16
+ // I386-O0: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t16
+ // I386-O2: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 undef)
+ int a, b;
+
+ asm ("nop;" :"=%c" (a) : "r" (b));
return 0;
}
// PR6475
void t17(void) {
+ // X86_64-O0-LABEL: define{{.*}} void @t17
+ // X86_64-O0: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %{{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t17
+ // X86_64-O2: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32) %{{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t17
+ // I386-O0: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %{{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t17
+ // I386-O2: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32) %{{.*}})
int i;
- __asm__ ( "nop": "=m"(i));
-// CHECK: @t17()
-// CHECK: call void asm "nop", "=*m,
+ __asm__ ("nop": "=m" (i));
}
int t18(unsigned data) {
+ // X86_64-O0-LABEL: define{{.*}} i32 @t18
+ // X86_64-O0: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
+ // X86_64-O0-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // X86_64-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
+ // X86_64-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t18
+ // X86_64-O2: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
+ // X86_64-O2-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // X86_64-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
+ // X86_64-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t18
+ // I386-O0: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
+ // I386-O0-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // I386-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
+ // I386-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t18
+ // I386-O2: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
+ // I386-O2-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // I386-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
+ // I386-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
int a, b;
- asm("xyz" :"=a"(a), "=d"(b) : "a"(data));
+ asm ("xyz" : "=a" (a), "=d" (b) : "a" (data));
return a + b;
-// CHECK: t18(i32
-// CHECK: = call {{.*}}asm "xyz"
-// CHECK-NEXT: extractvalue
-// CHECK-NEXT: extractvalue
}
// PR6780
int t19(unsigned data) {
+ // X86_64-O0-LABEL: define{{.*}} i32 @t19
+ // X86_64-O0: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t19
+ // X86_64-O2: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t19
+ // I386-O0: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t19
+ // I386-O2: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
int a, b;
- asm("x{abc|def|ghi}z" :"=r"(a): "r"(data));
+ asm ("x{abc|def|ghi}z" : "=r" (a) : "r" (data));
return a + b;
- // CHECK: t19(i32
- // CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z"
}
// PR6845 - Mismatching source/dest fp types.
double t20(double x) {
+ // X86_64-O0-LABEL: define{{.*}} double @t20
+ // X86_64-O0: fpext double {{.*}} to x86_fp80
+ // X86_64-O0-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // X86_64-O0: fptrunc x86_fp80 {{.*}} to double
+ //
+ // X86_64-O2-LABEL: define{{.*}} double @t20
+ // X86_64-O2: fpext double {{.*}} to x86_fp80
+ // X86_64-O2-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // X86_64-O2-NEXT: fptrunc x86_fp80 {{.*}} to double
+ //
+ // I386-O0-LABEL: define{{.*}} double @t20
+ // I386-O0: fpext double {{.*}} to x86_fp80
+ // I386-O0-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // I386-O0: fptrunc x86_fp80 {{.*}} to double
+ //
+ // I386-O2-LABEL: define{{.*}} double @t20
+ // I386-O2: fpext double {{.*}} to x86_fp80
+ // I386-O2-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // I386-O2: fptrunc x86_fp80 {{.*}} to double
register long double result;
+
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
return result;
-
- // CHECK: @t20
- // CHECK: fpext double {{.*}} to x86_fp80
- // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint"
- // CHECK: fptrunc x86_fp80 {{.*}} to double
}
float t21(long double x) {
+ // X86_64-O0-LABEL: define{{.*}} float @t21
+ // X86_64-O0: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // X86_64-O0-NEXT: fptrunc x86_fp80 {{.*}} to float
+ //
+ // X86_64-O2-LABEL: define{{.*}} float @t21
+ // X86_64-O2: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // X86_64-O2-NEXT: fptrunc x86_fp80 {{.*}} to float
+ //
+ // I386-O0-LABEL: define{{.*}} float @t21
+ // I386-O0: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // I386-O0-NEXT: fptrunc x86_fp80 {{.*}} to float
+ //
+ // I386-O2-LABEL: define{{.*}} float @t21
+ // I386-O2: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // I386-O2-NEXT: fptrunc x86_fp80 {{.*}} to float
register float result;
+
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
return result;
- // CHECK: @t21
- // CHECK: call x86_fp80 asm sideeffect "frndint"
- // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float
}
// accept 'l' constraint
unsigned char t22(unsigned char a, unsigned char b) {
+ // X86_64-O0-LABEL: define{{.*}} i8 @t22
+ // X86_64-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i8 @t22
+ // X86_64-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i8 @t22
+ // I386-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i8 @t22
+ // I386-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (i32 {{.*}}, i32 {{.*}})
unsigned int la = a;
unsigned int lb = b;
unsigned int bigres;
unsigned char res;
- __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) :
- "edx", "cc");
+
+ __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) : "edx", "cc");
res = bigres;
return res;
}
// accept 'l' constraint
unsigned char t23(unsigned char a, unsigned char b) {
+ // X86_64-O0-LABEL: define{{.*}} i8 @t23
+ // X86_64-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} i8 @t23
+ // X86_64-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} i8 @t23
+ // I386-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (i32 {{.*}}, i32 {{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} i8 @t23
+ // I386-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (i32 {{.*}}, i32 {{.*}})
unsigned int la = a;
unsigned int lb = b;
unsigned char res;
- __asm__ ("0:\n1:\n" : [res] "=la"(res) : [la] "0"(la), [lb] "c"(lb) :
- "edx", "cc");
+
+ __asm__ ("0:\n1:\n" : [res] "=la" (res) : [la] "0" (la), [lb] "c" (lb) : "edx", "cc");
return res;
}
void *t24(char c) {
+ // X86_64-O0-LABEL: define{{.*}} ptr @t24
+ // X86_64-O0: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
+ // X86_64-O0-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
+ //
+ // X86_64-O2-LABEL: define{{.*}} ptr @t24
+ // X86_64-O2: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
+ // X86_64-O2-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
+ //
+ // I386-O0-LABEL: define{{.*}} ptr @t24
+ // I386-O0: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i32
+ // I386-O0-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 [[C]])
+ //
+ // I386-O2-LABEL: define{{.*}} ptr @t24
+ // I386-O2: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i32
+ // I386-O2-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 [[C]])
void *addr;
- // CHECK: @t24
- // CHECK: zext i8 {{.*}} to i32
- // CHECK-NEXT: call ptr asm "foobar"
+
__asm__ ("foobar" : "=a" (addr) : "0" (c));
return addr;
}
// PR10299 - fpsr, fpcr
-void t25(void)
-{
- __asm__ __volatile__( \
- "finit" \
- : \
- : \
- :"st","st(1)","st(2)","st(3)", \
- "st(4)","st(5)","st(6)","st(7)", \
- "fpsr","fpcr" \
- );
+void t25(void) {
+ // X86_64-O0-LABEL: define{{.*}} void @t25
+ // X86_64-O0: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t25
+ // X86_64-O2: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
+ //
+ // I386-O0-LABEL: define{{.*}} void @t25
+ // I386-O0: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
+ //
+ // I386-O2-LABEL: define{{.*}} void @t25
+ // I386-O2: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
+ __asm__ __volatile__ ("finit" : : :
+ "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)",
+ "st(6)", "st(7)", "fpsr", "fpcr");
}
// AVX registers
typedef long long __m256i __attribute__((__vector_size__(32)));
+
void t26 (__m256i *p) {
- __asm__ volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0");
+ // X86_64-O0-LABEL: define{{.*}} void @t26
+ // X86_64-O0: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t26
+ // X86_64-O2: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} void @t26
+ // I386-O0: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} void @t26
+ // I386-O2: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
+ __asm__ volatile ("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0");
}
// Check to make sure the inline asm non-standard dialect attribute _not_ is
// emitted.
void t27(void) {
- asm volatile("nop");
-// CHECK: @t27
-// CHECK: call void asm sideeffect "nop"
-// CHECK-NOT: ia_nsdialect
-// CHECK: ret void
+ // X86_64-O0-LABEL: define{{.*}} void @t27
+ // X86_64-O0: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+ // X86_64-O0-NOT: ia_nsdialect
+ // X86_64-O0: ret void
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t27
+ // X86_64-O2: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+ // X86_64-O2-NOT: ia_nsdialect
+ // X86_64-O2: ret void
+ //
+ // I386-O0-LABEL: define{{.*}} void @t27
+ // I386-O0: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+ // I386-O0-NOT: ia_nsdialect
+ // I386-O0: ret void
+ //
+ // I386-O2-LABEL: define{{.*}} void @t27
+ // I386-O2: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+ // I386-O2-NOT: ia_nsdialect
+ // I386-O2: ret void
+ asm volatile ("nop");
}
// Check handling of '*' and '#' constraint modifiers.
-void t28(void)
-{
+void t28(void) {
+ // X86_64-O0-LABEL: define{{.*}} void @t28
+ // X86_64-O0: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t28
+ // X86_64-O2: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
+ //
+ // I386-O0-LABEL: define{{.*}} void @t28
+ // I386-O0: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
+ //
+ // I386-O2-LABEL: define{{.*}} void @t28
+ // I386-O2: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
asm volatile ("/* %0 */" : : "i#*X,*r" (1));
-// CHECK: @t28
-// CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
}
static unsigned t29_var[1];
void t29(void) {
- asm volatile("movl %%eax, %0"
- :
- : "m"(t29_var));
- // CHECK: @t29
- // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1 x i32]) @t29_var)
+ // X86_64-O0-LABEL: define{{.*}} void @t29
+ // X86_64-O0: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-SAME: (ptr elementtype([1 x i32]) @t29_var)
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t29
+ // X86_64-O2: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O2-SAME: (ptr nonnull elementtype([1 x i32]) @t29_var)
+ //
+ // I386-O0-LABEL: define{{.*}} void @t29
+ // I386-O0: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O0-SAME: (ptr elementtype([1 x i32]) @t29_var)
+ //
+ // I386-O2-LABEL: define{{.*}} void @t29
+ // I386-O2: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
+ // I386-O2-SAME: (ptr nonnull elementtype([1 x i32]) @t29_var)
+ asm volatile ("movl %%eax, %0" : : "m" (t29_var));
}
void t30(int len) {
- __asm__ volatile(""
- : "+&&rm"(len));
- // CHECK: @t30
- // CHECK: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ // X86_64-O0-LABEL: define{{.*}} void @t30
+ // X86_64-O0: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t30
+ // X86_64-O2: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O0-LABEL: define{{.*}} void @t30
+ // I386-O0: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O2-LABEL: define{{.*}} void @t30
+ // I386-O2: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile ("" : "+&&rm" (len));
}
void t31(int len) {
- __asm__ volatile(""
- : "+%%rm"(len), "+rm"(len));
- // CHECK: @t31
- // CHECK: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
-}
-
-// CHECK: @t32
-int t32(int cond)
-{
- asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop);
- // CHECK: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 %0) #1
- // CHECK-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
+ // X86_64-O0-LABEL: define{{.*}} void @t31
+ // X86_64-O0: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t31
+ // X86_64-O2: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O0-LABEL: define{{.*}} void @t31
+ // I386-O0: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O2-LABEL: define{{.*}} void @t31
+ // I386-O2: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile("" : "+%%rm" (len), "+rm" (len));
+}
+
+int t32(int cond) {
+ // X86_64-O0-LABEL: define{{.*}} i32 @t32
+ // X86_64-O0: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // X86_64-O0-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
+ //
+ // X86_64-O2-LABEL: define{{.*}} i32 @t32
+ // X86_64-O2: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // X86_64-O2-NEXT: to label %return [label %label_true, label %return]
+ //
+ // I386-O0-LABEL: define{{.*}} i32 @t32
+ // I386-O0: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // I386-O0-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
+ //
+ // I386-O2-LABEL: define{{.*}} i32 @t32
+ // I386-O2: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // I386-O2-NEXT: to label %return [label %label_true, label %return]
+ asm goto ("testl %0, %0; jne %l1;" : : "r" (cond) : : label_true, loop);
return 0;
loop:
return 0;
@@ -275,18 +667,35 @@ int t32(int cond)
return 1;
}
-void *t33(void *ptr)
-{
+void *t33(void *ptr) {
+ // X86_64-O0-LABEL: define{{.*}} ptr @t33
+ // X86_64-O0: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
+ //
+ // X86_64-O2-LABEL: define{{.*}} ptr @t33
+ // X86_64-O2: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
+ //
+ // I386-O0-LABEL: define{{.*}} ptr @t33
+ // I386-O0: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
+ //
+ // I386-O2-LABEL: define{{.*}} ptr @t33
+ // I386-O2: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
void *ret;
+
asm ("lea %1, %0" : "=r" (ret) : "p" (ptr));
return ret;
-
- // CHECK: @t33
- // CHECK: %1 = call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr %0)
}
void t34(void) {
- __asm__ volatile("T34 CC NAMED MODIFIER: %cc[input]" :: [input] "i" (4));
- // CHECK: @t34()
- // CHECK: T34 CC NAMED MODIFIER: ${0:c}
+ // X86_64-O0-LABEL: define{{.*}} void @t34
+ // X86_64-O0: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
+ //
+ // X86_64-O2-LABEL: define{{.*}} void @t34
+ // X86_64-O2: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O0-LABEL: define{{.*}} void @t34
+ // I386-O0: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
+ //
+ // I386-O2-LABEL: define{{.*}} void @t34
+ // I386-O2: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile ("T34 CC NAMED MODIFIER: %cc[input]" : : [input] "i" (4));
}
>From 6f3a041aabe49b64f839d64d534d7300d3ac2341 Mon Sep 17 00:00:00 2001
From: Bill Wendling <morbo at google.com>
Date: Tue, 14 Apr 2026 13:37:39 -0700
Subject: [PATCH 2/4] Remove duplicate testing.
---
clang/test/CodeGen/asm.c | 663 +++++++++------------------------------
1 file changed, 146 insertions(+), 517 deletions(-)
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index 8c1437f91d603..8f01bd6f4a5ed 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -1,224 +1,84 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O0 %s -o - | FileCheck %s -check-prefix=X86_64-O0
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O2 %s -o - | FileCheck %s -check-prefix=X86_64-O2
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -O0 %s -o - | FileCheck %s -check-prefix=I386-O0
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -O2 %s -o - | FileCheck %s -check-prefix=I386-O2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
// PR10415:
//
-// X86_64-O0: module asm "foo1"
-// X86_64-O0-NEXT: module asm "foo2"
-// X86_64-O0-NEXT: module asm "foo3"
-//
-// X86_64-O2: module asm "foo1"
-// X86_64-O2-NEXT: module asm "foo2"
-// X86_64-O2-NEXT: module asm "foo3"
-//
-// I386-O0: module asm "foo1"
-// I386-O0-NEXT: module asm "foo2"
-// I386-O0-NEXT: module asm "foo3"
-//
-// I386-O2: module asm "foo1"
-// I386-O2-NEXT: module asm "foo2"
-// I386-O2-NEXT: module asm "foo3"
+// CHECK: module asm "foo1"
+// CHECK-NEXT: module asm "foo2"
+// CHECK-NEXT: module asm "foo3"
__asm__ ("foo1");
__asm__ ("foo2");
__asm__ ("foo3");
void t1(int len) {
- // X86_64-O0-LABEL: define{{.*}} void @t1
- // X86_64-O0: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (i32 [[T1:%[.a-z0-9]+]])
- //
- // X86_64-O2-LABEL: define{{.*}} void @t1
- // X86_64-O2: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (i32 [[T1:%[.a-z0-9]+]])
- //
- // I386-O0-LABEL: define{{.*}} void @t1
- // I386-O0: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (i32 [[T1:%[.a-z0-9]+]])
- //
- // I386-O2-LABEL: define{{.*}} void @t1
- // I386-O2: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (i32 [[T1:%[.a-z0-9]+]])
+ // CHECK-LABEL: define{{.*}} void @t1
+ // CHECK: call { i32, i32 } asm sideeffect "", "=&r,=&r,1,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (i32 [[T1:%[.a-z0-9]+]])
__asm__ volatile ("" : "=&r" (len), "+&r" (len));
}
void t2(unsigned long long t) {
- // X86_64-O0-LABEL: define{{.*}} void @t2
- // X86_64-O0: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (ptr elementtype(i64) [[T2:%[a-z0-9.]+]], ptr elementtype(i64) [[T2]])
- //
- // X86_64-O2-LABEL: define{{.*}} void @t2
- // X86_64-O2: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (ptr nonnull elementtype(i64) [[T2:%[.a-z0-9]+]], ptr nonnull elementtype(i64) [[T2]])
- //
- // I386-O0-LABEL: define{{.*}} void @t2
- // I386-O0: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (ptr elementtype(i64) [[T2:%[.0-9a-z]+]], ptr elementtype(i64) [[T2]])
- //
- // I386-O2-LABEL: define{{.*}} void @t2
- // I386-O2: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (ptr nonnull elementtype(i64) [[T2:%[.a-z0-9]+]], ptr nonnull elementtype(i64) [[T2]])
+ // CHECK-LABEL: define{{.*}} void @t2
+ // CHECK: call void asm sideeffect "", "=*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (ptr elementtype(i64) [[T2:%[a-z0-9.]+]], ptr elementtype(i64) [[T2]])
__asm__ volatile ("" : "+m" (t));
}
void t3(unsigned char *src, unsigned long long temp) {
- // X86_64-O0-LABEL: define{{.*}} void @t3
- // X86_64-O0: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (ptr elementtype(i64) [[T3:%[a-z0-9.]+]], ptr elementtype(i64) [[T3]], ptr %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t3
- // X86_64-O2: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (ptr nonnull elementtype(i64) [[T3:%[a-z0-9.]+]], ptr nonnull elementtype(i64) [[T3]], ptr %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t3
- // I386-O0: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (ptr elementtype(i64) [[T3:%[a-z0-9.]+]], ptr elementtype(i64) [[T3]], ptr %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t3
- // I386-O2: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (ptr nonnull elementtype(i64) [[T3:%[a-z0-9.]+]], ptr nonnull elementtype(i64) [[T3]], ptr %{{.*}})
+ // CHECK-LABEL: define{{.*}} void @t3
+ // CHECK: call ptr asm sideeffect "", "=*m,=r,*m,1,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (ptr elementtype(i64) [[T3:%[a-z0-9.]+]], ptr elementtype(i64) [[T3]], ptr %{{.*}})
__asm__ volatile ("" : "+m" (temp), "+r" (src));
}
void t4(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t4
- // X86_64-O0: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (ptr elementtype(i64) %{{.*}}, ptr elementtype(%struct.reg) %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t4
- // X86_64-O2: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (ptr nonnull elementtype(i64) %{{.*}}, ptr nonnull elementtype(%struct.reg) %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t4
- // I386-O0: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (ptr elementtype(i64) %{{.*}}, ptr elementtype(%struct.reg) %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t4
- // I386-O2: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (ptr nonnull elementtype(i64) %{{.*}}, ptr nonnull elementtype(%struct.reg) %{{.*}})
+ // CHECK-LABEL: define{{.*}} void @t4
+ // CHECK: call void asm sideeffect "", "*m,*m,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (ptr elementtype(i64) %{{.*}}, ptr elementtype(%struct.reg) %{{.*}})
unsigned long long a;
struct reg { unsigned long long a, b; } b;
- __asm__ volatile ("":: "m" (a), "m" (b));
+ __asm__ volatile ("" : : "m" (a), "m" (b));
}
// PR3417
void t5(int i) {
- // X86_64-O0-LABEL: define{{.*}} void @t5
- // X86_64-O0: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
- //
- // X86_64-O2-LABEL: define{{.*}} void @t5
- // X86_64-O2: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @t5)
- //
- // I386-O0-LABEL: define{{.*}} void @t5
- // I386-O0: call i32 asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
- //
- // I386-O2-LABEL: define{{.*}} void @t5
- // I386-O2: call i32 asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @t5)
+ // CHECK-LABEL: define{{.*}} void @t5
+ // CHECK: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
asm ("nop" : "=r" (i) : "0" (t5));
}
// PR3641
void t6(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t6
- // X86_64-O0: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr @{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t6
- // X86_64-O2: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t6
- // I386-O0: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr @{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t6
- // I386-O2: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @{{.*}})
+ // CHECK-LABEL: define{{.*}} void @t6
+ // CHECK: call void asm sideeffect "", "i,~{dirflag},~{fpsr},~{flags}"(ptr @{{.*}})
__asm__ volatile ("" : : "i" (t6));
}
void t7(int a) {
- // X86_64-O0-LABEL: define{{.*}} void @t7
- // X86_64-O0: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (i32 4, i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t7
- // X86_64-O2: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (i32 4, i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t7
- // I386-O0: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (i32 4, i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t7
- // I386-O2: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (i32 4, i32 %{{.*}})
+ // CHECK-LABEL: define{{.*}} void @t7
+ // CHECK: call i32 asm sideeffect "T7 NAMED: $1", "=r,i,0,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (i32 4, i32 %{{.*}})
__asm__ volatile ("T7 NAMED: %[input]" : "+r" (a): [input] "i" (4));
}
void t8(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t8
- // X86_64-O0: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
- //
- // X86_64-O2-LABEL: define{{.*}} void @t8
- // X86_64-O2: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
- //
- // I386-O0-LABEL: define{{.*}} void @t8
- // I386-O0: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
- //
- // I386-O2-LABEL: define{{.*}} void @t8
- // I386-O2: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
- __asm__ volatile ("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
+ // CHECK-LABEL: define{{.*}} void @t8
+ // CHECK: call void asm sideeffect "T8 NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"(i32 4)
+ __asm__ volatile ("T8 NAMED MODIFIER: %c[input]" : : [input] "i" (4));
}
// PR3682
unsigned t9(unsigned int a) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t9
- // X86_64-O0: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t9
- // X86_64-O2: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i32 @t9
- // I386-O0: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i32 @t9
- // I386-O2: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+ // CHECK-LABEL: define{{.*}} i32 @t9
+ // CHECK: call i32 asm "bswap $0 $1", "=r,0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
asm ("bswap %0 %1" : "+r" (a));
return a;
}
-// PR3908
-void t10(int r) {
- // X86_64-O0-LABEL: define{{.*}} void @t10
- // X86_64-O0: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t10
- // X86_64-O2: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t10
- // I386-O0: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t10
- // I386-O2: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
- __asm__ ("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
-}
-
// PR3373
-unsigned t11(signed char input) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t11
- // X86_64-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t11
- // X86_64-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i32 @t11
- // I386-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i32 @t11
- // I386-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+unsigned t10(signed char input) {
+ // CHECK-LABEL: define{{.*}} i32 @t10
+ // CHECK: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned output;
__asm__ ("xyz" : "=a" (output) : "0" (input));
@@ -226,36 +86,18 @@ unsigned t11(signed char input) {
}
// PR3373
-unsigned char t12(unsigned input) {
- // X86_64-O0-LABEL: define{{.*}} i8 @t12
- // X86_64-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i8 @t12
- // X86_64-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i8 @t12
- // I386-O0: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i8 @t12
- // I386-O2: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+unsigned char t11(unsigned input) {
+ // CHECK-LABEL: define{{.*}} i8 @t11
+ // CHECK: call i32 asm "xyz", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned char output;
__asm__ ("xyz" : "=a" (output) : "0" (input));
return output;
}
-unsigned char t13(unsigned input) {
- // X86_64-O0-LABEL: define{{.*}} i8 @t13
- // X86_64-O0: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i8 @t13
- // X86_64-O2: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i8 @t13
- // I386-O0: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i8 @t13
- // I386-O2: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+unsigned char t12(unsigned input) {
+ // CHECK-LABEL: define{{.*}} i8 @t12
+ // CHECK: call i32 asm "xyz $1", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
unsigned char output;
__asm__ ("xyz %1" : "=a" (output) : "0" (input));
@@ -267,18 +109,9 @@ struct S {
int a : 4;
};
-void t14(struct S *P) {
- // X86_64-O0-LABEL: define{{.*}} void @t14
- // X86_64-O0: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
- //
- // X86_64-O2-LABEL: define{{.*}} void @t14
- // X86_64-O2: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
- //
- // I386-O0-LABEL: define{{.*}} void @t14
- // I386-O0: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
- //
- // I386-O2-LABEL: define{{.*}} void @t14
- // I386-O2: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
+void t13(struct S *P) {
+ // CHECK-LABEL: define{{.*}} void @t13
+ // CHECK: call i32 asm "abc $0", "=r,~{dirflag},~{fpsr},~{flags}"()
__asm__ ("abc %0" : "=r" (P->a));
}
@@ -286,39 +119,18 @@ struct large {
int x[1000];
};
-unsigned long t15(int x, struct large *P) {
- // X86_64-O0-LABEL: define{{.*}} i64 @t15
- // X86_64-O0: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i64 @t15
- // X86_64-O2: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (ptr elementtype(%struct.large) %P, i32 %x)
- //
- // I386-O0-LABEL: define{{.*}} i32 @t15
- // I386-O0: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i32 @t15
- // I386-O2: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (ptr elementtype(%struct.large) %P, i32 %x)
+unsigned long t14(int x, struct large *P) {
+ // CHECK-LABEL: define{{.*}} i64 @t14
+ // CHECK: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
__asm__ ("xyz " : "=r" (x) : "m" (*P), "0" (x));
return x;
}
// PR4938
-int t16(void) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t16
- // X86_64-O0: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t16
- // X86_64-O2: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 undef)
- //
- // I386-O0-LABEL: define{{.*}} i32 @t16
- // I386-O0: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i32 @t16
- // I386-O2: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 undef)
+int t15(void) {
+ // CHECK-LABEL: define{{.*}} i32 @t15
+ // CHECK: call i32 asm "nop;", "=%{cx},r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
int a, b;
asm ("nop;" :"=%c" (a) : "r" (b));
@@ -326,47 +138,20 @@ int t16(void) {
}
// PR6475
-void t17(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t17
- // X86_64-O0: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %{{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t17
- // X86_64-O2: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32) %{{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t17
- // I386-O0: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %{{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t17
- // I386-O2: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32) %{{.*}})
+void t16(void) {
+ // CHECK-LABEL: define{{.*}} void @t16
+ // CHECK: call void asm "nop", "=*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %{{.*}})
int i;
__asm__ ("nop": "=m" (i));
}
-int t18(unsigned data) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t18
- // X86_64-O0: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
- // X86_64-O0-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // X86_64-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
- // X86_64-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t18
- // X86_64-O2: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
- // X86_64-O2-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // X86_64-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
- // X86_64-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
- //
- // I386-O0-LABEL: define{{.*}} i32 @t18
- // I386-O0: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
- // I386-O0-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // I386-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
- // I386-O0-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
- //
- // I386-O2-LABEL: define{{.*}} i32 @t18
- // I386-O2: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
- // I386-O2-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // I386-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
- // I386-O2-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
+int t17(unsigned data) {
+ // CHECK-LABEL: define{{.*}} i32 @t17
+ // CHECK: [[ASM_RES:%[a-z0-9.]+]] ={{.*}} call { i32, i32 }
+ // CHECK-SAME: asm "xyz", "={ax},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // CHECK-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 0
+ // CHECK-NEXT: extractvalue { i32, i32 } [[ASM_RES]], 1
int a, b;
asm ("xyz" : "=a" (a), "=d" (b) : "a" (data));
@@ -374,18 +159,9 @@ int t18(unsigned data) {
}
// PR6780
-int t19(unsigned data) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t19
- // X86_64-O0: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t19
- // X86_64-O2: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i32 @t19
- // I386-O0: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i32 @t19
- // I386-O2: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+int t18(unsigned data) {
+ // CHECK-LABEL: define{{.*}} i32 @t18
+ // CHECK: call i32 asm "x$(abc$|def$|ghi$)z", "=r,r,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
int a, b;
asm ("x{abc|def|ghi}z" : "=r" (a) : "r" (data));
@@ -393,48 +169,21 @@ int t19(unsigned data) {
}
// PR6845 - Mismatching source/dest fp types.
-double t20(double x) {
- // X86_64-O0-LABEL: define{{.*}} double @t20
- // X86_64-O0: fpext double {{.*}} to x86_fp80
- // X86_64-O0-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // X86_64-O0: fptrunc x86_fp80 {{.*}} to double
- //
- // X86_64-O2-LABEL: define{{.*}} double @t20
- // X86_64-O2: fpext double {{.*}} to x86_fp80
- // X86_64-O2-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // X86_64-O2-NEXT: fptrunc x86_fp80 {{.*}} to double
- //
- // I386-O0-LABEL: define{{.*}} double @t20
- // I386-O0: fpext double {{.*}} to x86_fp80
- // I386-O0-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // I386-O0: fptrunc x86_fp80 {{.*}} to double
- //
- // I386-O2-LABEL: define{{.*}} double @t20
- // I386-O2: fpext double {{.*}} to x86_fp80
- // I386-O2-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // I386-O2: fptrunc x86_fp80 {{.*}} to double
+double t19(double x) {
+ // CHECK-LABEL: define{{.*}} double @t19
+ // CHECK: fpext double {{.*}} to x86_fp80
+ // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // CHECK: fptrunc x86_fp80 {{.*}} to double
register long double result;
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
return result;
}
-float t21(long double x) {
- // X86_64-O0-LABEL: define{{.*}} float @t21
- // X86_64-O0: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // X86_64-O0-NEXT: fptrunc x86_fp80 {{.*}} to float
- //
- // X86_64-O2-LABEL: define{{.*}} float @t21
- // X86_64-O2: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // X86_64-O2-NEXT: fptrunc x86_fp80 {{.*}} to float
- //
- // I386-O0-LABEL: define{{.*}} float @t21
- // I386-O0: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // I386-O0-NEXT: fptrunc x86_fp80 {{.*}} to float
- //
- // I386-O2-LABEL: define{{.*}} float @t21
- // I386-O2: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
- // I386-O2-NEXT: fptrunc x86_fp80 {{.*}} to float
+float t20(long double x) {
+ // CHECK-LABEL: define{{.*}} float @t20
+ // CHECK: call x86_fp80 asm sideeffect "frndint", "={st},0,~{dirflag},~{fpsr},~{flags}"(x86_fp80 {{.*}})
+ // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float
register float result;
__asm __volatile ("frndint" : "=t" (result) : "0" (x));
@@ -442,73 +191,43 @@ float t21(long double x) {
}
// accept 'l' constraint
-unsigned char t22(unsigned char a, unsigned char b) {
- // X86_64-O0-LABEL: define{{.*}} i8 @t22
- // X86_64-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i8 @t22
- // X86_64-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i8 @t22
- // I386-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i8 @t22
- // I386-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (i32 {{.*}}, i32 {{.*}})
+unsigned char t21(unsigned char a, unsigned char b) {
+ // CHECK-LABEL: define{{.*}} i8 @t21
+ // CHECK: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (i32 {{.*}}, i32 {{.*}})
unsigned int la = a;
unsigned int lb = b;
unsigned int bigres;
unsigned char res;
- __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) : "edx", "cc");
+ __asm__ ("0:\n1:\n"
+ : [bigres] "=la"(bigres)
+ : [la] "0"(la), [lb] "c"(lb)
+ : "edx", "cc");
res = bigres;
return res;
}
// accept 'l' constraint
-unsigned char t23(unsigned char a, unsigned char b) {
- // X86_64-O0-LABEL: define{{.*}} i8 @t23
- // X86_64-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} i8 @t23
- // X86_64-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // I386-O0-LABEL: define{{.*}} i8 @t23
- // I386-O0: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (i32 {{.*}}, i32 {{.*}})
- //
- // I386-O2-LABEL: define{{.*}} i8 @t23
- // I386-O2: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (i32 {{.*}}, i32 {{.*}})
+unsigned char t22(unsigned char a, unsigned char b) {
+ // CHECK-LABEL: define{{.*}} i8 @t22
+ // CHECK: call i32 asm "0:\0A1:\0A", "=l{ax},0,{cx},~{edx},~{cc},~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (i32 {{.*}}, i32 {{.*}})
unsigned int la = a;
unsigned int lb = b;
unsigned char res;
- __asm__ ("0:\n1:\n" : [res] "=la" (res) : [la] "0" (la), [lb] "c" (lb) : "edx", "cc");
+ __asm__ ("0:\n1:\n"
+ : [res] "=la" (res)
+ : [la] "0" (la), [lb] "c" (lb)
+ : "edx", "cc");
return res;
}
-void *t24(char c) {
- // X86_64-O0-LABEL: define{{.*}} ptr @t24
- // X86_64-O0: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
- // X86_64-O0-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
- //
- // X86_64-O2-LABEL: define{{.*}} ptr @t24
- // X86_64-O2: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
- // X86_64-O2-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
- //
- // I386-O0-LABEL: define{{.*}} ptr @t24
- // I386-O0: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i32
- // I386-O0-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 [[C]])
- //
- // I386-O2-LABEL: define{{.*}} ptr @t24
- // I386-O2: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i32
- // I386-O2-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 [[C]])
+void *t23(char c) {
+ // CHECK-LABEL: define{{.*}} ptr @t23
+ // CHECK: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
+ // CHECK-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
void *addr;
__asm__ ("foobar" : "=a" (addr) : "0" (c));
@@ -516,18 +235,9 @@ void *t24(char c) {
}
// PR10299 - fpsr, fpcr
-void t25(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t25
- // X86_64-O0: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
- //
- // X86_64-O2-LABEL: define{{.*}} void @t25
- // X86_64-O2: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
- //
- // I386-O0-LABEL: define{{.*}} void @t25
- // I386-O0: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
- //
- // I386-O2-LABEL: define{{.*}} void @t25
- // I386-O2: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
+void t24(void) {
+ // CHECK-LABEL: define{{.*}} void @t24
+ // CHECK: call void asm sideeffect "finit", "~{st},~{st(1)},~{st(2)},~{st(3)},~{st(4)},~{st(5)},~{st(6)},~{st(7)},~{fpsr},~{fpcr},~{dirflag},~{fpsr},~{flags}"()
__asm__ __volatile__ ("finit" : : :
"st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)",
"st(6)", "st(7)", "fpsr", "fpcr");
@@ -536,166 +246,85 @@ void t25(void) {
// AVX registers
typedef long long __m256i __attribute__((__vector_size__(32)));
-void t26 (__m256i *p) {
- // X86_64-O0-LABEL: define{{.*}} void @t26
- // X86_64-O0: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} void @t26
- // X86_64-O2: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
- //
- // I386-O0-LABEL: define{{.*}} void @t26
- // I386-O0: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
- //
- // I386-O2-LABEL: define{{.*}} void @t26
- // I386-O2: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
- __asm__ volatile ("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0");
+void t25(__m256i *p) {
+ // CHECK-LABEL: define{{.*}} void @t25
+ // CHECK: call void asm sideeffect "vmovaps $0, %ymm0", "*m,~{ymm0},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(<4 x i64>) {{.*}})
+ __asm__ volatile ("vmovaps %0, %%ymm0" : : "m" (*(__m256i*)p) : "ymm0");
}
// Check to make sure the inline asm non-standard dialect attribute _not_ is
// emitted.
-void t27(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t27
- // X86_64-O0: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
- // X86_64-O0-NOT: ia_nsdialect
- // X86_64-O0: ret void
- //
- // X86_64-O2-LABEL: define{{.*}} void @t27
- // X86_64-O2: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
- // X86_64-O2-NOT: ia_nsdialect
- // X86_64-O2: ret void
- //
- // I386-O0-LABEL: define{{.*}} void @t27
- // I386-O0: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
- // I386-O0-NOT: ia_nsdialect
- // I386-O0: ret void
- //
- // I386-O2-LABEL: define{{.*}} void @t27
- // I386-O2: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
- // I386-O2-NOT: ia_nsdialect
- // I386-O2: ret void
+void t26(void) {
+ // CHECK-LABEL: define{{.*}} void @t26
+ // CHECK: call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
+ // CHECK-NOT: ia_nsdialect
+ // CHECK: ret void
asm volatile ("nop");
}
// Check handling of '*' and '#' constraint modifiers.
-void t28(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t28
- // X86_64-O0: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
- //
- // X86_64-O2-LABEL: define{{.*}} void @t28
- // X86_64-O2: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
- //
- // I386-O0-LABEL: define{{.*}} void @t28
- // I386-O0: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
- //
- // I386-O2-LABEL: define{{.*}} void @t28
- // I386-O2: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
+void t27(void) {
+ // CHECK-LABEL: define{{.*}} void @t27
+ // CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
asm volatile ("/* %0 */" : : "i#*X,*r" (1));
}
-static unsigned t29_var[1];
-
-void t29(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t29
- // X86_64-O0: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O0-SAME: (ptr elementtype([1 x i32]) @t29_var)
- //
- // X86_64-O2-LABEL: define{{.*}} void @t29
- // X86_64-O2: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
- // X86_64-O2-SAME: (ptr nonnull elementtype([1 x i32]) @t29_var)
- //
- // I386-O0-LABEL: define{{.*}} void @t29
- // I386-O0: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O0-SAME: (ptr elementtype([1 x i32]) @t29_var)
- //
- // I386-O2-LABEL: define{{.*}} void @t29
- // I386-O2: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
- // I386-O2-SAME: (ptr nonnull elementtype([1 x i32]) @t29_var)
- asm volatile ("movl %%eax, %0" : : "m" (t29_var));
-}
-
-void t30(int len) {
- // X86_64-O0-LABEL: define{{.*}} void @t30
- // X86_64-O0: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
- //
- // X86_64-O2-LABEL: define{{.*}} void @t30
- // X86_64-O2: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O0-LABEL: define{{.*}} void @t30
- // I386-O0: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O2-LABEL: define{{.*}} void @t30
- // I386-O2: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
- __asm__ volatile ("" : "+&&rm" (len));
+static unsigned t28_var[1];
+
+void t28(void) {
+ // CHECK-LABEL: define{{.*}} void @t28
+ // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (ptr elementtype([1 x i32]) @t28_var)
+ asm volatile ("movl %%eax, %0" : : "m" (t28_var));
}
-void t31(int len) {
- // X86_64-O0-LABEL: define{{.*}} void @t31
- // X86_64-O0: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
- //
- // X86_64-O2-LABEL: define{{.*}} void @t31
- // X86_64-O2: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O0-LABEL: define{{.*}} void @t31
- // I386-O0: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O2-LABEL: define{{.*}} void @t31
- // I386-O2: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
- __asm__ volatile("" : "+%%rm" (len), "+rm" (len));
-}
-
-int t32(int cond) {
- // X86_64-O0-LABEL: define{{.*}} i32 @t32
- // X86_64-O0: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // X86_64-O0-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
- //
- // X86_64-O2-LABEL: define{{.*}} i32 @t32
- // X86_64-O2: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // X86_64-O2-NEXT: to label %return [label %label_true, label %return]
- //
- // I386-O0-LABEL: define{{.*}} i32 @t32
- // I386-O0: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // I386-O0-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
- //
- // I386-O2-LABEL: define{{.*}} i32 @t32
- // I386-O2: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
- // I386-O2-NEXT: to label %return [label %label_true, label %return]
+int t29(int cond) {
+ // CHECK-LABEL: define{{.*}} i32 @t29
+ // CHECK: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 {{.*}})
+ // CHECK-NEXT: to label %asm.fallthrough [label %label_true, label %loop]
asm goto ("testl %0, %0; jne %l1;" : : "r" (cond) : : label_true, loop);
return 0;
+
loop:
return 0;
+
label_true:
return 1;
}
-void *t33(void *ptr) {
- // X86_64-O0-LABEL: define{{.*}} ptr @t33
- // X86_64-O0: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
- //
- // X86_64-O2-LABEL: define{{.*}} ptr @t33
- // X86_64-O2: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
- //
- // I386-O0-LABEL: define{{.*}} ptr @t33
- // I386-O0: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
- //
- // I386-O2-LABEL: define{{.*}} ptr @t33
- // I386-O2: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
+void *t30(void *ptr) {
+ // CHECK-LABEL: define{{.*}} ptr @t30
+ // CHECK: call ptr asm "lea $1, $0", "=r,p,~{dirflag},~{fpsr},~{flags}"(ptr {{.*}})
void *ret;
asm ("lea %1, %0" : "=r" (ret) : "p" (ptr));
return ret;
}
-void t34(void) {
- // X86_64-O0-LABEL: define{{.*}} void @t34
- // X86_64-O0: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
- //
- // X86_64-O2-LABEL: define{{.*}} void @t34
- // X86_64-O2: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O0-LABEL: define{{.*}} void @t34
- // I386-O0: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
- //
- // I386-O2-LABEL: define{{.*}} void @t34
- // I386-O2: call void asm sideeffect "T34 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
- __asm__ volatile ("T34 CC NAMED MODIFIER: %cc[input]" : : [input] "i" (4));
+void t31(void) {
+ // CHECK-LABEL: define{{.*}} void @t31
+ // CHECK: call void asm sideeffect "T31 CC NAMED MODIFIER: ${0:c}", "i,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile ("T31 CC NAMED MODIFIER: %cc[input]" : : [input] "i" (4));
+}
+
+void t32(int len) {
+ // CHECK-LABEL: define{{.*}} void @t32
+ // CHECK: call void asm sideeffect "", "=*&rm,0,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile ("" : "+&&rm" (len));
+}
+
+void t33(int len) {
+ // CHECK-LABEL: define{{.*}} void @t33
+ // CHECK: call void asm sideeffect "", "=*%rm,=*rm,0,1,~{dirflag},~{fpsr},~{flags}"
+ __asm__ volatile ("" : "+%%rm" (len), "+rm" (len));
+}
+
+// PR3908
+void t34(int r) {
+ // CHECK-LABEL: define{{.*}} void @t34
+ // CHECK: call i32 asm "PR3908 $1 $3 $2 $0", "=r,mx,mr,x,0,~{dirflag},~{fpsr},~{flags}"
+ // CHECK-SAME: (i32 0, i32 0, double 0.000000e+00, i32 %{{.*}})
+ __asm__ ("PR3908 %[lf] %[xx] %[li] %[r]"
+ : [r] "+r" (r)
+ : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
}
>From fb10039af9bf3dc7857a57c7000e39b5a204b97b Mon Sep 17 00:00:00 2001
From: Bill Wendling <morbo at google.com>
Date: Wed, 15 Apr 2026 13:49:56 -0700
Subject: [PATCH 3/4] Revert back to i386.
---
clang/test/CodeGen/asm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index 8f01bd6f4a5ed..1c18eabf02cd3 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
// PR10415:
//
>From 370466e293b740f17aee01b965312c020aa1ca5f Mon Sep 17 00:00:00 2001
From: Bill Wendling <morbo at google.com>
Date: Wed, 15 Apr 2026 13:52:56 -0700
Subject: [PATCH 4/4] Fixup
---
clang/test/CodeGen/asm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index 1c18eabf02cd3..a20b2feabf64f 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -43,7 +43,7 @@ void t4(void) {
// PR3417
void t5(int i) {
// CHECK-LABEL: define{{.*}} void @t5
- // CHECK: call ptr asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
+ // CHECK: call i32 asm "nop", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr @t5)
asm ("nop" : "=r" (i) : "0" (t5));
}
@@ -120,7 +120,7 @@ struct large {
};
unsigned long t14(int x, struct large *P) {
- // CHECK-LABEL: define{{.*}} i64 @t14
+ // CHECK-LABEL: define{{.*}} i32 @t14
// CHECK: call i32 asm "xyz ", "=r,*m,0,~{dirflag},~{fpsr},~{flags}"
// CHECK-SAME: (ptr elementtype(%struct.large) %{{.*}}, i32 %{{.*}})
__asm__ ("xyz " : "=r" (x) : "m" (*P), "0" (x));
@@ -226,8 +226,8 @@ unsigned char t22(unsigned char a, unsigned char b) {
void *t23(char c) {
// CHECK-LABEL: define{{.*}} ptr @t23
- // CHECK: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i64
- // CHECK-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i64 [[C]])
+ // CHECK: [[C:%[a-z0-9.]+]] = zext i8 {{.*}} to i32
+ // CHECK-NEXT: call ptr asm "foobar", "={ax},0,~{dirflag},~{fpsr},~{flags}"(i32 [[C]])
void *addr;
__asm__ ("foobar" : "=a" (addr) : "0" (c));
More information about the cfe-commits
mailing list