diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -282,6 +282,8 @@ // Initialize the default annotation allocator with id 0 AnnotationAllocators.emplace(0, AnnotationAllocator()); MaxAllocatorId++; + // Build alias map + initAliases(); } /// Initialize a new annotation allocator and return its id @@ -1135,6 +1137,9 @@ virtual const BitVector &getAliases(MCPhysReg Reg, bool OnlySmaller = false) const; + /// Initialize aliases tables. + virtual void initAliases(); + /// Change \p Regs setting all registers used to pass parameters according /// to the host abi. Do nothing if not implemented. virtual BitVector getRegsUsedAsParams() const { @@ -1904,6 +1909,11 @@ llvm_unreachable("not implemented"); return BlocksVectorTy(); } + + // AliasMap caches a mapping of registers to the set of registers that + // alias (are sub or superregs of itself, including itself). + std::vector AliasMap; + std::vector SmallerAliasMap; }; MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *, diff --git a/bolt/lib/Core/MCPlusBuilder.cpp b/bolt/lib/Core/MCPlusBuilder.cpp --- a/bolt/lib/Core/MCPlusBuilder.cpp +++ b/bolt/lib/Core/MCPlusBuilder.cpp @@ -441,17 +441,13 @@ const BitVector &MCPlusBuilder::getAliases(MCPhysReg Reg, bool OnlySmaller) 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 AliasMap; - static std::vector SmallerAliasMap; - - if (AliasMap.size() > 0) { - if (OnlySmaller) - return SmallerAliasMap[Reg]; - return AliasMap[Reg]; - } + if (OnlySmaller) + return SmallerAliasMap[Reg]; + return AliasMap[Reg]; +} +void MCPlusBuilder::initAliases() { + assert(AliasMap.size() == 0 && SmallerAliasMap.size() == 0); // Build alias map for (MCPhysReg I = 0, E = RegInfo->getNumRegs(); I != E; ++I) { BitVector BV(RegInfo->getNumRegs(), false); @@ -492,10 +488,6 @@ dbgs() << "\n"; } }); - - if (OnlySmaller) - return SmallerAliasMap[Reg]; - return AliasMap[Reg]; } uint8_t MCPlusBuilder::getRegSize(MCPhysReg Reg) const {