[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:35:07 PST 2021
oontvoo created this revision.
oontvoo added reviewers: mgorny, ondrasej.
Herald added subscribers: dexonsmith, pengfei, hiraditya.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Detail: In D97504 <https://reviews.llvm.org/D97504>, I replaced the first getX86CpuIDAndInfo() call in getHhostCpuName() with getVendorSignature() (because the purpose of that was to get the vendor signature), but I hadn't noticed that it was also using the EAX (MaxLeaf) value.
Repository:
rG LLVM Github Monorepo
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 this pointer.
+ VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
} // namespace x86
#endif
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97958.328188.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/2186aad5/attachment.bin>
More information about the llvm-commits
mailing list