[backport][Clang] Fix crash with -fzero-call-used-reg
Signed-off-by: xiajingze <xiajingze1@huawei.com>
This commit is contained in:
parent
550a32921a
commit
2da3a9511b
@ -0,0 +1,72 @@
|
|||||||
|
From 28e3fc80336935bc8bed372e78616ef5be9f4908 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Arthur Eubanks <aeubanks@google.com>
|
||||||
|
Date: Thu, 27 Jul 2023 13:27:58 -0700
|
||||||
|
Subject: [PATCH] Don't zero out noreg operands
|
||||||
|
|
||||||
|
A tail call may have $noreg operands.
|
||||||
|
|
||||||
|
Fixes a crash.
|
||||||
|
|
||||||
|
Reviewed By: xgupta
|
||||||
|
|
||||||
|
Differential Revision: https://reviews.llvm.org/D156485
|
||||||
|
---
|
||||||
|
llvm/lib/CodeGen/PrologEpilogInserter.cpp | 9 +++++++--
|
||||||
|
llvm/test/CodeGen/X86/zero-call-used-regs.ll | 14 ++++++++++++++
|
||||||
|
2 files changed, 21 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
||||||
|
index e323aaaeefaf..49047719fdaa 100644
|
||||||
|
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
||||||
|
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
|
||||||
|
@@ -1285,6 +1285,8 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
|
||||||
|
continue;
|
||||||
|
|
||||||
|
MCRegister Reg = MO.getReg();
|
||||||
|
+ if (!Reg)
|
||||||
|
+ continue;
|
||||||
|
|
||||||
|
// This picks up sibling registers (e.q. %al -> %ah).
|
||||||
|
for (MCRegUnit Unit : TRI.regunits(Reg))
|
||||||
|
@@ -1308,8 +1310,11 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
|
||||||
|
if (!MO.isReg())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
- for (const MCPhysReg &Reg :
|
||||||
|
- TRI.sub_and_superregs_inclusive(MO.getReg()))
|
||||||
|
+ MCRegister Reg = MO.getReg();
|
||||||
|
+ if (!Reg)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ for (const MCPhysReg Reg : TRI.sub_and_superregs_inclusive(Reg))
|
||||||
|
RegsToZero.reset(Reg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/llvm/test/CodeGen/X86/zero-call-used-regs.ll b/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
||||||
|
index 63d51c916bb9..97ad5ce9c8cb 100644
|
||||||
|
--- a/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
||||||
|
+++ b/llvm/test/CodeGen/X86/zero-call-used-regs.ll
|
||||||
|
@@ -241,6 +241,20 @@ entry:
|
||||||
|
ret i32 %x
|
||||||
|
}
|
||||||
|
|
||||||
|
+define dso_local void @tailcall(ptr %p) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" {
|
||||||
|
+; I386-LABEL: tailcall:
|
||||||
|
+; I386: # %bb.0:
|
||||||
|
+; I386-NEXT: movl {{[0-9]+}}(%esp), %eax
|
||||||
|
+; I386-NEXT: jmpl *(%eax) # TAILCALL
|
||||||
|
+;
|
||||||
|
+; X86-64-LABEL: tailcall:
|
||||||
|
+; X86-64: # %bb.0:
|
||||||
|
+; X86-64-NEXT: jmpq *(%rdi) # TAILCALL
|
||||||
|
+ %c = load ptr, ptr %p
|
||||||
|
+ tail call void %c()
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
; Don't emit zeroing registers in "main" function.
|
||||||
|
define dso_local i32 @main() local_unnamed_addr #1 {
|
||||||
|
; I386-LABEL: main:
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
Name: %{pkg_name}
|
Name: %{pkg_name}
|
||||||
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
Version: %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||||
Release: 23
|
Release: 24
|
||||||
Summary: The Low Level Virtual Machine
|
Summary: The Low Level Virtual Machine
|
||||||
|
|
||||||
License: NCSA
|
License: NCSA
|
||||||
@ -84,6 +84,7 @@ Patch24: 0024-Backport-LoongArch-fix-and-add-some-new-support.patch
|
|||||||
Patch25: 0025-Backport-Simple-check-to-ignore-Inline-asm-fwait-insertion.patch
|
Patch25: 0025-Backport-Simple-check-to-ignore-Inline-asm-fwait-insertion.patch
|
||||||
Patch26: 0026-Add-arch-restriction-for-BiSheng-Autotuner.patch
|
Patch26: 0026-Add-arch-restriction-for-BiSheng-Autotuner.patch
|
||||||
Patch27: 0027-AArch64-Delete-hip09-macro.patch
|
Patch27: 0027-AArch64-Delete-hip09-macro.patch
|
||||||
|
Patch28: 0028-backport-Clang-Fix-crash-with-fzero-call-used-regs.patch
|
||||||
|
|
||||||
BuildRequires: binutils-devel
|
BuildRequires: binutils-devel
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
@ -377,6 +378,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C %{__cmake
|
|||||||
%{install_includedir}/llvm-gmock
|
%{install_includedir}/llvm-gmock
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 19 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-24
|
||||||
|
- [backport][Clang] Fix crash with -fzero-call-used-regs
|
||||||
|
|
||||||
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-23
|
* Mon Nov 18 2024 xiajingze <xiajingze1@huawei.com> - 17.0.6-23
|
||||||
- [AArch64] Delete hip09 macro
|
- [AArch64] Delete hip09 macro
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user