diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h --- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h +++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h @@ -694,6 +694,7 @@ // Register information bool TracksRegLiveness = false; bool HasWinCFI = false; + bool FailsVerification = false; std::vector VirtualRegisters; std::vector LiveIns; Optional> CalleeSavedRegisters; @@ -722,6 +723,7 @@ YamlIO.mapOptional("failedISel", MF.FailedISel, false); YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false); YamlIO.mapOptional("hasWinCFI", MF.HasWinCFI, false); + YamlIO.mapOptional("failsVerification", MF.FailsVerification, false); YamlIO.mapOptional("registers", MF.VirtualRegisters, std::vector()); YamlIO.mapOptional("liveins", MF.LiveIns, diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -149,6 +149,9 @@ // all sizes attached to them have been eliminated. // TiedOpsRewritten: The twoaddressinstruction pass will set this flag, it // means that tied-def have been rewritten to meet the RegConstraint. + // FailsVerification: Means that the function is not expected to pass machine + // verification. This can be set by passes that introduce known problems that + // have not been fixed yet. enum class Property : unsigned { IsSSA, NoPHIs, @@ -159,7 +162,8 @@ RegBankSelected, Selected, TiedOpsRewritten, - LastProperty = TiedOpsRewritten, + FailsVerification, + LastProperty = FailsVerification, }; bool hasProperty(Property P) const { diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -454,6 +454,9 @@ MF.getProperties().set(MachineFunctionProperties::Property::Selected); if (YamlMF.FailedISel) MF.getProperties().set(MachineFunctionProperties::Property::FailedISel); + if (YamlMF.FailsVerification) + MF.getProperties().set( + MachineFunctionProperties::Property::FailsVerification); PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target); if (parseRegisterInfo(PFS, YamlMF)) diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -217,6 +217,8 @@ MachineFunctionProperties::Property::Selected); YamlMF.FailedISel = MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel); + YamlMF.FailsVerification = MF.getProperties().hasProperty( + MachineFunctionProperties::Property::FailsVerification); convert(YamlMF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo()); MachineModuleSlotTracker MST(&MF); diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -99,6 +99,7 @@ case P::Selected: return "Selected"; case P::TracksLiveness: return "TracksLiveness"; case P::TiedOpsRewritten: return "TiedOpsRewritten"; + case P::FailsVerification: return "FailsVerification"; } llvm_unreachable("Invalid machine function property"); } diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -292,6 +292,13 @@ } bool runOnMachineFunction(MachineFunction &MF) override { + // Skip functions that have known verification problems. + // FIXME: Remove this mechanism when all problematic passes have been + // fixed. + if (MF.getProperties().hasProperty( + MachineFunctionProperties::Property::FailsVerification)) + return false; + unsigned FoundErrors = MachineVerifier(this, Banner.c_str()).verify(MF); if (FoundErrors) report_fatal_error("Found "+Twine(FoundErrors)+" machine code errors."); diff --git a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp --- a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp +++ b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp @@ -127,6 +127,10 @@ bool prepare(); bool runOnMachineFunction(MachineFunction &MF) override { + // FIXME: This pass causes verification failures. + MF.getProperties().set( + MachineFunctionProperties::Property::FailsVerification); + TII = MF.getSubtarget().getInstrInfo(); TRI = &TII->getRegisterInfo(); LLVM_DEBUG(MF.dump();); diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp --- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -787,6 +787,10 @@ } bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) { + // FIXME: This pass causes verification failures. + MF.getProperties().set( + MachineFunctionProperties::Property::FailsVerification); + const GCNSubtarget &ST = MF.getSubtarget(); TII = ST.getInstrInfo(); TRI = &TII->getRegisterInfo(); diff --git a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp --- a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp +++ b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp @@ -1498,6 +1498,11 @@ } bool SIWholeQuadMode::runOnMachineFunction(MachineFunction &MF) { + // This pass is a convenient place to re-enable machine verification after the + // problems caused by SILowerControlFlow have been fixed. + MF.getProperties().reset( + MachineFunctionProperties::Property::FailsVerification); + LLVM_DEBUG(dbgs() << "SI Whole Quad Mode on " << MF.getName() << " ------------- \n"); LLVM_DEBUG(MF.dump();); diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -203,6 +203,10 @@ } bool HexagonPacketizer::runOnMachineFunction(MachineFunction &MF) { + // FIXME: This pass causes verification failures. + MF.getProperties().set( + MachineFunctionProperties::Property::FailsVerification); + auto &HST = MF.getSubtarget(); HII = HST.getInstrInfo(); HRI = HST.getRegisterInfo();