================
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s | FileCheck %s
+
+// Test that __builtin_cpu_is emits the correct ABI value and field offset for
+// every vendor (field offset 0) in llvm/include/llvm/TargetParser/
+// X86TargetParser.def.
+extern void a(const char *);
+
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+
+#define TEST_CPU_IS(NAME, STR)
\
+ void test_##NAME(void) {
\
+ if (__builtin_cpu_is(STR))
\
+ a(STR);
\
+ }
+
+// CHECK-LABEL: define{{.*}} void @test_intel(
+// CHECK: [[LOAD:%[^ ]+]] = load i32, ptr @__cpu_model
+// CHECK: = icmp eq i32 [[LOAD]], 1
+TEST_CPU_IS(intel, "intel")
+
+// CHECK: = icmp eq i32 {{.*}}, 2
+TEST_CPU_IS(amd, "amd")
+
+// CHECK: = icmp eq i32 {{.*}}, 4
+TEST_CPU_IS(other, "other")
----------------
mikolaj-pirog wrote:
The error was also present in the X86TargetParser.def. The tests don't check if
the compiler-rt and llvm agree on the ABI. I don't see how this could be easily
accomplished, but I was thinking about making compiler-rt use the
X86TargetParser.def directly, that would eliminate a possiblity of compiler-rt
and llvm disagreeing
https://github.com/llvm/llvm-project/pull/171172
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits