[PATCH] D101338: [MS] Fix crash when calling __cpuid with /EHsc and -mavx2

Pengfei Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 26 20:32:41 PDT 2021


pengfei updated this revision to Diff 340718.
pengfei added a comment.

Update for test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101338/new/

https://reviews.llvm.org/D101338

Files:
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/ms-intrinsics-cpuid.c


Index: clang/test/CodeGen/ms-intrinsics-cpuid.c
===================================================================
--- clang/test/CodeGen/ms-intrinsics-cpuid.c
+++ clang/test/CodeGen/ms-intrinsics-cpuid.c
@@ -12,7 +12,15 @@
 void test__cpuid(int *info, int level) {
   __cpuid(info, level);
 }
-// CHECK-LABEL: define {{.*}} @test__cpuid(i32* %{{.*}}, i32 %{{.*}})
+// CHECK-LABEL: define {{.*}} @__cpuid(i32* %{{.*}}, i32 %{{.*}})
 // CHECK: call { i32, i32, i32, i32 } asm "cpuid",
 // CHECK-SAME:   "={ax},={bx},={cx},={dx},{ax},{cx},~{dirflag},~{fpsr},~{flags}"
 // CHECK-SAME:   (i32 %{{.*}}, i32 0)
+
+// CHECK-LABEL: define {{.*}} @__cpuidex(i32* %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
+// CHECK: call { i32, i32, i32, i32 } asm "cpuid",
+// CHECK-SAME:   "={ax},={bx},={cx},={dx},{ax},{cx},~{dirflag},~{fpsr},~{flags}"
+// CHECK-SAME:   (i32 %{{.*}}, i32 %{{.*}})
+
+// CHECK-LABEL: define {{.*}} @test__cpuid(i32* %{{.*}}, i32 %{{.*}})
+// CHECK: call void @__cpuid(i32* %{{.*}}, i32 %{{.*}})
Index: clang/lib/Headers/intrin.h
===================================================================
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -507,12 +507,12 @@
 |* Misc
 \*----------------------------------------------------------------------------*/
 #if defined(__i386__) || defined(__x86_64__)
-static __inline__ void __DEFAULT_FN_ATTRS __cpuid(int __info[4], int __level) {
+static void __attribute__((noinline, __nodebug__)) __cpuid(int __info[4], int __level) {
   __asm__("cpuid"
           : "=a"(__info[0]), "=b"(__info[1]), "=c"(__info[2]), "=d"(__info[3])
           : "a"(__level), "c"(0));
 }
-static __inline__ void __DEFAULT_FN_ATTRS __cpuidex(int __info[4], int __level,
+static void __attribute__((noinline, __nodebug__)) __cpuidex(int __info[4], int __level,
                                                     int __ecx) {
   __asm__("cpuid"
           : "=a"(__info[0]), "=b"(__info[1]), "=c"(__info[2]), "=d"(__info[3])


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101338.340718.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210427/bf5263a8/attachment.bin>


More information about the cfe-commits mailing list