[llvm] DiagnosticInfo: Clean up usage of DiagnosticInfoInlineAsm (PR #119485)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 22:49:32 PST 2024
================
@@ -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();
----------------
arsenm wrote:
The point of returning the node was one of the users directly needs the MDNode
https://github.com/llvm/llvm-project/pull/119485
More information about the llvm-commits
mailing list