[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)

Phoebe Wang via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 5 07:09:00 PDT 2024


================
@@ -1710,15 +1710,17 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
 
 #if defined(__i386__) || defined(_M_IX86) || \
     defined(__x86_64__) || defined(_M_X64)
-bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
+std::optional<StringMap<bool>> sys::getHostCPUFeatures() {
   unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
   unsigned MaxLevel;
 
   if (getX86CpuIDAndInfo(0, &MaxLevel, &EBX, &ECX, &EDX) || MaxLevel < 1)
-    return false;
+    return {};
 
   getX86CpuIDAndInfo(1, &EAX, &EBX, &ECX, &EDX);
 
+  StringMap<bool> Features;
----------------
phoebewang wrote:

IIUC, the motivation is to avoid creating a blank map. But here we still create it with each call. Is there any difference except early return in line 1728, which should rarely happend.

https://github.com/llvm/llvm-project/pull/97824


More information about the lldb-commits mailing list