[llvm] r345589 - [llc] Error out when -print-machineinstrs is used with an unknown pass
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 30 05:07:18 PDT 2018
Author: thegameg
Date: Tue Oct 30 05:07:18 2018
New Revision: 345589
URL: http://llvm.org/viewvc/llvm-project?rev=345589&view=rev
Log:
[llc] Error out when -print-machineinstrs is used with an unknown pass
We used to assert instead of reporting an error.
PR39494
Added:
llvm/trunk/test/CodeGen/X86/llc-print-machineinstrs.mir
Modified:
llvm/trunk/lib/CodeGen/TargetPassConfig.cpp
Modified: llvm/trunk/lib/CodeGen/TargetPassConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetPassConfig.cpp?rev=345589&r1=345588&r2=345589&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetPassConfig.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetPassConfig.cpp Tue Oct 30 05:07:18 2018
@@ -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...
Added: llvm/trunk/test/CodeGen/X86/llc-print-machineinstrs.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/llc-print-machineinstrs.mir?rev=345589&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/llc-print-machineinstrs.mir (added)
+++ llvm/trunk/test/CodeGen/X86/llc-print-machineinstrs.mir Tue Oct 30 05:07:18 2018
@@ -0,0 +1,12 @@
+# Check that -print-machineinstrs doesn't assert when it's passed an unknown pass name.
+# RUN: llc -mtriple=x86_64-- -start-before=greedy -print-machineinstrs=greedy %s -o /dev/null
+# RUN: not llc -mtriple=x86_64-- -start-before=greedy -print-machineinstrs=unknown %s -o /dev/null 2>&1 | FileCheck %s
+# CHECK: LLVM ERROR: "unknown" pass is not registered.
+
+...
+---
+name: fun
+tracksRegLiveness: true
+body: |
+ bb.0:
+ RET 0
More information about the llvm-commits
mailing list