Skip to content

Commit 4272060

Browse files
committed
[llvm-mca] InstrBuilder: warnings for call/ret instructions are only reported once.
llvm-svn: 347514
1 parent e0466f5 commit 4272060

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

llvm/tools/llvm-mca/include/InstrBuilder.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class InstrBuilder {
4646
DenseMap<unsigned short, std::unique_ptr<const InstrDesc>> Descriptors;
4747
DenseMap<const MCInst *, std::unique_ptr<const InstrDesc>> VariantDescriptors;
4848

49+
bool FirstCallInst;
50+
bool FirstReturnInst;
51+
4952
Expected<const InstrDesc &> createInstrDescImpl(const MCInst &MCI);
5053
Expected<const InstrDesc &> getOrCreateInstrDesc(const MCInst &MCI);
5154

@@ -60,7 +63,11 @@ class InstrBuilder {
6063
InstrBuilder(const MCSubtargetInfo &STI, const MCInstrInfo &MCII,
6164
const MCRegisterInfo &RI, const MCInstrAnalysis &IA);
6265

63-
void clear() { VariantDescriptors.shrink_and_clear(); }
66+
void clear() {
67+
VariantDescriptors.shrink_and_clear();
68+
FirstCallInst = true;
69+
FirstReturnInst = true;
70+
}
6471

6572
Expected<std::unique_ptr<Instruction>> createInstruction(const MCInst &MCI);
6673
};

llvm/tools/llvm-mca/lib/InstrBuilder.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ InstrBuilder::InstrBuilder(const llvm::MCSubtargetInfo &sti,
2929
const llvm::MCInstrInfo &mcii,
3030
const llvm::MCRegisterInfo &mri,
3131
const llvm::MCInstrAnalysis &mcia)
32-
: STI(sti), MCII(mcii), MRI(mri), MCIA(mcia) {
32+
: STI(sti), MCII(mcii), MRI(mri), MCIA(mcia), FirstCallInst(true),
33+
FirstReturnInst(true) {
3334
computeProcResourceMasks(STI.getSchedModel(), ProcResourceMasks);
3435
}
3536

@@ -455,17 +456,19 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) {
455456
std::unique_ptr<InstrDesc> ID = llvm::make_unique<InstrDesc>();
456457
ID->NumMicroOps = SCDesc.NumMicroOps;
457458

458-
if (MCDesc.isCall()) {
459+
if (MCDesc.isCall() && FirstCallInst) {
459460
// We don't correctly model calls.
460461
WithColor::warning() << "found a call in the input assembly sequence.\n";
461462
WithColor::note() << "call instructions are not correctly modeled. "
462463
<< "Assume a latency of 100cy.\n";
464+
FirstCallInst = false;
463465
}
464466

465-
if (MCDesc.isReturn()) {
467+
if (MCDesc.isReturn() && FirstReturnInst) {
466468
WithColor::warning() << "found a return instruction in the input"
467469
<< " assembly sequence.\n";
468470
WithColor::note() << "program counter updates are ignored.\n";
471+
FirstReturnInst = false;
469472
}
470473

471474
ID->MayLoad = MCDesc.mayLoad();

0 commit comments

Comments
 (0)