mirror of
https://src.fedoraproject.org/rpms/llvm.git
synced 2024-11-28 02:34:52 +00:00
Backport a fix addressing miscompliation related to TLS
this change backports a commit from upstream's release/18.x branch to address a miscompliation related to TLS. the fix addresses the issue where TLS variables could fail to initialize after the globalopt pass. this change has been backported to the release/18.x branch, but since LLVM 17.0.6 does not receive any more patches, we need to backport it in downstream. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
This commit is contained in:
parent
79d4892286
commit
528cead504
2 changed files with 104 additions and 1 deletions
|
@ -0,0 +1,97 @@
|
||||||
|
From 3d0752b9492efd60e85aedec79676596af6fb4f8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: DianQK <dianqk@dianqk.net>
|
||||||
|
Date: Fri, 17 May 2024 05:51:49 +0800
|
||||||
|
Subject: [PATCH] [GlobalOpt] Don't replace aliasee with alias that has weak
|
||||||
|
linkage (#91483)
|
||||||
|
|
||||||
|
Fixes #91312.
|
||||||
|
|
||||||
|
Don't perform the transform if the alias may be replaced at link time.
|
||||||
|
|
||||||
|
(cherry picked from commit c79690040acf5bb3d857558b0878db47f7f23dc3)
|
||||||
|
---
|
||||||
|
llvm/lib/Transforms/IPO/GlobalOpt.cpp | 3 ++
|
||||||
|
llvm/test/Transforms/GlobalOpt/alias-weak.ll | 57 ++++++++++++++++++++
|
||||||
|
2 files changed, 60 insertions(+)
|
||||||
|
create mode 100644 llvm/test/Transforms/GlobalOpt/alias-weak.ll
|
||||||
|
|
||||||
|
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
|
||||||
|
index 951372adcfa9..619b3f612f25 100644
|
||||||
|
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
|
||||||
|
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
|
||||||
|
@@ -2212,6 +2212,9 @@ static bool mayHaveOtherReferences(GlobalValue &GV, const LLVMUsed &U) {
|
||||||
|
|
||||||
|
static bool hasUsesToReplace(GlobalAlias &GA, const LLVMUsed &U,
|
||||||
|
bool &RenameTarget) {
|
||||||
|
+ if (GA.isWeakForLinker())
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
RenameTarget = false;
|
||||||
|
bool Ret = false;
|
||||||
|
if (hasUseOtherThanLLVMUsed(GA, U))
|
||||||
|
diff --git a/llvm/test/Transforms/GlobalOpt/alias-weak.ll b/llvm/test/Transforms/GlobalOpt/alias-weak.ll
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..aec2a56313b1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/llvm/test/Transforms/GlobalOpt/alias-weak.ll
|
||||||
|
@@ -0,0 +1,57 @@
|
||||||
|
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --include-generated-funcs --version 4
|
||||||
|
+; RUN: opt < %s -passes=globalopt -S | FileCheck %s
|
||||||
|
+
|
||||||
|
+@f1_alias = linkonce_odr hidden alias void (), ptr @f1
|
||||||
|
+@f2_alias = linkonce_odr hidden alias void (), ptr @f2
|
||||||
|
+
|
||||||
|
+define void @foo() {
|
||||||
|
+ call void @f1_alias()
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+define void @bar() {
|
||||||
|
+ call void @f1()
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+define void @baz() {
|
||||||
|
+ call void @f2_alias()
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+; We cannot use `f1_alias` to replace `f1` because they are both in use
|
||||||
|
+; and `f1_alias` could be replaced at link time.
|
||||||
|
+define internal void @f1() {
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+; FIXME: We can use `f2_alias` to replace `f2` because `b2` is not in use.
|
||||||
|
+define internal void @f2() {
|
||||||
|
+ ret void
|
||||||
|
+}
|
||||||
|
+;.
|
||||||
|
+; CHECK: @f1_alias = linkonce_odr hidden alias void (), ptr @f1
|
||||||
|
+; CHECK: @f2_alias = linkonce_odr hidden alias void (), ptr @f2
|
||||||
|
+;.
|
||||||
|
+; CHECK-LABEL: define void @foo() local_unnamed_addr {
|
||||||
|
+; CHECK-NEXT: call void @f1_alias()
|
||||||
|
+; CHECK-NEXT: ret void
|
||||||
|
+;
|
||||||
|
+;
|
||||||
|
+; CHECK-LABEL: define void @bar() local_unnamed_addr {
|
||||||
|
+; CHECK-NEXT: call void @f1()
|
||||||
|
+; CHECK-NEXT: ret void
|
||||||
|
+;
|
||||||
|
+;
|
||||||
|
+; CHECK-LABEL: define void @baz() local_unnamed_addr {
|
||||||
|
+; CHECK-NEXT: call void @f2_alias()
|
||||||
|
+; CHECK-NEXT: ret void
|
||||||
|
+;
|
||||||
|
+;
|
||||||
|
+; CHECK-LABEL: define internal void @f1() {
|
||||||
|
+; CHECK-NEXT: ret void
|
||||||
|
+;
|
||||||
|
+;
|
||||||
|
+; CHECK-LABEL: define internal void @f2() {
|
||||||
|
+; CHECK-NEXT: ret void
|
||||||
|
+;
|
||||||
|
--
|
||||||
|
2.45.1
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
Name: %{pkg_name}
|
Name: %{pkg_name}
|
||||||
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
|
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Summary: The Low Level Virtual Machine
|
Summary: The Low Level Virtual Machine
|
||||||
|
|
||||||
License: Apache-2.0 WITH LLVM-exception OR NCSA
|
License: Apache-2.0 WITH LLVM-exception OR NCSA
|
||||||
|
@ -115,6 +115,9 @@ Source6: release-keys.asc
|
||||||
|
|
||||||
# Backport of https://reviews.llvm.org/D156485 for rhbz#2262260.
|
# Backport of https://reviews.llvm.org/D156485 for rhbz#2262260.
|
||||||
Patch0: 0001-PEI-Don-t-zero-out-noreg-operands.patch
|
Patch0: 0001-PEI-Don-t-zero-out-noreg-operands.patch
|
||||||
|
# https://github.com/llvm/llvm-project/commit/3d0752b9492efd60e85aedec79676596af6fb4f8
|
||||||
|
# This patch will be in 18.1.6
|
||||||
|
Patch1: 0001-GlobalOpt-Don-t-replace-aliasee-with-alias-that-has-.patch
|
||||||
|
|
||||||
# RHEL-specific patch to avoid unwanted recommonmark dep
|
# RHEL-specific patch to avoid unwanted recommonmark dep
|
||||||
Patch101: 0101-Deactivate-markdown-doc.patch
|
Patch101: 0101-Deactivate-markdown-doc.patch
|
||||||
|
@ -614,6 +617,9 @@ fi
|
||||||
%changelog
|
%changelog
|
||||||
%{?llvm_snapshot_changelog_entry}
|
%{?llvm_snapshot_changelog_entry}
|
||||||
|
|
||||||
|
* Thu May 30 2024 Kefu Chai <tchaikov@fedoraproject.org> - 17.0.6-4
|
||||||
|
- Backport fix for https://github.com/llvm/llvm-project/issues/91312
|
||||||
|
|
||||||
* Thu Feb 01 2024 Nikita Popov <npopov@redhat.com> - 17.0.6-3
|
* Thu Feb 01 2024 Nikita Popov <npopov@redhat.com> - 17.0.6-3
|
||||||
- Fix crash with -fzero-call-used-regs (rhbz#2262260)
|
- Fix crash with -fzero-call-used-regs (rhbz#2262260)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue