diff options
Diffstat (limited to 'llvm/tools/llvm-mca/CodeRegion.h')
| -rw-r--r-- | llvm/tools/llvm-mca/CodeRegion.h | 24 | 
1 files changed, 10 insertions, 14 deletions
| diff --git a/llvm/tools/llvm-mca/CodeRegion.h b/llvm/tools/llvm-mca/CodeRegion.h index 7f0025e4884..21ca8da9b53 100644 --- a/llvm/tools/llvm-mca/CodeRegion.h +++ b/llvm/tools/llvm-mca/CodeRegion.h @@ -34,6 +34,7 @@  #ifndef LLVM_TOOLS_LLVM_MCA_CODEREGION_H  #define LLVM_TOOLS_LLVM_MCA_CODEREGION_H +#include "llvm/ADT/ArrayRef.h"  #include "llvm/ADT/StringRef.h"  #include "llvm/MC/MCInst.h"  #include "llvm/Support/SMLoc.h" @@ -49,7 +50,7 @@ class CodeRegion {    // An optional descriptor for this region.    llvm::StringRef Description;    // Instructions that form this region. -  std::vector<std::unique_ptr<const llvm::MCInst>> Instructions; +  std::vector<llvm::MCInst> Instructions;    // Source location range.    llvm::SMLoc RangeStart;    llvm::SMLoc RangeEnd; @@ -61,8 +62,8 @@ public:    CodeRegion(llvm::StringRef Desc, llvm::SMLoc Start)        : Description(Desc), RangeStart(Start), RangeEnd() {} -  void addInstruction(std::unique_ptr<const llvm::MCInst> Instruction) { -    Instructions.emplace_back(std::move(Instruction)); +  void addInstruction(const llvm::MCInst &Instruction) { +    Instructions.emplace_back(Instruction);    }    llvm::SMLoc startLoc() const { return RangeStart; } @@ -72,10 +73,7 @@ public:    bool empty() const { return Instructions.empty(); }    bool isLocInRange(llvm::SMLoc Loc) const; -  const std::vector<std::unique_ptr<const llvm::MCInst>> & -  getInstructions() const { -    return Instructions; -  } +  llvm::ArrayRef<llvm::MCInst> getInstructions() const { return Instructions; }    llvm::StringRef getDescription() const { return Description; }  }; @@ -106,23 +104,21 @@ public:    void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc);    void endRegion(llvm::SMLoc Loc); -  void addInstruction(std::unique_ptr<const llvm::MCInst> Instruction); +  void addInstruction(const llvm::MCInst &Instruction);    CodeRegions(llvm::SourceMgr &S) : SM(S) {      // Create a default region for the input code sequence.      addRegion("Default", llvm::SMLoc());    } -  const std::vector<std::unique_ptr<const llvm::MCInst>> & -  getInstructionSequence(unsigned Idx) const { +  llvm::ArrayRef<llvm::MCInst> getInstructionSequence(unsigned Idx) const {      return Regions[Idx]->getInstructions();    }    bool empty() const { -    return std::all_of(Regions.begin(), Regions.end(), -                       [](const std::unique_ptr<CodeRegion> &Region) { -                         return Region->empty(); -                       }); +    return llvm::all_of(Regions, [](const std::unique_ptr<CodeRegion> &Region) { +      return Region->empty(); +    });    }  }; | 

