llvm.org GIT mirror llvm / 89cab93
Pass a Banner argument to the machine code verifier both from createMachineVerifierPass and MachineFunction::verify. The banner is printed before the machine code dump, just like the printer pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122113 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 9 years ago
7 changed file(s) with 27 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
270270
271271 /// verify - Run the current MachineFunction through the machine code
272272 /// verifier, useful for debugger use.
273 void verify(Pass *p=NULL) const;
273 void verify(Pass *p = NULL, const char *Banner = NULL) const;
274274
275275 // Provide accessors for the MachineBasicBlock list...
276276 typedef BasicBlockListType::iterator iterator;
205205
206206 /// createMachineVerifierPass - This pass verifies cenerated machine code
207207 /// instructions for correctness.
208 FunctionPass *createMachineVerifierPass();
208 FunctionPass *createMachineVerifierPass(const char *Banner = 0);
209209
210210 /// createDwarfEHPass - This pass mulches exception handling code into a form
211211 /// adapted to code generation. Required if using dwarf exception handling.
9595 MachineFunction &mf,
9696 VirtRegMap &vrm) {
9797 if (VerifySpills)
98 mf.verify(&pass);
98 mf.verify(&pass, "When creating inline spiller");
9999 return new InlineSpiller(pass, mf, vrm);
100100 }
101101 }
312312 LiveRangeEdit edit(*li, newIntervals, spillIs);
313313 spill(edit);
314314 if (VerifySpills)
315 mf_.verify(&pass_);
315 mf_.verify(&pass_, "After inline spill");
316316 }
317317
318318 void InlineSpiller::spill(LiveRangeEdit &edit) {
250250 PM.add(createMachineFunctionPrinterPass(dbgs(), Banner));
251251
252252 if (VerifyMachineCode)
253 PM.add(createMachineVerifierPass());
253 PM.add(createMachineVerifierPass(Banner));
254254 }
255255
256256 /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for both
4545 namespace {
4646 struct MachineVerifier {
4747
48 MachineVerifier(Pass *pass) :
48 MachineVerifier(Pass *pass, const char *b) :
4949 PASS(pass),
50 Banner(b),
5051 OutFileName(getenv("LLVM_VERIFY_MACHINEINSTRS"))
5152 {}
5253
5354 bool runOnMachineFunction(MachineFunction &MF);
5455
5556 Pass *const PASS;
57 const char *Banner;
5658 const char *const OutFileName;
5759 raw_ostream *OS;
5860 const MachineFunction *MF;
195197
196198 struct MachineVerifierPass : public MachineFunctionPass {
197199 static char ID; // Pass ID, replacement for typeid
198
199 MachineVerifierPass()
200 : MachineFunctionPass(ID) {
200 const char *const Banner;
201
202 MachineVerifierPass(const char *b = 0)
203 : MachineFunctionPass(ID), Banner(b) {
201204 initializeMachineVerifierPassPass(*PassRegistry::getPassRegistry());
202205 }
203206
207210 }
208211
209212 bool runOnMachineFunction(MachineFunction &MF) {
210 MF.verify(this);
213 MF.verify(this, Banner);
211214 return false;
212215 }
213216 };
218221 INITIALIZE_PASS(MachineVerifierPass, "machineverifier",
219222 "Verify generated machine code", false, false)
220223
221 FunctionPass *llvm::createMachineVerifierPass() {
222 return new MachineVerifierPass();
223 }
224
225 void MachineFunction::verify(Pass *p) const {
226 MachineVerifier(p).runOnMachineFunction(const_cast(*this));
224 FunctionPass *llvm::createMachineVerifierPass(const char *Banner) {
225 return new MachineVerifierPass(Banner);
226 }
227
228 void MachineFunction::verify(Pass *p, const char *Banner) const {
229 MachineVerifier(p, Banner)
230 .runOnMachineFunction(const_cast(*this));
227231 }
228232
229233 bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
296300 void MachineVerifier::report(const char *msg, const MachineFunction *MF) {
297301 assert(MF);
298302 *OS << '\n';
299 if (!foundErrors++)
303 if (!foundErrors++) {
304 if (Banner)
305 *OS << "# " << Banner << '\n';
300306 MF->print(*OS, Indexes);
307 }
301308 *OS << "*** Bad machine code: " << msg << " ***\n"
302309 << "- function: " << MF->getFunction()->getNameStr() << "\n";
303310 }
483483 // spiller. Always use -spiller=inline with -verify-regalloc. Even with the
484484 // inline spiller, some tests fail to verify because the coalescer does not
485485 // always generate verifiable code.
486 MF->verify(this);
486 MF->verify(this, "In RABasic::verify");
487487
488488 // Verify that LiveIntervals are partitioned into unions and disjoint within
489489 // the unions.
328328 .splitAroundLoop(Loop->getLoop());
329329
330330 if (VerifyEnabled)
331 MF->verify(this);
331 MF->verify(this, "After splitting live range around loop");
332332
333333 // We have new split regs, don't assign anything.
334334 return 0;
403403
404404 MF = &mf;
405405 if (VerifyEnabled)
406 MF->verify(this);
406 MF->verify(this, "Before greedy register allocator");
407407
408408 RegAllocBase::init(getAnalysis(), getAnalysis());
409409 DomTree = &getAnalysis();