summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetPassConfig.cpp
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2018-10-30 12:07:18 +0000
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2018-10-30 12:07:18 +0000
commit85d3f1ee8f109c0f180050020ef9d7c233f782e5 (patch)
treeae182a32e93af87676825fabeb88cffdfab9bd1e /llvm/lib/CodeGen/TargetPassConfig.cpp
parentb3735ee14e7ad01ffc92baed2f7884d5fdbf1464 (diff)
downloadbcm5719-llvm-85d3f1ee8f109c0f180050020ef9d7c233f782e5.tar.gz
bcm5719-llvm-85d3f1ee8f109c0f180050020ef9d7c233f782e5.zip
[llc] Error out when -print-machineinstrs is used with an unknown pass
We used to assert instead of reporting an error. PR39494 llvm-svn: 345589
Diffstat (limited to 'llvm/lib/CodeGen/TargetPassConfig.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetPassConfig.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index a3b24d1cd66..6a9c3c05f03 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -806,15 +806,17 @@ void TargetPassConfig::addMachinePasses() {
AddingMachinePasses = true;
// Insert a machine instr printer pass after the specified pass.
- if (!StringRef(PrintMachineInstrs.getValue()).equals("") &&
- !StringRef(PrintMachineInstrs.getValue()).equals("option-unspecified")) {
- const PassRegistry *PR = PassRegistry::getPassRegistry();
- const PassInfo *TPI = PR->getPassInfo(PrintMachineInstrs.getValue());
- const PassInfo *IPI = PR->getPassInfo(StringRef("machineinstr-printer"));
- assert (TPI && IPI && "Pass ID not registered!");
- const char *TID = (const char *)(TPI->getTypeInfo());
- const char *IID = (const char *)(IPI->getTypeInfo());
- insertPass(TID, IID);
+ StringRef PrintMachineInstrsPassName = PrintMachineInstrs.getValue();
+ if (!PrintMachineInstrsPassName.equals("") &&
+ !PrintMachineInstrsPassName.equals("option-unspecified")) {
+ if (const PassInfo *TPI = getPassInfo(PrintMachineInstrsPassName)) {
+ const PassRegistry *PR = PassRegistry::getPassRegistry();
+ const PassInfo *IPI = PR->getPassInfo(StringRef("machineinstr-printer"));
+ assert(IPI && "failed to get \"machineinstr-printer\" PassInfo!");
+ const char *TID = (const char *)(TPI->getTypeInfo());
+ const char *IID = (const char *)(IPI->getTypeInfo());
+ insertPass(TID, IID);
+ }
}
// Print the instruction selected machine code...
OpenPOWER on IntegriCloud