diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-12-11 07:51:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 07:51:36 -0800 |
commit | 40986feda8b1437ed475b144d5b9a208b008782a (patch) | |
tree | fb9cf5f5da966ed1caf5c01f3e86e2144a77b100 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 323bedd0d60a9f4c04015687326eba1e96f34b04 (diff) | |
download | llvm-40986feda8b1437ed475b144d5b9a208b008782a.zip llvm-40986feda8b1437ed475b144d5b9a208b008782a.tar.gz llvm-40986feda8b1437ed475b144d5b9a208b008782a.tar.bz2 |
Revert "DiagnosticInfo: Clean up usage of DiagnosticInfoInlineAsm" (#119575)
Reverts llvm/llvm-project#119485
Breaks builders, details in llvm/llvm-project#119485
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, |