Date: Friday, November 12, 2021 @ 10:14:01 Author: foutrelis Revision: 427924
upgpkg: llvm 13.0.0-3: re-add GEP element type resolution This is a temporary workaround until intel-graphics-compiler is fixed. https://github.com/intel/intel-graphics-compiler/issues/204 Added: llvm/trunk/don-t-accept-nullptr-as-GEP-element-type.patch Modified: llvm/trunk/PKGBUILD ------------------------------------------------+ PKGBUILD | 7 ++ don-t-accept-nullptr-as-GEP-element-type.patch | 63 +++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-11-12 10:00:39 UTC (rev 427923) +++ PKGBUILD 2021-11-12 10:14:01 UTC (rev 427924) @@ -3,7 +3,7 @@ pkgname=('llvm' 'llvm-libs' 'llvm-ocaml') pkgver=13.0.0 -pkgrel=2 +pkgrel=3 _ocaml_ver=4.12.0 arch=('x86_64') url="https://llvm.org/" @@ -15,11 +15,13 @@ options=('staticlibs') _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver source=($_source_base/$pkgname-$pkgver.src.tar.xz{,.sig} + don-t-accept-nullptr-as-GEP-element-type.patch no-strict-aliasing-DwarfCompileUnit.patch disable-bswap-for-spir.patch llvm-config.h) sha256sums=('408d11708643ea826f519ff79761fcdfc12d641a2510229eec459e72f8163020' 'SKIP' + 'a7e902a7612d0fdabe436a917468b043cc296bc89d8954bfc3126f737beb9ac4' 'd1eff24508e35aae6c26a943dbaa3ef5acb60a145b008fd1ef9ac6f6c4faa662' 'af163392fbc19d65d11ab4b1510a2eae39b417d6228023b3ba5395b138bb41f5' '597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48') @@ -30,6 +32,9 @@ cd "$srcdir/llvm-$pkgver.src" mkdir build + # https://github.com/intel/intel-graphics-compiler/issues/204 + patch -Rp2 -i ../don-t-accept-nullptr-as-GEP-element-type.patch + # Work around intermittent 'clang -O -g' crashes # https://bugs.llvm.org/show_bug.cgi?id=50611#c3 patch -Np2 -i ../no-strict-aliasing-DwarfCompileUnit.patch Added: don-t-accept-nullptr-as-GEP-element-type.patch =================================================================== --- don-t-accept-nullptr-as-GEP-element-type.patch (rev 0) +++ don-t-accept-nullptr-as-GEP-element-type.patch 2021-11-12 10:14:01 UTC (rev 427924) @@ -0,0 +1,63 @@ +From b00cff56cfb15cbfa74cb512c9cee1c402cce55b Mon Sep 17 00:00:00 2001 +From: Nikita Popov <[email protected]> +Date: Thu, 8 Jul 2021 20:56:05 +0200 +Subject: [PATCH] Reapply [IR] Don't accept nullptr as GEP element type + +Reapply after fixing another occurrence in lldb that was relying +on this in the preceding commit. + +----- + +GetElementPtrInst::Create() (and IRBuilder methods based on it) +currently accept nullptr as the element type, and will fetch the +element type from the pointer in that case. Remove this fallback, +as it is incompatible with opaque pointers. I've removed a handful +of leftover calls using this behavior as a preliminary step. + +Out-of-tree code affected by this change should either pass a proper +type, or can temporarily explicitly call getPointerElementType(), +if the newly added assertion is encountered. + +Differential Revision: https://reviews.llvm.org/D105653 +--- + llvm/include/llvm/IR/Instructions.h | 20 ++++++-------------- + 1 file changed, 6 insertions(+), 14 deletions(-) + +diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h +index a5cebf0a4626..0c43a56daa33 100644 +--- a/llvm/include/llvm/IR/Instructions.h ++++ b/llvm/include/llvm/IR/Instructions.h +@@ -956,13 +956,9 @@ public: + const Twine &NameStr = "", + Instruction *InsertBefore = nullptr) { + unsigned Values = 1 + unsigned(IdxList.size()); +- if (!PointeeType) { +- PointeeType = +- cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(); +- } else { +- assert(cast<PointerType>(Ptr->getType()->getScalarType()) +- ->isOpaqueOrPointeeTypeMatches(PointeeType)); +- } ++ assert(PointeeType && "Must specify element type"); ++ assert(cast<PointerType>(Ptr->getType()->getScalarType()) ++ ->isOpaqueOrPointeeTypeMatches(PointeeType)); + return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values, + NameStr, InsertBefore); + } +@@ -972,13 +968,9 @@ public: + const Twine &NameStr, + BasicBlock *InsertAtEnd) { + unsigned Values = 1 + unsigned(IdxList.size()); +- if (!PointeeType) { +- PointeeType = +- cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(); +- } else { +- assert(cast<PointerType>(Ptr->getType()->getScalarType()) +- ->isOpaqueOrPointeeTypeMatches(PointeeType)); +- } ++ assert(PointeeType && "Must specify element type"); ++ assert(cast<PointerType>(Ptr->getType()->getScalarType()) ++ ->isOpaqueOrPointeeTypeMatches(PointeeType)); + return new (Values) GetElementPtrInst(PointeeType, Ptr, IdxList, Values, + NameStr, InsertAtEnd); + }
