diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2017-04-16 18:35:20 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2017-04-22 02:45:59 +0200 |
commit | ecee06b883a97bbc7be8455580db410e84557320 (patch) | |
tree | 0c009a71c4879199a91ab83b5a140a818d5fced4 | |
parent | 6b867ce28451cdb2b794961e42ed775741fe0b31 (diff) | |
download | aports-ecee06b883a97bbc7be8455580db410e84557320.tar.bz2 aports-ecee06b883a97bbc7be8455580db410e84557320.tar.xz |
main/llvm: remove (in favour of llvm4)
10 files changed, 0 insertions, 1001 deletions
diff --git a/main/llvm/APKBUILD b/main/llvm/APKBUILD deleted file mode 100644 index 4308847314..0000000000 --- a/main/llvm/APKBUILD +++ /dev/null @@ -1,176 +0,0 @@ -# Contributor Travis Tilley <ttilley@gmail.com> -# Maintainer: Travis Tilley <ttilley@gmail.com> -pkgname=llvm -pkgver=3.8.1 -pkgrel=2 -pkgdesc="Low Level Virtual Machine compiler system" -arch="all" -url="http://llvm.org/" -license="UOI-NCSA" -depends_dev="perl" -makedepends="$depends_dev - binutils-dev - bison - chrpath - cmake - file - flex - groff - isl-dev - libffi-dev - make - paxmark - py2-sphinx - python2 - python2-dev - zlib-dev - " -subpackages="$pkgname-static $pkgname-doc $pkgname-dev $pkgname-libs" -source="http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz - llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch - llvm-0002-Fix-build-with-musl-libc.patch - llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch - llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch - llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch - llvm-0006-clone-every-functions-debug-info.patch - llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch - llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch - llvm-0009-nm-workaround.patch - " -builddir="$srcdir/$pkgname-$pkgver.src" - -# ARM has few failures in test suite that we don't care about currently. -case "$CARCH" in - arm*) options="!check";; -esac - -prepare() { - cd "$builddir" - - update_config_sub || return 1 - default_prepare || return 1 - - # Remove some tests that fails. - rm test/tools/llvm-objdump/macho-compact-unwind-x86_64.test \ - test/tools/llvm-objdump/macho-compact-unwind-i386.test \ - test/Transforms/GlobalOpt/alias-used.ll \ - test/tools/llvm-symbolizer/print_context.c -} - -build() { - mkdir -p "$builddir"/build - cd "$builddir"/build - - # Auto-detect it by guessing either. - local ffi_include_dir="$(pkg-config --cflags-only-I libffi | sed 's|^-I||g')" - - cmake -G "Unix Makefiles" -Wno-dev \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_VERBOSE_MAKEFILE=OFF \ - \ - -DFFI_INCLUDE_DIR="$ffi_include_dir" \ - -DLLVM_BINUTILS_INCDIR=/usr/include \ - -DLLVM_BUILD_DOCS=ON \ - -DLLVM_BUILD_EXAMPLES=OFF \ - -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \ - -DLLVM_BUILD_LLVM_DYLIB=ON \ - -DLLVM_BUILD_TESTS=ON \ - -DLLVM_DEFAULT_TARGET_TRIPLE="$CBUILD" \ - -DLLVM_DYLIB_EXPORT_ALL=ON \ - -DLLVM_ENABLE_ASSERTIONS=OFF \ - -DLLVM_ENABLE_CXX1Y=ON \ - -DLLVM_ENABLE_FFI=ON \ - -DLLVM_ENABLE_LIBCXX=OFF \ - -DLLVM_ENABLE_PIC=ON \ - -DLLVM_ENABLE_RTTI=ON \ - -DLLVM_ENABLE_SPHINX=OFF \ - -DLLVM_ENABLE_TERMINFO=ON \ - -DLLVM_ENABLE_ZLIB=ON \ - -DLLVM_HOST_TRIPLE="$CHOST" \ - -DLLVM_INCLUDE_EXAMPLES=OFF \ - -DLLVM_LINK_LLVM_DYLIB=ON \ - -DLLVM_TARGETS_TO_BUILD=all \ - \ - -DSPHINX_WARNINGS_AS_ERRORS=NO \ - "$builddir" || return 1 - - make llvm-tblgen || return 1 - make || return 1 - - paxmark m \ - bin/llvm-rtdyld \ - bin/lli \ - bin/lli-child-target \ - unittests/ExecutionEngine/MCJIT/MCJITTests \ - unittests/Support/SupportTests || return 1 -} - -check() { - cd "$builddir"/build - - make check-llvm -} - -package() { - cd "$builddir"/build - - make DESTDIR="$pkgdir" install || return 1 - - # Remove RPATHs. - file "$pkgdir"/lib/*.so "$pkgdir"/bin/* \ - | awk -F: '$2~/ELF/{print $1}' \ - | xargs -r chrpath -d -} - -static() { - pkgdesc="LLVM static libraries" - - mkdir -p "$subpkgdir"/usr/lib - mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/ -} - -dev() { - default_dev || return 1 - - mv "$pkgdir"/usr/lib/LLVMHello.so "$subpkgdir"/usr/lib/ || return 1 - mv "$pkgdir"/usr/share "$subpkgdir"/usr/ || return 1 -} - -libs() { - pkgdesc="LLVM runtime libraries" - - mkdir -p "$subpkgdir"/usr/lib - mv "$pkgdir"/usr/lib/libLLVM-[0-9]*.so* "$subpkgdir"/usr/lib/ -} - -md5sums="538467e6028bbc9259b1e6e015d25845 llvm-3.8.1.src.tar.xz -10904f363abd86c5c4729e5630ea319c llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch -b0cd098117223159b76e96c3f884536b llvm-0002-Fix-build-with-musl-libc.patch -9cc5050619f764ca9dc842a5ab122290 llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch -1485f62f8b26541a5308b082e9172de9 llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch -ade897d81b5ed522fa07bf045e779cbc llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch -fc5ac9c103c97057526a0c98e965199d llvm-0006-clone-every-functions-debug-info.patch -c06093bf71dba5edc87e3b1a2ea69b40 llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch -1646fff7966d8e727ff20e3891372e4f llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch -785147afd8ab80fa95955a5637b6582f llvm-0009-nm-workaround.patch" -sha256sums="6e82ce4adb54ff3afc18053d6981b6aed1406751b8742582ed50f04b5ab475f9 llvm-3.8.1.src.tar.xz -708db2b21570e48e2c2e155a0c7b7969acecbb82393e306b5b69b0353ac108dd llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch -e1b0fd5f6918d8c8404f3ec4b8d3ab8fbe8dadc2d6011792349b56e5e8ee51e2 llvm-0002-Fix-build-with-musl-libc.patch -fc28356bf0d5fcfe9b99e28f4abbc2f49f50d263b44e428e30f33bf5472747b4 llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch -a12615f51d4ebfc724bd6075dbab62b1632f42c9daed3f1e2d279e4985a7ccda llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch -8c7571fddebd073f81efb11a489def1cfdfbd77ba202fec71d6955c4c52fffa1 llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch -1d109e00c6c904d0af5a4cc49b5fb0a5b895890ebdd3e3a1bc5d517e162afc1f llvm-0006-clone-every-functions-debug-info.patch -18e00ea15872e672a17b4797a88cea0d3fb4d80c5557455cc1e8e8f5ddda13d6 llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch -4c27b11af5d6e2b0c5a2c4e5b3dd49ef1b2aea9f5d55af72f75582de13bffefa llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch -1870f910a6f5f2ba6144bd079ec55ed879fe8fd8b1b1b384935f36da43e5f114 llvm-0009-nm-workaround.patch" -sha512sums="99bbb2cc5f337fd5edf1621f8028c8cb74011aa4af2531018dc05409b27f7b8d0c2f76a00115f677f7c013029d5d9f55d085a5b40433409aac4e9161d53bd366 llvm-3.8.1.src.tar.xz -a97ad7a71ec4878f1a8a335dbc0c161323d957aeb95917b0c4837405c69b53b5f9718094e0e9fd7814c74f44aaa8cff3a9379202964b537c8162a53214621bc5 llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch -4cb3fabbb627b596ce398ed717c66ad20bbea7092ba30751520cc5a63d38e1ac53d23e98a6ad82121ddcf2434383ba5cadbc2990f99a4528e99c6e2160c2f725 llvm-0002-Fix-build-with-musl-libc.patch -19bfb9282455d39d07dbb2b1293b03a45c57d522fbb9c5e58dac034200669628b97e7a90cd4ff5d52d9bb79acfccbef653d8a1140a7f0589ecd6f9b7c4ba0eb6 llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch -f1cbbe0fc39151749ef5423619eb2855905535b2aaab5e6659bacfb14818e56c6b2205f258604db009dcfb1eebd51588a39fc76e1ec5421d68fde1fe65fab550 llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch -199565f088605e758d12fb17ba556463a3b6f523a0629949b3de2f5eb4a34775d7390ff3842f97f30a4828185c611ae8534b2f7beff17fa35bbd928478c2c069 llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch -3f4625dab896f27645a45f2fa75efb2b25ee249379b110e7510b8908e7f16edf14907d431bacd8c5dc2821fd5740f3091c881d31c2d44a6aa415e6d06cd5d7f0 llvm-0006-clone-every-functions-debug-info.patch -3e9de70c000dfbf0e405d85607e10f2c61c608df957c6195560b9f4b583ddf4be30538846d86bee02038b23f9deedd773dccd24c3fee89a942a3e5e1f3d0ad4a llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch -6bb3e8e1b794737b1f411b5656f1a8e13e696c3c0cc8cb57297b371746713948f07c5c4fa93b57f90125f0da82550c1b6973e64575b636092d75fa05694610d2 llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch -11db6f3c5d697bc536c7d053530f7a5572756185e16399c32c31306861b58046ca9bc14b8d8097758c00a8c1a7026cbfb75636c0e697e59c53dda5848f93b006 llvm-0009-nm-workaround.patch" diff --git a/main/llvm/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch b/main/llvm/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch deleted file mode 100644 index c1dfc5bdf7..0000000000 --- a/main/llvm/llvm-0001-Add-Musl-MuslEABI-and-Musl-EABIHF-triples.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 1cec99f6d53d442d8a8c9d2ed9f4a58f8fdc6412 Mon Sep 17 00:00:00 2001 -From: Natanael Copa <ncopa@alpinelinux.org> -Date: Thu, 18 Feb 2016 08:30:07 +0100 -Subject: [PATCH 1/3] Add Musl, MuslEABI and Musl EABIHF triples - ---- - include/llvm/ADT/Triple.h | 11 +++++++++++ - lib/Support/Triple.cpp | 7 +++++++ - lib/Target/ARM/ARMSubtarget.h | 3 +++ - lib/Target/ARM/ARMTargetMachine.cpp | 2 ++ - 4 files changed, 23 insertions(+) - -diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h -index e01db0a..2fc4fc1 100644 ---- a/include/llvm/ADT/Triple.h -+++ b/include/llvm/ADT/Triple.h -@@ -174,6 +174,10 @@ public: - EABIHF, - Android, - -+ Musl, -+ MuslEABI, -+ MuslEABIHF, -+ - MSVC, - Itanium, - Cygnus, -@@ -544,6 +548,13 @@ public: - /// Tests whether the target is Android - bool isAndroid() const { return getEnvironment() == Triple::Android; } - -+ /// Tests whether the target is musl libc -+ bool isMusl() const { -+ return getEnvironment() == Triple::Musl || -+ getEnvironment() == Triple::MuslEABI || -+ getEnvironment() == Triple::MuslEABIHF; -+ } -+ - /// @} - /// @name Mutators - /// @{ -diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp -index 11afcf7..d90a06a 100644 ---- a/lib/Support/Triple.cpp -+++ b/lib/Support/Triple.cpp -@@ -199,6 +199,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) { - case CODE16: return "code16"; - case EABI: return "eabi"; - case EABIHF: return "eabihf"; -+ case Musl: return "musl"; -+ case MuslEABIHF: return "muslgnueabihf"; -+ case MuslEABI: return "muslgnueabi"; - case Android: return "android"; - case MSVC: return "msvc"; - case Itanium: return "itanium"; -@@ -454,6 +457,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { - .StartsWith("code16", Triple::CODE16) - .StartsWith("gnu", Triple::GNU) - .StartsWith("android", Triple::Android) -+ .StartsWith("muslgnueabihf", Triple::MuslEABIHF) -+ .StartsWith("muslgnueabi", Triple::MuslEABI) -+ .StartsWith("musl", Triple::Musl) - .StartsWith("msvc", Triple::MSVC) - .StartsWith("itanium", Triple::Itanium) - .StartsWith("cygnus", Triple::Cygnus) -@@ -1431,6 +1437,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const { - switch (getEnvironment()) { - case llvm::Triple::EABIHF: - case llvm::Triple::GNUEABIHF: -+ case llvm::Triple::MuslEABIHF: - return "arm1176jzf-s"; - default: - return "arm7tdmi"; -diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h -index 4d54e57..7ed7ab7 100644 ---- a/lib/Target/ARM/ARMSubtarget.h -+++ b/lib/Target/ARM/ARMSubtarget.h -@@ -405,8 +405,10 @@ public: - bool isTargetEHABICompatible() const { - return (TargetTriple.getEnvironment() == Triple::EABI || - TargetTriple.getEnvironment() == Triple::GNUEABI || -+ TargetTriple.getEnvironment() == Triple::MuslEABI || - TargetTriple.getEnvironment() == Triple::EABIHF || - TargetTriple.getEnvironment() == Triple::GNUEABIHF || -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF || - isTargetAndroid()) && - !isTargetDarwin() && !isTargetWindows(); - } -@@ -415,6 +417,7 @@ public: - // FIXME: this is invalid for WindowsCE - return TargetTriple.getEnvironment() == Triple::GNUEABIHF || - TargetTriple.getEnvironment() == Triple::EABIHF || -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF || - isTargetWindows() || isAAPCS16_ABI(); - } - bool isTargetAndroid() const { return TargetTriple.isAndroid(); } -diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp -index fca1901..25f5cf9 100644 ---- a/lib/Target/ARM/ARMTargetMachine.cpp -+++ b/lib/Target/ARM/ARMTargetMachine.cpp -@@ -101,6 +101,8 @@ computeTargetABI(const Triple &TT, StringRef CPU, - case llvm::Triple::GNUEABIHF: - case llvm::Triple::EABIHF: - case llvm::Triple::EABI: -+ case llvm::Triple::MuslEABI: -+ case llvm::Triple::MuslEABIHF: - TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS; - break; - case llvm::Triple::GNU: --- -2.7.3 - diff --git a/main/llvm/llvm-0002-Fix-build-with-musl-libc.patch b/main/llvm/llvm-0002-Fix-build-with-musl-libc.patch deleted file mode 100644 index 1a69080866..0000000000 --- a/main/llvm/llvm-0002-Fix-build-with-musl-libc.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 5c571082fdaf61f6df19d9b7137dc26d71334058 Mon Sep 17 00:00:00 2001 -From: Natanael Copa <ncopa@alpinelinux.org> -Date: Thu, 18 Feb 2016 10:33:04 +0100 -Subject: [PATCH 2/3] Fix build with musl libc - -On musl libc the fopen64 and fopen are the same thing, but for -compatibility they have a `#define fopen64 fopen`. Same applies for -fseek64, fstat64, fstatvfs64, ftello64, lstat64, stat64 and tmpfile64. ---- - include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h -index 7becdf0..7f14427 100644 ---- a/include/llvm/Analysis/TargetLibraryInfo.h -+++ b/include/llvm/Analysis/TargetLibraryInfo.h -@@ -18,6 +18,15 @@ - #include "llvm/IR/Module.h" - #include "llvm/Pass.h" - -+#undef fopen64 -+#undef fseeko64 -+#undef fstat64 -+#undef fstatvfs64 -+#undef ftello64 -+#undef lstat64 -+#undef stat64 -+#undef tmpfile64 -+ - namespace llvm { - /// VecDesc - Describes a possible vectorization of a function. - /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized --- -2.7.3 - diff --git a/main/llvm/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch b/main/llvm/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch deleted file mode 100644 index d5d7f07b5e..0000000000 --- a/main/llvm/llvm-0003-Fix-DynamicLibrary-to-build-with-musl-libc.patch +++ /dev/null @@ -1,33 +0,0 @@ -From d12ecb83d01dcb580dd94f4d57828f33d3eb4c35 Mon Sep 17 00:00:00 2001 -From: Natanael Copa <ncopa@alpinelinux.org> -Date: Thu, 18 Feb 2016 15:33:21 +0100 -Subject: [PATCH 3/3] Fix DynamicLibrary to build with musl libc - -stdin/out/err is part of the libc and not the kernel so we check for the -specific libc that does the unexpected instead of linux. - -This is needed for making it build with musl libc. ---- - lib/Support/DynamicLibrary.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp -index 9a7aeb5..0c1c8f8 100644 ---- a/lib/Support/DynamicLibrary.cpp -+++ b/lib/Support/DynamicLibrary.cpp -@@ -140,10 +140,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { - #define EXPLICIT_SYMBOL(SYM) \ - if (!strcmp(symbolName, #SYM)) return &SYM - --// On linux we have a weird situation. The stderr/out/in symbols are both -+// On GNU libc we have a weird situation. The stderr/out/in symbols are both - // macros and global variables because of standards requirements. So, we - // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. --#if defined(__linux__) and !defined(__ANDROID__) -+#if defined(__GLIBC__) - { - EXPLICIT_SYMBOL(stderr); - EXPLICIT_SYMBOL(stdout); --- -2.7.3 - diff --git a/main/llvm/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch b/main/llvm/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch deleted file mode 100644 index 9945bf3567..0000000000 --- a/main/llvm/llvm-0004-Fix-ScalarEvolutionExpander-step-scaling-bug.patch +++ /dev/null @@ -1,99 +0,0 @@ -From c8ce9e59a883f452bc538b5f16fb83649472dc3e Mon Sep 17 00:00:00 2001 -From: Keno Fischer <kfischer@college.harvard.edu> -Date: Wed, 13 Jul 2016 01:28:12 +0000 -Subject: [PATCH] Fix ScalarEvolutionExpander step scaling bug - -The expandAddRecExprLiterally function incorrectly transforms -`[Start + Step * X]` into `Step * [Start + X]` instead of the correct -transform of `[Step * X] + Start`. - -This caused https://github.com/JuliaLang/julia/issues/14704#issuecomment-174126219 -due to what appeared to be sufficiently complicated loop interactions. - -Patch by Jameson Nash (jameson@juliacomputing.com). - -Reviewers: sanjoy -Differential Revision: http://reviews.llvm.org/D16505 - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275239 91177308-0d34-0410-b5e6-96231b3b80d8 - -Alpine maintainer notes: -This patch replaces deps/patches/llvm-3.7.1_3.patch from Julia. ---- - lib/Analysis/ScalarEvolutionExpander.cpp | 7 ++++ - .../ScalarEvolution/incorrect-offset-scaling.ll | 48 ++++++++++++++++++++++ - 2 files changed, 55 insertions(+) - create mode 100644 test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll - -diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp -index 7716435..77e4ec7 100644 ---- a/lib/Analysis/ScalarEvolutionExpander.cpp -+++ b/lib/Analysis/ScalarEvolutionExpander.cpp -@@ -1288,6 +1288,13 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) { - if (!SE.dominates(Step, L->getHeader())) { - PostLoopScale = Step; - Step = SE.getConstant(Normalized->getType(), 1); -+ if (!Start->isZero()) { -+ // The normalization below assumes that Start is constant zero, so if -+ // it isn't re-associate Start to PostLoopOffset. -+ assert(!PostLoopOffset && "Start not-null but PostLoopOffset set?"); -+ PostLoopOffset = Start; -+ Start = SE.getConstant(Normalized->getType(), 0); -+ } - Normalized = - cast<SCEVAddRecExpr>(SE.getAddRecExpr( - Start, Step, Normalized->getLoop(), -diff --git a/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll b/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll -new file mode 100644 -index 0000000..7ffb093 ---- /dev/null -+++ b/test/Analysis/ScalarEvolution/incorrect-offset-scaling.ll -@@ -0,0 +1,48 @@ -+; RUN: opt -S -loop-reduce < %s | FileCheck %s -+ -+target triple = "x86_64-unknown-unknown" -+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" -+ -+define void @incorrect_offset_scaling(i64, i64*) { -+top: -+ br label %L -+ -+L: ; preds = %idxend.10, %idxend, %L2, %top -+ br i1 undef, label %L, label %L1 -+ -+L1: ; preds = %L1.preheader, %L2 -+ %r13 = phi i64 [ %r1, %L2 ], [ 1, %L ] -+; CHECK: %lsr.iv = phi i64 [ 0, %L{{[^ ]+}} ], [ %lsr.iv.next, %L2 ] -+; CHECK-NOT: %lsr.iv = phi i64 [ -1, %L{{[^ ]+}} ], [ %lsr.iv.next, %L2 ] -+; CHECK: br -+ %r0 = add i64 %r13, -1 -+ br label %idxend.8 -+ -+L2: ; preds = %idxend.8 -+ %r1 = add i64 %r13, 1 -+ br i1 undef, label %L, label %L1 -+ -+if6: ; preds = %idxend.8 -+ %r2 = add i64 %0, -1 -+ %r3 = load i64, i64* %1, align 8 -+; CHECK-NOT: %r2 -+; CHECK: %r3 = load i64 -+ br label %ib -+ -+idxend.8: ; preds = %L1 -+ br i1 undef, label %if6, label %L2 -+ -+ib: ; preds = %if6 -+ %r4 = mul i64 %r3, %r0 -+ %r5 = add i64 %r2, %r4 -+ %r6 = icmp ult i64 %r5, undef -+; CHECK %2 = mul i64 %lsr.iv, %r3 -+; CHECK %3 = add i64 %1, -1 -+; CHECK %4 = add i64 %0, %r3 -+; CHECK %r6 -+ %r7 = getelementptr i64, i64* undef, i64 %r5 -+ store i64 1, i64* %r7, align 8 -+; CHECK %5 = mul i64 %lsr.iv, %r3 -+; CHECK %6 = add i64 %5, -1 -+ br label %L -+} diff --git a/main/llvm/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch b/main/llvm/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch deleted file mode 100644 index 7f891b66db..0000000000 --- a/main/llvm/llvm-0005-optimize-store-of-bitcast-from-vector-to-aggregate.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 1ca1fcaa5b4c75a65a202badfd5df8240a36ca0f Mon Sep 17 00:00:00 2001 -From: "Arch D. Robison" <arch.robison@intel.com> -Date: Mon, 25 Apr 2016 22:22:39 +0000 -Subject: [PATCH] Optimize store of "bitcast" from vector to aggregate. - -This patch is what was the "instcombine" portion of D14185, with an additional -test added (see julia_pseudovec in test/Transforms/InstCombine/insert-val-extract-elem.ll). -The patch causes instcombine to replace sequences of extractelement-insertvalue-store -that act essentially like a bitcast followed by a store. - -Differential review: http://reviews.llvm.org/D14260 - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267482 91177308-0d34-0410-b5e6-96231b3b80d8 - -Alpine maintainer notes: - - Updated for llvm 3.8.1. - - This patch replaces llvm-D14260.patch from Julia. ---- - .../InstCombine/InstCombineLoadStoreAlloca.cpp | 60 ++++++++++++++++++ - .../InstCombine/insert-val-extract-elem.ll | 74 ++++++++++++++++++++++ - 2 files changed, 134 insertions(+) - create mode 100644 test/Transforms/InstCombine/insert-val-extract-elem.ll - -diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -index 96f0908..0ee6045 100644 ---- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -+++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -@@ -913,6 +913,61 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { - return nullptr; - } - -+/// \brief Look for extractelement/insertvalue sequence that acts like a bitcast. -+/// -+/// \returns underlying value that was "cast", or nullptr otherwise. -+/// -+/// For example, if we have: -+/// -+/// %E0 = extractelement <2 x double> %U, i32 0 -+/// %V0 = insertvalue [2 x double] undef, double %E0, 0 -+/// %E1 = extractelement <2 x double> %U, i32 1 -+/// %V1 = insertvalue [2 x double] %V0, double %E1, 1 -+/// -+/// and the layout of a <2 x double> is isomorphic to a [2 x double], -+/// then %V1 can be safely approximated by a conceptual "bitcast" of %U. -+/// Note that %U may contain non-undef values where %V1 has undef. -+static Value *likeBitCastFromVector(InstCombiner &IC, Value *V) { -+ Value *U = nullptr; -+ while (auto *IV = dyn_cast<InsertValueInst>(V)) { -+ auto *E = dyn_cast<ExtractElementInst>(IV->getInsertedValueOperand()); -+ if (!E) -+ return nullptr; -+ auto *W = E->getVectorOperand(); -+ if (!U) -+ U = W; -+ else if (U != W) -+ return nullptr; -+ auto *CI = dyn_cast<ConstantInt>(E->getIndexOperand()); -+ if (!CI || IV->getNumIndices() != 1 || CI->getZExtValue() != *IV->idx_begin()) -+ return nullptr; -+ V = IV->getAggregateOperand(); -+ } -+ if (!isa<UndefValue>(V) ||!U) -+ return nullptr; -+ -+ auto *UT = cast<VectorType>(U->getType()); -+ auto *VT = V->getType(); -+ // Check that types UT and VT are bitwise isomorphic. -+ const auto &DL = IC.getDataLayout(); -+ if (DL.getTypeStoreSizeInBits(UT) != DL.getTypeStoreSizeInBits(VT)) { -+ return nullptr; -+ } -+ if (auto *AT = dyn_cast<ArrayType>(VT)) { -+ if (AT->getNumElements() != UT->getNumElements()) -+ return nullptr; -+ } else { -+ auto *ST = cast<StructType>(VT); -+ if (ST->getNumElements() != UT->getNumElements()) -+ return nullptr; -+ for (const auto *EltT : ST->elements()) { -+ if (EltT != UT->getElementType()) -+ return nullptr; -+ } -+ } -+ return U; -+} -+ - /// \brief Combine stores to match the type of value being stored. - /// - /// The core idea here is that the memory does not have any intrinsic type and -@@ -924,6 +979,11 @@ - return true; - } - -+ if (Value *U = likeBitCastFromVector(IC, V)) { -+ combineStoreToNewValue(IC, SI, U); -+ return true; -+ } -+ - // FIXME: We should also canonicalize loads of vectors when their elements are - // cast to other types. - return false; -diff --git a/test/Transforms/InstCombine/insert-val-extract-elem.ll b/test/Transforms/InstCombine/insert-val-extract-elem.ll -new file mode 100644 -index 0000000..db7b403 ---- /dev/null -+++ b/test/Transforms/InstCombine/insert-val-extract-elem.ll -@@ -0,0 +1,74 @@ -+; RUN: opt -S -instcombine %s | FileCheck %s -+ -+; CHECK-LABEL: julia_2xdouble -+; CHECK-NOT: insertvalue -+; CHECK-NOT: extractelement -+; CHECK: store <2 x double> -+define void @julia_2xdouble([2 x double]* sret, <2 x double>*) { -+top: -+ %x = load <2 x double>, <2 x double>* %1 -+ %x0 = extractelement <2 x double> %x, i32 0 -+ %i0 = insertvalue [2 x double] undef, double %x0, 0 -+ %x1 = extractelement <2 x double> %x, i32 1 -+ %i1 = insertvalue [2 x double] %i0, double %x1, 1 -+ store [2 x double] %i1, [2 x double]* %0, align 4 -+ ret void -+} -+ -+; Test with two inserts to the same index -+; CHECK-LABEL: julia_2xi64 -+; CHECK-NOT: insertvalue -+; CHECK-NOT: extractelement -+; CHECK: store <2 x i64> -+define void @julia_2xi64([2 x i64]* sret, <2 x i64>*) { -+top: -+ %x = load <2 x i64>, <2 x i64>* %1 -+ %x0 = extractelement <2 x i64> %x, i32 1 -+ %i0 = insertvalue [2 x i64] undef, i64 %x0, 0 -+ %x1 = extractelement <2 x i64> %x, i32 1 -+ %i1 = insertvalue [2 x i64] %i0, i64 %x1, 1 -+ %x2 = extractelement <2 x i64> %x, i32 0 -+ %i2 = insertvalue [2 x i64] %i1, i64 %x2, 0 -+ store [2 x i64] %i2, [2 x i64]* %0, align 4 -+ ret void -+} -+ -+; CHECK-LABEL: julia_4xfloat -+; CHECK-NOT: insertvalue -+; CHECK-NOT: extractelement -+; CHECK: store <4 x float> -+define void @julia_4xfloat([4 x float]* sret, <4 x float>*) { -+top: -+ %x = load <4 x float>, <4 x float>* %1 -+ %x0 = extractelement <4 x float> %x, i32 0 -+ %i0 = insertvalue [4 x float] undef, float %x0, 0 -+ %x1 = extractelement <4 x float> %x, i32 1 -+ %i1 = insertvalue [4 x float] %i0, float %x1, 1 -+ %x2 = extractelement <4 x float> %x, i32 2 -+ %i2 = insertvalue [4 x float] %i1, float %x2, 2 -+ %x3 = extractelement <4 x float> %x, i32 3 -+ %i3 = insertvalue [4 x float] %i2, float %x3, 3 -+ store [4 x float] %i3, [4 x float]* %0, align 4 -+ ret void -+} -+ -+%pseudovec = type { float, float, float, float } -+ -+; CHECK-LABEL: julia_pseudovec -+; CHECK-NOT: insertvalue -+; CHECK-NOT: extractelement -+; CHECK: store <4 x float> -+define void @julia_pseudovec(%pseudovec* sret, <4 x float>*) { -+top: -+ %x = load <4 x float>, <4 x float>* %1 -+ %x0 = extractelement <4 x float> %x, i32 0 -+ %i0 = insertvalue %pseudovec undef, float %x0, 0 -+ %x1 = extractelement <4 x float> %x, i32 1 -+ %i1 = insertvalue %pseudovec %i0, float %x1, 1 -+ %x2 = extractelement <4 x float> %x, i32 2 -+ %i2 = insertvalue %pseudovec %i1, float %x2, 2 -+ %x3 = extractelement <4 x float> %x, i32 3 -+ %i3 = insertvalue %pseudovec %i2, float %x3, 3 -+ store %pseudovec %i3, %pseudovec* %0, align 4 -+ ret void -+} diff --git a/main/llvm/llvm-0006-clone-every-functions-debug-info.patch b/main/llvm/llvm-0006-clone-every-functions-debug-info.patch deleted file mode 100644 index 567ddcadd4..0000000000 --- a/main/llvm/llvm-0006-clone-every-functions-debug-info.patch +++ /dev/null @@ -1,129 +0,0 @@ -From 11adcc4de0797c83e61ae0240927f0bafcf041a9 Mon Sep 17 00:00:00 2001 -From: Keno Fischer <kfischer@college.harvard.edu> -Date: Sat, 13 Feb 2016 02:04:29 +0000 -Subject: [PATCH] [Cloning] Clone every Function's Debug Info - -Summary: -Export the CloneDebugInfoMetadata utility, which clones all debug info -associated with a function into the first module. Also use this function -in CloneModule on each function we clone (the CloneFunction entrypoint -already does this). - -Without this, cloning a module will lead to DI quality regressions, -especially since r252219 reversed the Function <-> DISubprogram edge -(before we could get lucky and have this edge preserved if the -DISubprogram itself was, e.g. due to location metadata). - -This was verified to fix missing debug information in julia and -a unittest to verify the new behavior is included. - -Patch by Yichao Yu! Thanks! - -Reviewers: loladiro, pcc -Differential Revision: http://reviews.llvm.org/D17165 - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260791 91177308-0d34-0410-b5e6-96231b3b80d8 - -Alpine maintainer notes: - - Corresponds to llvm-D17165-D18583.patch in Julia. ---- - include/llvm/Transforms/Utils/Cloning.h | 5 +++++ - lib/Transforms/Utils/CloneFunction.cpp | 4 ++-- - lib/Transforms/Utils/CloneModule.cpp | 1 + - unittests/Transforms/Utils/Cloning.cpp | 25 +++++++++++++++++++++++++ - 4 files changed, 33 insertions(+), 2 deletions(-) - -diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h -index 4f006f2..0bae2bd 100644 ---- a/include/llvm/Transforms/Utils/Cloning.h -+++ b/include/llvm/Transforms/Utils/Cloning.h -@@ -130,6 +130,11 @@ Function *CloneFunction(const Function *F, ValueToValueMapTy &VMap, - bool ModuleLevelChanges, - ClonedCodeInfo *CodeInfo = nullptr); - -+/// Clone the module-level debug info associated with OldFunc. The cloned data -+/// will point to NewFunc instead. -+void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -+ ValueToValueMapTy &VMap); -+ - /// Clone OldFunc into NewFunc, transforming the old arguments into references - /// to VMap values. Note that if NewFunc already has basic blocks, the ones - /// cloned into it will be added to the end of the function. This function -diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp -index 6454afb..8b5692a 100644 ---- a/lib/Transforms/Utils/CloneFunction.cpp -+++ b/lib/Transforms/Utils/CloneFunction.cpp -@@ -187,8 +187,8 @@ static void AddOperand(DICompileUnit *CU, DISubprogramArray SPs, - - // Clone the module-level debug info associated with OldFunc. The cloned data - // will point to NewFunc instead. --static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -- ValueToValueMapTy &VMap) { -+void llvm::CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -+ ValueToValueMapTy &VMap) { - DebugInfoFinder Finder; - Finder.processModule(*OldFunc->getParent()); - -diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp -index 53de62a..b16a02a 100644 ---- a/lib/Transforms/Utils/CloneModule.cpp -+++ b/lib/Transforms/Utils/CloneModule.cpp -@@ -136,6 +136,7 @@ std::unique_ptr<Module> llvm::CloneModule( - VMap[&*J] = &*DestI++; - } - -+ CloneDebugInfoMetadata(F, &*I, VMap); - SmallVector<ReturnInst*, 8> Returns; // Ignore returns cloned. - CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns); - } -diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp -index 25e322e..b761e4e 100644 ---- a/unittests/Transforms/Utils/Cloning.cpp -+++ b/unittests/Transforms/Utils/Cloning.cpp -@@ -423,6 +423,7 @@ class CloneModule : public ::testing::Test { - void SetupModule() { OldM = new Module("", C); } - - void CreateOldModule() { -+ DIBuilder DBuilder(*OldM); - IRBuilder<> IBuilder(C); - - auto *FuncType = FunctionType::get(Type::getVoidTy(C), false); -@@ -431,9 +432,25 @@ class CloneModule : public ::testing::Test { - auto *F = - Function::Create(FuncType, GlobalValue::PrivateLinkage, "f", OldM); - F->setPersonalityFn(PersFn); -+ -+ // Create debug info -+ auto *File = DBuilder.createFile("filename.c", "/file/dir/"); -+ DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None); -+ DISubroutineType *DFuncType = DBuilder.createSubroutineType(ParamTypes); -+ auto *CU = -+ DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c", -+ "/file/dir", "CloneModule", false, "", 0); -+ // Function DI -+ auto *Subprogram = DBuilder.createFunction(CU, "f", "f", File, 4, DFuncType, -+ true, true, 3, 0, false); -+ F->setSubprogram(Subprogram); -+ - auto *Entry = BasicBlock::Create(C, "", F); - IBuilder.SetInsertPoint(Entry); - IBuilder.CreateRetVoid(); -+ -+ // Finalize the debug info -+ DBuilder.finalize(); - } - - void CreateNewModule() { NewM = llvm::CloneModule(OldM).release(); } -@@ -447,4 +464,12 @@ TEST_F(CloneModule, Verify) { - EXPECT_FALSE(verifyModule(*NewM)); - } - -+TEST_F(CloneModule, Subprogram) { -+ Function *NewF = NewM->getFunction("f"); -+ DISubprogram *SP = NewF->getSubprogram(); -+ EXPECT_TRUE(SP != nullptr); -+ EXPECT_EQ(SP->getName(), "f"); -+ EXPECT_EQ(SP->getFile()->getFilename(), "filename.c"); -+ EXPECT_EQ(SP->getLine(), (unsigned)4); -+} - } diff --git a/main/llvm/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch b/main/llvm/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch deleted file mode 100644 index 0930c28e8f..0000000000 --- a/main/llvm/llvm-0007-reduce-complexity-of-debug-info-clonning-and-fix-correctness.patch +++ /dev/null @@ -1,102 +0,0 @@ -From af289e04413504c3bdc252e08c3fe17bf7ea6dc8 Mon Sep 17 00:00:00 2001 -From: Peter Collingbourne <peter@pcc.me.uk> -Date: Wed, 30 Mar 2016 22:05:13 +0000 -Subject: [PATCH] Cloning: Reduce complexity of debug info cloning and fix - correctness issue. - -Commit r260791 contained an error in that it would introduce a cross-module -reference in the old module. It also introduced O(N^2) complexity in the -module cloner by requiring the entire module to be visited for each function. -Fix both of these problems by avoiding use of the CloneDebugInfoMetadata -function (which is only designed to do intra-module cloning) and cloning -function-attached metadata in the same way that we clone all other metadata. - -Differential Revision: http://reviews.llvm.org/D18583 - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264935 91177308-0d34-0410-b5e6-96231b3b80d8 - -Alpine maintainer notes: - - Corresponds to llvm-D17165-D18583.patch in Julia. ---- - include/llvm/Transforms/Utils/Cloning.h | 5 ----- - lib/Transforms/Utils/CloneFunction.cpp | 13 +++++++++++-- - lib/Transforms/Utils/CloneModule.cpp | 1 - - unittests/Transforms/Utils/Cloning.cpp | 6 ++++++ - 4 files changed, 17 insertions(+), 8 deletions(-) - -diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h -index 0bae2bd..4f006f2 100644 ---- a/include/llvm/Transforms/Utils/Cloning.h -+++ b/include/llvm/Transforms/Utils/Cloning.h -@@ -130,11 +130,6 @@ Function *CloneFunction(const Function *F, ValueToValueMapTy &VMap, - bool ModuleLevelChanges, - ClonedCodeInfo *CodeInfo = nullptr); - --/// Clone the module-level debug info associated with OldFunc. The cloned data --/// will point to NewFunc instead. --void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -- ValueToValueMapTy &VMap); -- - /// Clone OldFunc into NewFunc, transforming the old arguments into references - /// to VMap values. Note that if NewFunc already has basic blocks, the ones - /// cloned into it will be added to the end of the function. This function -diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp -index 05b0a17..8e1715a 100644 ---- a/lib/Transforms/Utils/CloneFunction.cpp -+++ b/lib/Transforms/Utils/CloneFunction.cpp -@@ -119,6 +119,15 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, - .addAttributes(NewFunc->getContext(), AttributeSet::FunctionIndex, - OldAttrs.getFnAttributes())); - -+ SmallVector<std::pair<unsigned, MDNode *>, 1> MDs; -+ OldFunc->getAllMetadata(MDs); -+ for (auto MD : MDs) -+ NewFunc->setMetadata( -+ MD.first, -+ MapMetadata(MD.second, VMap, -+ ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges, -+ TypeMapper, Materializer)); -+ - // Loop over all of the basic blocks in the function, cloning them as - // appropriate. Note that we save BE this way in order to handle cloning of - // recursive functions into themselves. -@@ -187,8 +196,8 @@ static void AddOperand(DICompileUnit *CU, DISubprogramArray SPs, - - // Clone the module-level debug info associated with OldFunc. The cloned data - // will point to NewFunc instead. --void llvm::CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -- ValueToValueMapTy &VMap) { -+static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc, -+ ValueToValueMapTy &VMap) { - DebugInfoFinder Finder; - Finder.processModule(*OldFunc->getParent()); - -diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp -index 494e275..929f51b 100644 ---- a/lib/Transforms/Utils/CloneModule.cpp -+++ b/lib/Transforms/Utils/CloneModule.cpp -@@ -138,7 +138,6 @@ std::unique_ptr<Module> llvm::CloneModule( - VMap[&*J] = &*DestI++; - } - -- CloneDebugInfoMetadata(F, &*I, VMap); - SmallVector<ReturnInst*, 8> Returns; // Ignore returns cloned. - CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns); - } -diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp -index b761e4e..f06a20f 100644 ---- a/unittests/Transforms/Utils/Cloning.cpp -+++ b/unittests/Transforms/Utils/Cloning.cpp -@@ -464,6 +464,12 @@ TEST_F(CloneModule, Verify) { - EXPECT_FALSE(verifyModule(*NewM)); - } - -+TEST_F(CloneModule, OldModuleUnchanged) { -+ DebugInfoFinder Finder; -+ Finder.processModule(*OldM); -+ EXPECT_EQ(1U, Finder.subprogram_count()); -+} -+ - TEST_F(CloneModule, Subprogram) { - Function *NewF = NewM->getFunction("f"); - DISubprogram *SP = NewF->getSubprogram(); diff --git a/main/llvm/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch b/main/llvm/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch deleted file mode 100644 index b66584dc9a..0000000000 --- a/main/llvm/llvm-0008-dont-widen-metadata-on-store-to-load-forwarding.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 3c80c2658022201214241e9229ac35097cc476d2 Mon Sep 17 00:00:00 2001 -From: Eli Friedman <eli.friedman@gmail.com> -Date: Thu, 16 Jun 2016 02:33:42 +0000 -Subject: [PATCH] [InstCombine] Don't widen metadata on store-to-load - forwarding - -The original check for load CSE or store-to-load forwarding is wrong -when the forwarded stored value happened to be a load. - -Ref https://github.com/JuliaLang/julia/issues/16894 - -Differential Revision: http://reviews.llvm.org/D21271 - -Patch by Yichao Yu! - -git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272868 91177308-0d34-0410-b5e6-96231b3b80d8 - -Alpine maintainer notes: - - Updated for llvm 3.8.1. - - Corresponds to llvm-D21271-instcombine-tbaa-3.8.patch in Julia. ---- - include/llvm/Analysis/Loads.h | 3 ++- - lib/Analysis/Loads.cpp | 5 ++++- - .../InstCombine/InstCombineLoadStoreAlloca.cpp | 6 ++++-- - test/Transforms/InstCombine/tbaa-store-to-load.ll | 17 +++++++++++++++++ - 4 files changed, 27 insertions(+), 4 deletions(-) - create mode 100644 test/Transforms/InstCombine/tbaa-store-to-load.ll - -diff --git a/include/llvm/Analysis/Loads.h b/include/llvm/Analysis/Loads.h -index e5bd0c8..9d24b7b 100644 ---- a/include/llvm/Analysis/Loads.h -+++ b/include/llvm/Analysis/Loads.h -@@ -82,7 +82,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, - BasicBlock::iterator &ScanFrom, - unsigned MaxInstsToScan = DefMaxInstsToScan, - AliasAnalysis *AA = nullptr, -- AAMDNodes *AATags = nullptr); -+ AAMDNodes *AATags = nullptr, -+ bool *IsLoadCSE = nullptr); - - } - -diff --git a/lib/Analysis/Loads.cpp b/lib/Analysis/Loads.cpp -index dce243c..7d3fd59 100644 ---- a/lib/Analysis/Loads.cpp -+++ b/lib/Analysis/Loads.cpp -@@ -322,7 +322,8 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden, - Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, - BasicBlock::iterator &ScanFrom, - unsigned MaxInstsToScan, -- AliasAnalysis *AA, AAMDNodes *AATags) { -+ AliasAnalysis *AA, AAMDNodes *AATags, -+ bool *IsLoadCSE) { - if (MaxInstsToScan == 0) - MaxInstsToScan = ~0U; - -@@ -374,6 +375,8 @@ Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, - - if (AATags) - LI->getAAMetadata(*AATags); -+ if (IsLoadCSE) -+ *IsLoadCSE = true; - return LI; - } - -diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -index 6a5d5a6..d312983 100644 ---- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -+++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp -@@ -800,10 +800,12 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { - // separated by a few arithmetic operations. - BasicBlock::iterator BBI(LI); - AAMDNodes AATags; -+ bool IsLoadCSE = false; - if (Value *AvailableVal = - FindAvailableLoadedValue(Op, LI.getParent(), BBI, -- DefMaxInstsToScan, AA, &AATags)) { -- if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) { -+ DefMaxInstsToScan, AA, &AATags, &IsLoadCSE)) { -+ if (IsLoadCSE) { -+ LoadInst *NLI = cast<LoadInst>(AvailableVal); - unsigned KnownIDs[] = { - LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope, - LLVMContext::MD_noalias, LLVMContext::MD_range, -diff --git a/test/Transforms/InstCombine/tbaa-store-to-load.ll b/test/Transforms/InstCombine/tbaa-store-to-load.ll -new file mode 100644 -index 0000000..707be73 ---- /dev/null -+++ b/test/Transforms/InstCombine/tbaa-store-to-load.ll -@@ -0,0 +1,17 @@ -+; RUN: opt -S -instcombine < %s 2>&1 | FileCheck %s -+ -+define i64 @f(i64* %p1, i64* %p2) { -+top: -+ ; check that the tbaa is preserved -+ ; CHECK-LABEL: @f( -+ ; CHECK: %v1 = load i64, i64* %p1, align 8, !tbaa !0 -+ ; CHECK: store i64 %v1, i64* %p2, align 8 -+ ; CHECK: ret i64 %v1 -+ %v1 = load i64, i64* %p1, align 8, !tbaa !0 -+ store i64 %v1, i64* %p2, align 8 -+ %v2 = load i64, i64* %p2, align 8 -+ ret i64 %v2 -+} -+ -+!0 = !{!1, !1, i64 0} -+!1 = !{!"load_tbaa"} diff --git a/main/llvm/llvm-0009-nm-workaround.patch b/main/llvm/llvm-0009-nm-workaround.patch deleted file mode 100644 index 5755e57ff3..0000000000 --- a/main/llvm/llvm-0009-nm-workaround.patch +++ /dev/null @@ -1,27 +0,0 @@ -From https://llvm.org/bugs/show_bug.cgi?id=24115 - -diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp -index e7ee312..b9e4779 100644 ---- a/tools/llvm-nm/llvm-nm.cpp -+++ b/tools/llvm-nm/llvm-nm.cpp -@@ -486,7 +486,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, - std::string ArchiveName, - std::string ArchitectureName) { - if (!NoSort) { -- std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp; -+ bool (*Cmp)(const NMSymbol &, const NMSymbol &); - if (NumericSort) - Cmp = compareSymbolAddress; - else if (SizeSort) -@@ -495,8 +495,9 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, - Cmp = compareSymbolName; - - if (ReverseSort) -- Cmp = [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); }; -- std::sort(SymbolList.begin(), SymbolList.end(), Cmp); -+ std::sort(SymbolList.begin(), SymbolList.end(), [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); }); -+ else -+ std::sort(SymbolList.begin(), SymbolList.end(), Cmp); - } - - if (!PrintFileName) { |