[llvm] clang crash assigning to a global named register variable #109778 (PR #113105)
Akshay Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 13:59:06 PDT 2024
https://github.com/akshaykumars614 created https://github.com/llvm/llvm-project/pull/113105
fixed crash
I am not sure if the fix is correct. I tried to analyze the logic and found potential issue in the logic and corrected it. Because of this, two testcases;
arm64-named-reg-alloc.ll :
; RUN: not --crash llc < %s -mtriple=arm64-apple-darwin 2>&1 | FileCheck %s
; RUN: not --crash llc < %s -mtriple=arm64-linux-gnueabi 2>&1 | FileCheck %s
define i32 @get_stack() nounwind {
entry:
; FIXME: Include an allocatable-specific error message
; CHECK: Invalid register name "x5".
%sp = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %sp
}
declare i32 @llvm.read_register.i32(metadata) nounwind
!0 = !{!"x5\00"}
aarch64-named-reg-x18.ll :
; RUN: llc -mtriple=aarch64-fuchsia -o - %s
define void @set_x18(i64 %x) {
entry:
; FIXME: Include an allocatable-specific error message
tail call void @llvm.write_register.i64(metadata !0, i64 %x)
ret void
}
declare void @llvm.write_register.i64(metadata, i64) nounwind
!0 = !{!"x18"}
I am new to project. Please help me here.
>From ecbf43e8e73c31d4a2730e685b410bc507d0815d Mon Sep 17 00:00:00 2001
From: akshaykumars614 <akshaykumars614 at gmail.com>
Date: Sun, 20 Oct 2024 16:54:10 -0400
Subject: [PATCH] clang crash assigning to a global named register variable
#109778
fixed crash
---
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 7448416c682abc..98703d8368813a 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -11522,8 +11522,8 @@ getRegisterByName(const char* RegName, LLT VT, const MachineFunction &MF) const
if (AArch64::X1 <= Reg && Reg <= AArch64::X28) {
const AArch64RegisterInfo *MRI = Subtarget->getRegisterInfo();
unsigned DwarfRegNum = MRI->getDwarfRegNum(Reg, false);
- if (!Subtarget->isXRegisterReserved(DwarfRegNum) &&
- !MRI->isReservedReg(MF, Reg))
+ if (Subtarget->isXRegisterReserved(DwarfRegNum) ||
+ MRI->isReservedReg(MF, Reg))
Reg = 0;
}
if (Reg)
More information about the llvm-commits
mailing list