summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/CodeRegion.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/CodeRegion.h')
-rw-r--r--llvm/tools/llvm-mca/CodeRegion.h23
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/tools/llvm-mca/CodeRegion.h b/llvm/tools/llvm-mca/CodeRegion.h
index 1cdfeabfef4..cc474b78ca7 100644
--- a/llvm/tools/llvm-mca/CodeRegion.h
+++ b/llvm/tools/llvm-mca/CodeRegion.h
@@ -34,6 +34,7 @@
#define LLVM_TOOLS_LLVM_MCA_CODEREGION_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCInst.h"
#include "llvm/Support/SMLoc.h"
@@ -50,7 +51,7 @@ class CodeRegion {
// An optional descriptor for this region.
llvm::StringRef Description;
// Instructions that form this region.
- std::vector<llvm::MCInst> Instructions;
+ llvm::SmallVector<llvm::MCInst, 8> Instructions;
// Source location range.
llvm::SMLoc RangeStart;
llvm::SMLoc RangeEnd;
@@ -82,20 +83,15 @@ class CodeRegions {
// A source manager. Used by the tool to generate meaningful warnings.
llvm::SourceMgr &SM;
- std::vector<std::unique_ptr<CodeRegion>> Regions;
-
- // Construct a new region of code guarded by LLVM-MCA comments.
- void addRegion(llvm::StringRef Description, llvm::SMLoc Loc) {
- Regions.emplace_back(llvm::make_unique<CodeRegion>(Description, Loc));
- }
+ using UniqueCodeRegion = std::unique_ptr<CodeRegion>;
+ std::vector<UniqueCodeRegion> Regions;
CodeRegions(const CodeRegions &) = delete;
CodeRegions &operator=(const CodeRegions &) = delete;
public:
- typedef std::vector<std::unique_ptr<CodeRegion>>::iterator iterator;
- typedef std::vector<std::unique_ptr<CodeRegion>>::const_iterator
- const_iterator;
+ typedef std::vector<UniqueCodeRegion>::iterator iterator;
+ typedef std::vector<UniqueCodeRegion>::const_iterator const_iterator;
iterator begin() { return Regions.begin(); }
iterator end() { return Regions.end(); }
@@ -107,17 +103,14 @@ public:
void addInstruction(const llvm::MCInst &Instruction);
llvm::SourceMgr &getSourceMgr() const { return SM; }
- CodeRegions(llvm::SourceMgr &S) : SM(S) {
- // Create a default region for the input code sequence.
- addRegion("Default", llvm::SMLoc());
- }
+ CodeRegions(llvm::SourceMgr &S);
llvm::ArrayRef<llvm::MCInst> getInstructionSequence(unsigned Idx) const {
return Regions[Idx]->getInstructions();
}
bool empty() const {
- return llvm::all_of(Regions, [](const std::unique_ptr<CodeRegion> &Region) {
+ return llvm::all_of(Regions, [](const UniqueCodeRegion &Region) {
return Region->empty();
});
}
OpenPOWER on IntegriCloud