1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[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
This commit is contained in:
Francis Visoiu Mistrih 2018-10-30 12:07:18 +00:00
parent 9e3b159286
commit ac46438e82
2 changed files with 23 additions and 9 deletions

View File

@ -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...

View File

@ -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