[PATCH] D97958: [llvm][support] Fix unused variable bug caused by D97504

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 08:40:03 PST 2021


oontvoo updated this revision to Diff 328190.
oontvoo added a comment.

updated comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97958

Files:
  llvm/include/llvm/Support/Host.h
  llvm/lib/Support/Host.cpp


Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -498,13 +498,15 @@
 namespace detail {
 namespace x86 {
 
-VendorSignatures getVendorSignature() {
+VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
   unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
+  if (MaxLeaf == nullptr)
+    MaxLeaf = &EAX;
 
   if (!isCpuIdSupported())
     return VendorSignatures::UNKNOWN;
 
-  if (getX86CpuIDAndInfo(0, &EAX, &EBX, &ECX, &EDX) || EAX < 1)
+  if (getX86CpuIDAndInfo(0, MaxLeaf, &EBX, &ECX, &EDX) || *MaxLeaf < 1)
     return VendorSignatures::UNKNOWN;
 
   // "Genu ineI ntel"
@@ -1122,7 +1124,8 @@
 }
 
 StringRef sys::getHostCPUName() {
-  const VendorSignatures Vendor = getVendorSignature();
+  unsigned MaxLeaf = 0;
+  const VendorSignatures Vendor = getVendorSignature(&MaxLeaf);
   if (Vendor == VendorSignatures::UNKNOWN)
     return "generic";
 
@@ -1131,7 +1134,6 @@
 
   unsigned Family = 0, Model = 0;
   unsigned Features[(X86::CPU_FEATURE_MAX + 31) / 32] = {0};
-  unsigned MaxLeaf = 0;
   detectX86FamilyModel(EAX, &Family, &Model);
   getAvailableFeatures(ECX, EDX, MaxLeaf, Features);
 
Index: llvm/include/llvm/Support/Host.h
===================================================================
--- llvm/include/llvm/Support/Host.h
+++ llvm/include/llvm/Support/Host.h
@@ -77,7 +77,9 @@
   };
 
   /// Returns the host CPU's vendor.
-  VendorSignatures getVendorSignature();
+  /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
+  /// assigned to its pointee.
+  VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
   } // namespace x86
 #endif
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97958.328190.patch
Type: text/x-patch
Size: 1718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/8cfd7bc5/attachment.bin>


More information about the llvm-commits mailing list