Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions llvm/lib/MCA/InstrBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,14 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI,
bool IsVariadic = MCDesc.isVariadic();
if ((ID->IsRecyclable = !IsVariadic && !IsVariant)) {
auto DKey = std::make_pair(MCI.getOpcode(), SchedClassID);
Descriptors[DKey] = std::move(ID);
return *Descriptors[DKey];
return *(Descriptors[DKey] = std::move(ID));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if I am a bit late on this review.

Have you considered using insert_or_assign() ?
https://llvm.org/doxygen/DenseMap_8h_source.html#l00306

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using insert_or_assign() should solve the issue in a nicer way. That is, assuming that my understanding of how insert_or_assign() works is correct :) .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could use insert_or_assign, but that would be a bit mouthful though:

    return *(Descriptors[DKey] = std::move(ID));
    return *(Descriptors.insert_or_assign(DKey, std::move(ID)).first->second);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm yeah, it forces you to do that annoying first->second to get the iterator from the pair.
Nevermind then. Thanks for the fix!

}

auto VDKey = std::make_pair(hashMCInst(MCI), SchedClassID);
assert(
!VariantDescriptors.contains(VDKey) &&
"Expected VariantDescriptors to not already have a value for this key.");
VariantDescriptors[VDKey] = std::move(ID);
return *VariantDescriptors[VDKey];
return *(VariantDescriptors[VDKey] = std::move(ID));
}

Expected<const InstrDesc &>
Expand Down