diff options
| author | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
|---|---|---|
| committer | Michael Kruse <llvm-project@meinersbur.de> | 2025-01-03 10:22:51 +0100 |
| commit | 38500d63e14ce340236840f60d356cdefb56a52c (patch) | |
| tree | 17edbec446ce9b50d2f215a483b83afb293a635d /llvm/lib/CodeGen/MachineInstr.cpp | |
| parent | 1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff) | |
| parent | 27f30029741ecf023baece7b3dde1ff9011ffefc (diff) | |
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 941861da5c56..958efa79d7e9 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -2219,26 +2219,36 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) { return hash_combine_range(HashComponents.begin(), HashComponents.end()); } -void MachineInstr::emitError(StringRef Msg) const { +const MDNode *MachineInstr::getLocCookieMD() 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 (const ConstantInt *CI = - mdconst::dyn_extract<ConstantInt>(LocMD->getOperand(0))) { - LocCookie = CI->getZExtValue(); - break; - } + if (mdconst::hasa<ConstantInt>(LocMD->getOperand(0))) + return LocMD; } } - if (const MachineBasicBlock *MBB = getParent()) - if (const MachineFunction *MF = MBB->getParent()) - return MF->getFunction().getContext().emitError(LocCookie, Msg); - report_fatal_error(Msg); + 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())); } MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, const DebugLoc &DL, |
