diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/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(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, diff --git a/llvm/test/CodeGen/X86/named-reg-alloc.ll b/llvm/test/CodeGen/X86/named-reg-alloc.ll --- a/llvm/test/CodeGen/X86/named-reg-alloc.ll +++ b/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 } diff --git a/llvm/test/CodeGen/X86/named-reg-notareg.ll b/llvm/test/CodeGen/X86/named-reg-notareg.ll --- a/llvm/test/CodeGen/X86/named-reg-notareg.ll +++ b/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 } diff --git a/llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll b/llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll --- a/llvm/test/CodeGen/X86/read-fp-no-frame-pointer.ll +++ b/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 }