diff --git a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index d075d7ab10a..77c0a8cb48e 100644 --- a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -193,7 +193,8 @@ public: class OperandsMapper { /// The OpIdx-th cell contains the index in NewVRegs where the VRegs of the /// OpIdx-th operand starts. -1 means we do not have such mapping yet. - std::unique_ptr OpToNewVRegIdx; + /// Note: We use a SmallVector to avoid heap allocation for most cases. + SmallVector OpToNewVRegIdx; /// Hold the registers that will be used to map MI with InstrMapping. SmallVector NewVRegs; /// Current MachineRegisterInfo, used to create new virtual registers. diff --git a/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index 91681fb7a40..ca9e8e61552 100644 --- a/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -513,7 +513,7 @@ RegisterBankInfo::OperandsMapper::OperandsMapper( MachineRegisterInfo &MRI) : MRI(MRI), MI(MI), InstrMapping(InstrMapping) { unsigned NumOpds = MI.getNumOperands(); - OpToNewVRegIdx.reset(new int[NumOpds]); + OpToNewVRegIdx.resize(NumOpds); std::fill(&OpToNewVRegIdx[0], &OpToNewVRegIdx[NumOpds], OperandsMapper::DontKnowIdx); assert(InstrMapping.verify(MI) && "Invalid mapping for MI");