diff options
author | Jan Voung <jvoung@chromium.org> | 2013-02-04 09:34:30 -0800 |
---|---|---|
committer | Jan Voung <jvoung@chromium.org> | 2013-02-04 09:34:30 -0800 |
commit | 8bdbdf71c987b7604a178c1ebabfab3d22c0e85b (patch) | |
tree | b26f480631ac19b0d3a09e02b683b889fcbc02f6 | |
parent | b2be8cafd394a1617a290d1ef358395e5326acf2 (diff) |
Make some LLVM localmods compile when building with --disable-assertions.
Also, wrap some more debug code under the DEBUG() macro so that it gets
pruned with --disable-assertions.
BUG=none
Review URL: https://codereview.chromium.org/12162006
-rw-r--r-- | include/llvm/CodeGen/LexicalScopes.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/ValueHandle.h | 8 | ||||
-rw-r--r-- | lib/Target/ARM/ARMNaClRewritePass.cpp | 68 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 1 | ||||
-rw-r--r-- | lib/Target/X86/X86NaClRewritePass.cpp | 32 |
5 files changed, 61 insertions, 50 deletions
diff --git a/include/llvm/CodeGen/LexicalScopes.h b/include/llvm/CodeGen/LexicalScopes.h index bb22cb74c5..dad13381a3 100644 --- a/include/llvm/CodeGen/LexicalScopes.h +++ b/include/llvm/CodeGen/LexicalScopes.h @@ -164,8 +164,10 @@ public: #endif // @LOCALMOD-BEGIN -- Hack for bug // http://code.google.com/p/nativeclient/issues/detail?id=2786 +#ifndef NDEBUG Desc.make_weak(); InlinedAtLocation.make_weak(); +#endif // @LOCALMOD-END if (Parent) diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index 5e98fbd07a..c278e67056 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -240,10 +240,16 @@ public: // @LOCALMOD-BEGIN -- Hack for bug: // http://code.google.com/p/nativeclient/issues/detail?id=2786 // This allows us to weaken the Asserting Value Handle in LexicalScopes.h, - // for Debug info only. + // for Debug info only. FIXME: check if this is fixed by some upstream + // changes, e.g., r174084. Test by building the full ARM IRT w/ debug + // info, and dosbox with full debug info. +#ifndef NDEBUG + // Only enable for !defined(NDEBUG), since this only inherits from + // ValueHandleBase when !defined(NDEBUG). void make_weak() { setKind(Weak); } +#endif // @LOCALMOD-END ValueTy *operator->() const { return getValPtr(); } diff --git a/lib/Target/ARM/ARMNaClRewritePass.cpp b/lib/Target/ARM/ARMNaClRewritePass.cpp index d26a35848d..d18886bfa4 100644 --- a/lib/Target/ARM/ARMNaClRewritePass.cpp +++ b/lib/Target/ARM/ARMNaClRewritePass.cpp @@ -121,23 +121,28 @@ static bool IsDirectCall(const MachineInstr &MI) { } static void DumpInstructionVerbose(const MachineInstr &MI) { - dbgs() << MI; - dbgs() << MI.getNumOperands() << " operands:" << "\n"; - for (unsigned i = 0; i < MI.getNumOperands(); ++i) { - const MachineOperand& op = MI.getOperand(i); - dbgs() << " " << i << "(" << op.getType() << "):" << op << "\n"; - } - dbgs() << "\n"; + DEBUG({ + dbgs() << MI; + dbgs() << MI.getNumOperands() << " operands:" << "\n"; + for (unsigned i = 0; i < MI.getNumOperands(); ++i) { + const MachineOperand& op = MI.getOperand(i); + dbgs() << " " << i << "(" << op.getType() << "):" << op << "\n"; + } + dbgs() << "\n"; + }); } static void DumpBasicBlockVerbose(const MachineBasicBlock &MBB) { - dbgs() << "\n<<<<< DUMP BASIC BLOCK START\n"; - for (MachineBasicBlock::const_iterator MBBI = MBB.begin(), MBBE = MBB.end(); - MBBI != MBBE; - ++MBBI) { - DumpInstructionVerbose(*MBBI); - } - dbgs() << "<<<<< DUMP BASIC BLOCK END\n\n"; + DEBUG({ + dbgs() << "\n<<<<< DUMP BASIC BLOCK START\n"; + for (MachineBasicBlock::const_iterator + MBBI = MBB.begin(), MBBE = MBB.end(); + MBBI != MBBE; + ++MBBI) { + DumpInstructionVerbose(*MBBI); + } + dbgs() << "<<<<< DUMP BASIC BLOCK END\n\n"; + }); } /**********************************************************************/ @@ -301,25 +306,24 @@ void ARMNaClRewritePass::getAnalysisUsage(AnalysisUsage &AU) const { * E.g., it could be used along with bugpoint to reduce a bitcode file. */ void ARMNaClRewritePass::LightweightVerify(MachineFunction &MF) { - - for (MachineFunction::iterator MFI = MF.begin(), MFE = MF.end(); - MFI != MFE; - ++MFI) { - MachineBasicBlock &MBB = *MFI; - for (MachineBasicBlock::iterator MBBI = MBB.begin(), MBBE = MBB.end(); - MBBI != MBBE; - ++MBBI) { - MachineInstr &MI = *MBBI; - - if (ARM_SFI::NeedSandboxStackChange(MI, TRI)) { - dbgs() << "LightWeightVerify for function: " - << MF.getFunction()->getName() << " (BAD STACK CHANGE)\n"; - DumpInstructionVerbose(MI); - DumpBasicBlockVerbose(MBB); - // assert(false && "LightweightVerify Failed"); + DEBUG({ + for (MachineFunction::iterator MFI = MF.begin(), MFE = MF.end(); + MFI != MFE; + ++MFI) { + MachineBasicBlock &MBB = *MFI; + for (MachineBasicBlock::iterator MBBI = MBB.begin(), MBBE = MBB.end(); + MBBI != MBBE; + ++MBBI) { + MachineInstr &MI = *MBBI; + if (ARM_SFI::NeedSandboxStackChange(MI, TRI)) { + dbgs() << "LightWeightVerify for function: " + << MF.getFunction()->getName() << " (BAD STACK CHANGE)\n"; + DumpInstructionVerbose(MI); + DumpBasicBlockVerbose(MBB); + } + } } - } - } + }); } void ARMNaClRewritePass::SandboxStackChange(MachineBasicBlock &MBB, diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 72d8b5c7fd..175cb31b1f 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -2877,7 +2877,6 @@ void X86InstrInfo::copyPhysReg(MachineBasicBlock &MBB, DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) << " to " << RI.getName(DestReg) << '\n'); - MBB.dump(); llvm_unreachable("Cannot emit physreg copy instruction"); } diff --git a/lib/Target/X86/X86NaClRewritePass.cpp b/lib/Target/X86/X86NaClRewritePass.cpp index 7310dcd77a..846c72f452 100644 --- a/lib/Target/X86/X86NaClRewritePass.cpp +++ b/lib/Target/X86/X86NaClRewritePass.cpp @@ -79,7 +79,6 @@ namespace { bool ApplyControlSFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI); - void PassLightWeightValidator(MachineBasicBlock &MBB); bool AlignJumpTableTargets(MachineFunction &MF); }; @@ -87,7 +86,17 @@ namespace { } -static void DumpInstructionVerbose(const MachineInstr &MI); +static void DumpInstructionVerbose(const MachineInstr &MI) { + DEBUG({ + dbgs() << MI; + dbgs() << MI.getNumOperands() << " operands:" << "\n"; + for (unsigned i = 0; i < MI.getNumOperands(); ++i) { + const MachineOperand& op = MI.getOperand(i); + dbgs() << " " << i << "(" << op.getType() << "):" << op << "\n"; + } + dbgs() << "\n"; + }); +} static bool IsPushPop(MachineInstr &MI) { const unsigned Opcode = MI.getOpcode(); @@ -204,7 +213,8 @@ void X86NaClRewritePass::TraceLog(const char *func, const MachineBasicBlock &MBB, const MachineBasicBlock::iterator MBBI) const { - DEBUG(dbgs() << "@" << func << "(" << MBB.getName() << ", " << (*MBBI) << ")\n"); + DEBUG(dbgs() << "@" << func + << "(" << MBB.getName() << ", " << (*MBBI) << ")\n"); } bool X86NaClRewritePass::ApplyStackSFI(MachineBasicBlock &MBB, @@ -303,7 +313,7 @@ bool X86NaClRewritePass::ApplyStackSFI(MachineBasicBlock &MBB, return true; } - DumpInstructionVerbose(MI); + DEBUG(DumpInstructionVerbose(MI)); llvm_unreachable("Unhandled Stack SFI"); } @@ -389,7 +399,7 @@ bool X86NaClRewritePass::ApplyFrameSFI(MachineBasicBlock &MBB, return true; } - DumpInstructionVerbose(MI); + DEBUG(DumpInstructionVerbose(MI)); llvm_unreachable("Unhandled Frame SFI"); } @@ -480,7 +490,7 @@ bool X86NaClRewritePass::ApplyControlSFI(MachineBasicBlock &MBB, return true; } - DumpInstructionVerbose(MI); + DEBUG(DumpInstructionVerbose(MI)); llvm_unreachable("Unhandled Control SFI"); } @@ -744,16 +754,6 @@ bool X86NaClRewritePass::runOnMachineBasicBlock(MachineBasicBlock &MBB) { return Modified; } -static void DumpInstructionVerbose(const MachineInstr &MI) { - dbgs() << MI; - dbgs() << MI.getNumOperands() << " operands:" << "\n"; - for (unsigned i = 0; i < MI.getNumOperands(); ++i) { - const MachineOperand& op = MI.getOperand(i); - dbgs() << " " << i << "(" << op.getType() << "):" << op << "\n"; - } - dbgs() << "\n"; -} - /// createX86NaClRewritePassPass - returns an instance of the pass. namespace llvm { FunctionPass* createX86NaClRewritePass() { |