diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-25 17:03:51 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-25 17:03:51 +0000 |
| commit | 1e6d0aad7e90744dcaa5d9be8644dafd5181834d (patch) | |
| tree | 05238615999949d7eeee62ec2ad4e32c15b13915 /llvm/tools/llvm-mca/lib/InstrBuilder.cpp | |
| parent | b53cf99388b24f1477dc50cada7a21c083bca083 (diff) | |
| download | bcm5719-llvm-1e6d0aad7e90744dcaa5d9be8644dafd5181834d.tar.gz bcm5719-llvm-1e6d0aad7e90744dcaa5d9be8644dafd5181834d.zip | |
[llvm-mca] Introduce a new base class for mca::Instruction, and change how read/write information is stored.
This patch introduces a new base class for Instruction named InstructionBase.
Class InstructionBase is responsible for tracking data dependencies with the
help of ReadState and WriteState objects. Class Instruction now derives from
InstructionBase, and adds extra information related to the `InstrStage` as well
as the `RCUTokenID`.
ReadState and WriteState objects are no longer unique pointers. This avoids
extra heap allocation and pointer checks that weren't really needed. Now, those
objects are simply stored into SmallVectors. We use a SmallVector instead of a
std::vector because we expect most instructions to only have a very small number
of reads and writes. By using a simple SmallVector we also avoid extra heap
allocations most of the time.
In a debug build, this improves the performance of llvm-mca by roughly 10% (I
still have to verify the impact in performance on a release build).
llvm-svn: 345280
Diffstat (limited to 'llvm/tools/llvm-mca/lib/InstrBuilder.cpp')
| -rw-r--r-- | llvm/tools/llvm-mca/lib/InstrBuilder.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/tools/llvm-mca/lib/InstrBuilder.cpp b/llvm/tools/llvm-mca/lib/InstrBuilder.cpp index 3768c2e7088..3704eaf6a50 100644 --- a/llvm/tools/llvm-mca/lib/InstrBuilder.cpp +++ b/llvm/tools/llvm-mca/lib/InstrBuilder.cpp @@ -482,14 +482,15 @@ InstrBuilder::createInstruction(const MCInst &MCI) { // Okay, this is a register operand. Create a ReadState for it. assert(RegID > 0 && "Invalid register ID found!"); - auto RS = llvm::make_unique<ReadState>(RD, RegID); + NewIS->getUses().emplace_back(RD, RegID); + ReadState &RS = NewIS->getUses().back(); if (IsDepBreaking) { // A mask of all zeroes means: explicit input operands are not // independent. if (Mask.isNullValue()) { if (!RD.isImplicitRead()) - RS->setIndependentFromDef(); + RS.setIndependentFromDef(); } else { // Check if this register operand is independent according to `Mask`. // Note that Mask may not have enough bits to describe all explicit and @@ -499,11 +500,10 @@ InstrBuilder::createInstruction(const MCInst &MCI) { if (Mask.getBitWidth() > RD.UseIndex) { // Okay. This map describe register use `RD.UseIndex`. if (Mask[RD.UseIndex]) - RS->setIndependentFromDef(); + RS.setIndependentFromDef(); } } } - NewIS->getUses().emplace_back(std::move(RS)); } // Early exit if there are no writes. @@ -530,9 +530,9 @@ InstrBuilder::createInstruction(const MCInst &MCI) { } assert(RegID && "Expected a valid register ID!"); - NewIS->getDefs().emplace_back(llvm::make_unique<WriteState>( + NewIS->getDefs().emplace_back( WD, RegID, /* ClearsSuperRegs */ WriteMask[WriteIndex], - /* WritesZero */ IsZeroIdiom)); + /* WritesZero */ IsZeroIdiom); ++WriteIndex; } |

