[PATCH] D124942: [BOLT][TEST] Fix MCPlusBuilder::getAliases with two targets

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 10:13:30 PDT 2022


Amir created this revision.
Herald added subscribers: ayermolo, jeroen.dobbelaere.
Herald added a reviewer: rafauler.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124942

Files:
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Core/MCPlusBuilder.cpp
  bolt/unittests/Core/MCPlusBuilder.cpp


Index: bolt/unittests/Core/MCPlusBuilder.cpp
===================================================================
--- bolt/unittests/Core/MCPlusBuilder.cpp
+++ bolt/unittests/Core/MCPlusBuilder.cpp
@@ -62,7 +62,8 @@
     if (GetParam() != Arch)
       GTEST_SKIP();
 
-    const BitVector &BV = BC->MIB->getAliases(Register, OnlySmaller);
+    const BitVector &BV =
+        BC->MIB->getAliases(Register, OnlySmaller, /* Cache = */ false);
     ASSERT_EQ(BV.count(), Count);
     for (size_t I = 0; I < Count; ++I)
       ASSERT_TRUE(BV[Aliases[I]]);
Index: bolt/lib/Core/MCPlusBuilder.cpp
===================================================================
--- bolt/lib/Core/MCPlusBuilder.cpp
+++ bolt/lib/Core/MCPlusBuilder.cpp
@@ -439,17 +439,22 @@
   return false;
 }
 
-const BitVector &MCPlusBuilder::getAliases(MCPhysReg Reg,
-                                           bool OnlySmaller) const {
+const BitVector &MCPlusBuilder::getAliases(MCPhysReg Reg, bool OnlySmaller,
+                                           bool Cache) const {
   // AliasMap caches a mapping of registers to the set of registers that
   // alias (are sub or superregs of itself, including itself).
   static std::vector<BitVector> AliasMap;
   static std::vector<BitVector> SmallerAliasMap;
 
-  if (AliasMap.size() > 0) {
-    if (OnlySmaller)
-      return SmallerAliasMap[Reg];
-    return AliasMap[Reg];
+  if (Cache) {
+    if (AliasMap.size() > 0) {
+      if (OnlySmaller)
+        return SmallerAliasMap[Reg];
+      return AliasMap[Reg];
+    }
+  } else {
+    AliasMap.clear();
+    SmallerAliasMap.clear();
   }
 
   // Build alias map
Index: bolt/include/bolt/Core/MCPlusBuilder.h
===================================================================
--- bolt/include/bolt/Core/MCPlusBuilder.h
+++ bolt/include/bolt/Core/MCPlusBuilder.h
@@ -1132,8 +1132,8 @@
 
   /// Return a BitVector marking all sub or super registers of \p Reg, including
   /// itself.
-  virtual const BitVector &getAliases(MCPhysReg Reg,
-                                      bool OnlySmaller = false) const;
+  virtual const BitVector &getAliases(MCPhysReg Reg, bool OnlySmaller = false,
+                                      bool Cache = true) const;
 
   /// Change \p Regs setting all registers used to pass parameters according
   /// to the host abi. Do nothing if not implemented.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124942.427055.patch
Type: text/x-patch
Size: 2358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/2068e264/attachment.bin>


More information about the llvm-commits mailing list