[PATCH] D152332: [X86] Improve diagnostics for named registers
Evgenii Kudriashov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 11 06:06:11 PDT 2023
e-kud created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
e-kud updated this revision to Diff 529954.
e-kud added a comment.
e-kud published this revision for review.
e-kud added reviewers: pengfei, RKSimon.
e-kud added a subscriber: RKSimon.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Rebased
e-kud added a comment.
Hi @pengfei @RKSimon, what do you think about such diagnostic improvement? It works perfectly with `clang`, however `llc` ignores errors in a handler and continues execution. It seems that we need a combination of diagnostic and `report_fatal_error` to stop both `clang` and `llc`. Or is it expected behavior of `llc`?
Closes #62984
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152332
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/named-reg-alloc.ll
llvm/test/CodeGen/X86/named-reg-notareg.ll
llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll
Index: llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll
===================================================================
--- llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll
+++ llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll
@@ -1,8 +1,8 @@
-; RUN: not --crash llc < %s -mtriple=x86_64-linux-gnueabi 2>&1 | FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-linux-gnueabi 2>&1 | FileCheck %s
define i32 @get_frame() nounwind {
entry:
-; CHECK: register ebp is allocatable: function has no frame pointer
+; CHECK: error: register 'ebp' is allocatable: function 'get_frame' has no frame pointer
%fp = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %fp
}
Index: llvm/test/CodeGen/X86/named-reg-notareg.ll
===================================================================
--- llvm/test/CodeGen/X86/named-reg-notareg.ll
+++ llvm/test/CodeGen/X86/named-reg-notareg.ll
@@ -3,8 +3,8 @@
define i32 @get_stack() nounwind {
entry:
-; CHECK: Invalid register name global variable
- %sp = call i32 @llvm.read_register.i32(metadata !0)
+; CHECK: error: invalid register name for a global variable: notareg
+ %sp = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %sp
}
Index: llvm/test/CodeGen/X86/named-reg-alloc.ll
===================================================================
--- llvm/test/CodeGen/X86/named-reg-alloc.ll
+++ llvm/test/CodeGen/X86/named-reg-alloc.ll
@@ -4,8 +4,8 @@
define i32 @get_stack() nounwind {
entry:
; FIXME: Include an allocatable-specific error message
-; CHECK: Invalid register name global variable
- %sp = call i32 @llvm.read_register.i32(metadata !0)
+; CHECK: error: invalid register name for a global variable: eax
+ %sp = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %sp
}
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -29506,6 +29506,7 @@
Register X86TargetLowering::getRegisterByName(const char* RegName, LLT VT,
const MachineFunction &MF) const {
const TargetFrameLowering &TFI = *Subtarget.getFrameLowering();
+ LLVMContext &Ctx = MF.getFunction().getContext();
Register Reg = StringSwitch<unsigned>(RegName)
.Case("esp", X86::ESP)
@@ -29516,8 +29517,9 @@
if (Reg == X86::EBP || Reg == X86::RBP) {
if (!TFI.hasFP(MF))
- report_fatal_error("register " + StringRef(RegName) +
- " is allocatable: function has no frame pointer");
+ Ctx.emitError("register '" + StringRef(RegName) +
+ "' is allocatable: function '" + MF.getName() +
+ "' has no frame pointer");
#ifndef NDEBUG
else {
const X86RegisterInfo *RegInfo = Subtarget.getRegisterInfo();
@@ -29531,7 +29533,9 @@
if (Reg)
return Reg;
- report_fatal_error("Invalid register name global variable");
+ Ctx.emitError("invalid register name for a global variable: " +
+ StringRef(RegName));
+ return Reg;
}
SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152332.529954.patch
Type: text/x-patch
Size: 3182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/58048674/attachment-0001.bin>
More information about the llvm-commits
mailing list