diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 958efa7..941861d 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -2219,36 +2219,26 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) { return hash_combine_range(HashComponents.begin(), HashComponents.end()); } -const MDNode *MachineInstr::getLocCookieMD() const { +void MachineInstr::emitError(StringRef Msg) const { // Find the source location cookie. + uint64_t LocCookie = 0; const MDNode *LocMD = nullptr; for (unsigned i = getNumOperands(); i != 0; --i) { if (getOperand(i-1).isMetadata() && (LocMD = getOperand(i-1).getMetadata()) && LocMD->getNumOperands() != 0) { - if (mdconst::hasa<ConstantInt>(LocMD->getOperand(0))) - return LocMD; + if (const ConstantInt *CI = + mdconst::dyn_extract<ConstantInt>(LocMD->getOperand(0))) { + LocCookie = CI->getZExtValue(); + break; + } } } - return nullptr; -} - -void MachineInstr::emitInlineAsmError(const Twine &Msg) const { - assert(isInlineAsm()); - const MDNode *LocMD = getLocCookieMD(); - uint64_t LocCookie = - LocMD - ? mdconst::extract<ConstantInt>(LocMD->getOperand(0))->getZExtValue() - : 0; - LLVMContext &Ctx = getMF()->getFunction().getContext(); - Ctx.diagnose(DiagnosticInfoInlineAsm(LocCookie, Msg)); -} - -void MachineInstr::emitGenericError(const Twine &Msg) const { - const Function &Fn = getMF()->getFunction(); - Fn.getContext().diagnose( - DiagnosticInfoGenericWithLoc(Msg, Fn, getDebugLoc())); + if (const MachineBasicBlock *MBB = getParent()) + if (const MachineFunction *MF = MBB->getParent()) + return MF->getFunction().getContext().emitError(LocCookie, Msg); + report_fatal_error(Msg); } MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, const DebugLoc &DL, |