Update to LLVM 18.1.8

Related: https://issues.redhat.com/browse/RHEL-28687
This commit is contained in:
Konrad Kleine 2024-07-16 14:45:59 +02:00
parent 54ffee6602
commit 179e85873a
3 changed files with 14 additions and 114 deletions

View File

@ -1,103 +0,0 @@
From 97ab1917845fa9426ba913139fc8a007cba1d7ce Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Mon, 27 May 2024 08:54:11 +0200
Subject: [PATCH] [PPCMergeStringPool] Only replace constant once (#92996)
In #88846 I changed this code to use RAUW to perform the replacement
instead of manual updates -- but kept the outer loop, which means we try
to perform RAUW once per user. However, some of the users might be freed
by the RAUW operation, resulting in use-after-free.
The case where this happens is constant users where the replacement
might result in the destruction of the original constant.
Fixes https://github.com/llvm/llvm-project/issues/92991.
(cherry picked from commit 9f85bc834b07ebfec9e5e02deb9255a0f6ec5cc7)
---
.../lib/Target/PowerPC/PPCMergeStringPool.cpp | 37 ++++---------------
.../PowerPC/mergeable-string-pool-pr92991.ll | 20 ++++++++++
2 files changed, 27 insertions(+), 30 deletions(-)
create mode 100644 llvm/test/CodeGen/PowerPC/mergeable-string-pool-pr92991.ll
diff --git a/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp b/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
index ebd876d50c44e..0830b02370cd0 100644
--- a/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
+++ b/llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp
@@ -290,13 +290,6 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) {
return true;
}
-static bool userHasOperand(User *TheUser, GlobalVariable *GVOperand) {
- for (Value *Op : TheUser->operands())
- if (Op == GVOperand)
- return true;
- return false;
-}
-
// For pooled strings we need to add the offset into the pool for each string.
// This is done by adding a Get Element Pointer (GEP) before each user. This
// function adds the GEP.
@@ -307,29 +300,13 @@ void PPCMergeStringPool::replaceUsesWithGEP(GlobalVariable *GlobalToReplace,
Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
Indices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), ElementIndex));
- // Need to save a temporary copy of each user list because we remove uses
- // as we replace them.
- SmallVector<User *> Users;
- for (User *CurrentUser : GlobalToReplace->users())
- Users.push_back(CurrentUser);
-
- for (User *CurrentUser : Users) {
- // The user was not found so it must have been replaced earlier.
- if (!userHasOperand(CurrentUser, GlobalToReplace))
- continue;
-
- // We cannot replace operands in globals so we ignore those.
- if (isa<GlobalValue>(CurrentUser))
- continue;
-
- Constant *ConstGEP = ConstantExpr::getInBoundsGetElementPtr(
- PooledStructType, GPool, Indices);
- LLVM_DEBUG(dbgs() << "Replacing this global:\n");
- LLVM_DEBUG(GlobalToReplace->dump());
- LLVM_DEBUG(dbgs() << "with this:\n");
- LLVM_DEBUG(ConstGEP->dump());
- GlobalToReplace->replaceAllUsesWith(ConstGEP);
- }
+ Constant *ConstGEP =
+ ConstantExpr::getInBoundsGetElementPtr(PooledStructType, GPool, Indices);
+ LLVM_DEBUG(dbgs() << "Replacing this global:\n");
+ LLVM_DEBUG(GlobalToReplace->dump());
+ LLVM_DEBUG(dbgs() << "with this:\n");
+ LLVM_DEBUG(ConstGEP->dump());
+ GlobalToReplace->replaceAllUsesWith(ConstGEP);
}
} // namespace
diff --git a/llvm/test/CodeGen/PowerPC/mergeable-string-pool-pr92991.ll b/llvm/test/CodeGen/PowerPC/mergeable-string-pool-pr92991.ll
new file mode 100644
index 0000000000000..4e9c69e5fe4cf
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/mergeable-string-pool-pr92991.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
+
+@g = private constant [4 x i32] [i32 122, i32 67, i32 35, i32 56]
+@g2 = private constant [1 x i64] [i64 1], align 8
+
+define void @test(ptr %p, ptr %p2) {
+; CHECK-LABEL: test:
+; CHECK: # %bb.0:
+; CHECK-NEXT: addis 5, 2, .L__ModuleStringPool@toc@ha
+; CHECK-NEXT: addi 5, 5, .L__ModuleStringPool@toc@l
+; CHECK-NEXT: addi 6, 5, 12
+; CHECK-NEXT: std 6, 0(3)
+; CHECK-NEXT: addi 3, 5, 16
+; CHECK-NEXT: std 3, 0(4)
+; CHECK-NEXT: blr
+ store ptr getelementptr inbounds ([4 x i32], ptr @g, i64 0, i64 1), ptr %p
+ store ptr getelementptr inbounds ([4 x i32], ptr @g, i64 0, i64 2), ptr %p2
+ ret void
+}

View File

@ -44,7 +44,7 @@
%global maj_ver 18
%global min_ver 1
%global patch_ver 6
%global patch_ver 8
#global rc_ver 4
%if %{with snapshot_build}
@ -101,7 +101,7 @@
Name: %{pkg_name}
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
Release: 3%{?dist}
Release: 1%{?dist}
Summary: The Low Level Virtual Machine
License: Apache-2.0 WITH LLVM-exception OR NCSA
@ -129,9 +129,6 @@ Source8: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{compat
# RHEL-specific patch to avoid unwanted python3-myst-parser dep
Patch101: 0101-Deactivate-markdown-doc.patch
# Backport of PPCMergeStringPool fix for rhbz#2283525.
Patch102: 93442.patch
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: clang
@ -249,13 +246,16 @@ Summary: LLVM's modified googletest sources
%description googletest
LLVM's modified googletest sources.
%if 0%{?rhel}
%package toolset
Summary: Package that installs llvm-toolset
Requires: clang = %{version}
Requires: llvm = %{version}
Requires: lld = %{version}
%description toolset
This is the main package for llvm-toolset.
%endif
%prep
%{gpgverify} --keyring='%{SOURCE6}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
@ -653,6 +653,9 @@ fi
%license LICENSE.TXT
%changelog
* Tue Jul 16 2024 Konrad Kleine <kkleine@redhat.com> - 18.1.8-1
- Update to LLVM 18.1.8
* Tue May 28 2024 Nikita Popov <npopov@redhat.com> - 18.1.6-3
- Fix use after free on ppc64le (rhbz#2283525)

12
sources
View File

@ -1,8 +1,8 @@
SHA512 (llvm-18.1.6.src.tar.xz) = 6b52d63a7c1a604d062ddb69838939fd2e51a31de7225bf4f2c11a6cf3574f96188ebee3020ecbeb77cd4592680571abad8f0a9584a23685bf662b7f085c0372
SHA512 (llvm-18.1.6.src.tar.xz.sig) = a4c87fe68d17d085baa8ad7fd61a2e6b156bf31644904cd54c5527d8b069d09d5183a8e6f3e13157144c3d567fac9cb696f8a69fe6b10960638530772a9adc86
SHA512 (cmake-18.1.6.src.tar.xz) = 1334647f4be280b41858aa272bebc65e935cab772001032f77040396ba7472fbd5eb6a1a0c042ab7156540075705b7f05c8de2f02e2ce9d7ec1ec27be6bef86f
SHA512 (cmake-18.1.6.src.tar.xz.sig) = 27fe3ca9a25f5a20f7ca4e059cd4390d2e484c6a70b309a9e934a80fc732da9d8845064813a47c1258d00be38624aaa9024d5584305076abc2ad93f578b0a3d0
SHA512 (third-party-18.1.6.src.tar.xz) = 4131a08951683972ab4897687b1dbc5cb0873c8d31fdc8fbaab92a2de52249e797b983329ef0d53fc681b531972d8d5550757af52314f0a3087d8009eb2f5c66
SHA512 (third-party-18.1.6.src.tar.xz.sig) = 7c108a3bd67f9a058cbece2e413e7c6b944cc8ebcff323daad78a7fa7185d242f75b5750f7900d962d7516c63aae067809b4dbac4eda934dab3fcc9be4e53641
SHA512 (cmake-18.1.8.src.tar.xz) = e02243b491f9e688db28d7b53270fcf87debf09d3c95b136a7c7b96e26890de68712c60a1e85f5a448a95ad8c81f2d8ae77047780822443bbe39f1a9e6211007
SHA512 (cmake-18.1.8.src.tar.xz.sig) = 99191e95130fe4363a8db8f411a0e61af0549ad182a1280f99f0dd3ee679a321b993d103c6915d535a55d9f8a4d7fea86b7fdcc77605e02150e8edf1e18dee57
SHA512 (llvm-18.1.8.src.tar.xz) = 930814730bb2d80cf7f7b2968f0f1f1442009ca62a7ca29992b69d63823270584b059d16aa845bb381411da566e7e4f255fcfbc38acbdf865eb0419b4dfd7459
SHA512 (llvm-18.1.8.src.tar.xz.sig) = aab7cb61a6b5dd3776a9b306d91d08763710725b72ba6a4263d3cca5ae5959e3b073b27dbfd95f9a53a78600c6f414e2fd1cc0dbe3176d7cf142996f7af700ca
SHA512 (third-party-18.1.8.src.tar.xz) = bedaa5d29ebeaf0ee1c700eb8492d0fef185e7c16528202927c81117d94fadd568829aa0e1873e1217e8e72866f3876a9681bbdb2a6a0a5466fc911f7b3620d4
SHA512 (third-party-18.1.8.src.tar.xz.sig) = 32c4d779a56a3908b291a4f0cf1df72ccb86b55439ad66f9cbad1b48a77cb92b129b131806d2914d0e63cb319cde3181a2c03b75856ec36cee5f88120bb58214
SHA512 (llvm-17.0.6.src.tar.xz) = bf9b04d0d45c67168b195c550cd8326e3a01176f92776705846aad3956a494bcb7a053b0b0bde19abd68dc0068e5c97ef99dee7eadfdb727bc0d758b2684f3bd
SHA512 (llvm-17.0.6.src.tar.xz.sig) = 904066c34ec0adf5b9e789af640329cadc7919b111aca77fa3ce26450696bace20e299e2592251f96ee33fb83da603423cc0ca63a67ad627916fcab0bed59689