aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index eb71cff..e037c06 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -237,6 +237,11 @@ static cl::opt<bool> DisableInstrumentManager(
"ignores instruments.)."),
cl::cat(ViewOptions), cl::init(false));
+static cl::opt<bool> SkipUnsupportedInstructions(
+ "skip-unsupported-instructions",
+ cl::desc("Make unsupported instruction errors into warnings."),
+ cl::cat(ViewOptions), cl::init(false));
+
namespace {
const Target *getTarget(const char *ProgName) {
@@ -558,6 +563,7 @@ int main(int argc, char **argv) {
assert(MAB && "Unable to create asm backend!");
json::Object JSONOutput;
+ int NonEmptyRegions = 0;
for (const std::unique_ptr<mca::AnalysisRegion> &Region : Regions) {
// Skip empty code regions.
if (Region->empty())
@@ -571,14 +577,13 @@ int main(int argc, char **argv) {
IPP->resetState();
- DenseMap<const MCInst *, SmallVector<mca::Instrument *>>
- InstToInstruments;
+ DenseMap<const MCInst *, SmallVector<mca::Instrument *>> InstToInstruments;
SmallVector<std::unique_ptr<mca::Instruction>> LoweredSequence;
+ SmallPtrSet<const MCInst *, 16> DroppedInsts;
for (const MCInst &MCI : Insts) {
SMLoc Loc = MCI.getLoc();
const SmallVector<mca::Instrument *> Instruments =
InstrumentRegions.getActiveInstruments(Loc);
- InstToInstruments.insert({&MCI, Instruments});
Expected<std::unique_ptr<mca::Instruction>> Inst =
IB.createInstruction(MCI, Instruments);
@@ -588,7 +593,15 @@ int main(int argc, char **argv) {
[&IP, &STI](const mca::InstructionError<MCInst> &IE) {
std::string InstructionStr;
raw_string_ostream SS(InstructionStr);
- WithColor::error() << IE.Message << '\n';
+ if (SkipUnsupportedInstructions)
+ WithColor::warning()
+ << IE.Message
+ << ", skipping with -skip-unsupported-instructions, "
+ "note accuracy will be impacted:\n";
+ else
+ WithColor::error()
+ << IE.Message
+ << ", use -skip-unsupported-instructions to ignore.\n";
IP->printInst(&IE.Inst, 0, "", *STI, SS);
SS.flush();
WithColor::note()
@@ -597,14 +610,25 @@ int main(int argc, char **argv) {
// Default case.
WithColor::error() << toString(std::move(NewE));
}
+ if (SkipUnsupportedInstructions) {
+ DroppedInsts.insert(&MCI);
+ continue;
+ }
return 1;
}
IPP->postProcessInstruction(Inst.get(), MCI);
-
+ InstToInstruments.insert({&MCI, Instruments});
LoweredSequence.emplace_back(std::move(Inst.get()));
}
+ Insts = Region->dropInstructions(DroppedInsts);
+
+ // Skip empty regions.
+ if (Insts.empty())
+ continue;
+ NonEmptyRegions++;
+
mca::CircularSourceMgr S(LoweredSequence,
PrintInstructionTables ? 1 : Iterations);
@@ -759,6 +783,11 @@ int main(int argc, char **argv) {
++RegionIdx;
}
+ if (NonEmptyRegions == 0) {
+ WithColor::error() << "no assembly instructions found.\n";
+ return 1;
+ }
+
if (PrintJson)
TOF->os() << formatv("{0:2}", json::Value(std::move(JSONOutput))) << "\n";