Commit 163a6bc1 authored by Jakub Jirutka's avatar Jakub Jirutka

testing/llvm3.9: add backported patches for Rust

I've copied these patches from Fedora package:
http://pkgs.fedoraproject.org/cgit/rpms/llvm3.9.git/
parent 0c013c8a
......@@ -17,6 +17,12 @@ source="http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.xz
llvm-fix-build-with-musl-libc.patch
llvm-fix-DynamicLibrary-to-build-with-musl-libc.patch
cmake-fix-libLLVM-name.patch
rust-lang-llvm-pr47.patch
rust-lang-llvm-pr53.patch
rust-lang-llvm-pr54.patch
rust-lang-llvm-pr55.patch
rust-lang-llvm-pr57.patch
"
builddir="$srcdir/$_pkgname-$pkgver.src"
......@@ -53,6 +59,13 @@ prepare() {
# https://bugs.llvm.org//show_bug.cgi?id=31870
rm test/tools/llvm-symbolizer/print_context.c
# Tests added by rust-lang-llvm-pr53.patch, fails for unknown reason.
rm test/CodeGen/ARM/dbg-range-extension.mir
rm test/DebugInfo/MIR/X86/livedebugvalues-limit.mir
# Test added by rust-lang-llvm-pr57.patch, fails for unknown reason.
rm test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
}
build() {
......@@ -182,4 +195,9 @@ _mv() {
sha512sums="50cbe8ee911080f586e77861c442348701bd02e2de0c090c54c34f82ac275ecfcd712af0f41e387c33b4a6057778a4258a27554292fe68ab4af3fd9dd6d90683 llvm-3.9.1.src.tar.xz
4cb3fabbb627b596ce398ed717c66ad20bbea7092ba30751520cc5a63d38e1ac53d23e98a6ad82121ddcf2434383ba5cadbc2990f99a4528e99c6e2160c2f725 llvm-fix-build-with-musl-libc.patch
19bfb9282455d39d07dbb2b1293b03a45c57d522fbb9c5e58dac034200669628b97e7a90cd4ff5d52d9bb79acfccbef653d8a1140a7f0589ecd6f9b7c4ba0eb6 llvm-fix-DynamicLibrary-to-build-with-musl-libc.patch
6d1a716e5aa24e6b9a3acf4cc11e2504b1b01abf574074e9e5617b991de87d5e4e687eb18e85e73d5e632568afe2fc357771c4c96f9e136502071991496fb78c cmake-fix-libLLVM-name.patch"
6d1a716e5aa24e6b9a3acf4cc11e2504b1b01abf574074e9e5617b991de87d5e4e687eb18e85e73d5e632568afe2fc357771c4c96f9e136502071991496fb78c cmake-fix-libLLVM-name.patch
a7c6056bfa3c2b76bbbc1a663ea84e5db6e269d5360afedaad5fdc3279d4732bc414e8c7d3a3f6f0d7b30ed81d8aec3fd2b35377f81db6d441b17b185d8b9bd0 rust-lang-llvm-pr47.patch
3c35bd342de6ec40aef9af8f18cb7d9aa1d2d8e04e9f320fff7df2c828f663cc12715d86946bc6bbc19f2e99b357a07f0fd9a4acce912c9c195c6837675847d5 rust-lang-llvm-pr53.patch
4f5418082b3bb0992a57f7abbd4187d119cf277a573f899b63af93522d823f9195a754adc56ea2a8fb2f5925b39eb82975b522c30cac275c71204cbe6d809271 rust-lang-llvm-pr54.patch
0e38a0390b07a0764bea68dd6a7ea78b9f7b5fd8e292cc7d11f46c0358d68bd40020ca24e0c486d1e74d2a957e1fe79fd3eb29b8ac73a1531b38606605babc43 rust-lang-llvm-pr55.patch
b9f952a71cb4f88f0657f0f2cf17b6102a303f6fab1845f3026d4889a6466b2746694752bc664228e25861abf05b76425a42f05ec4066f1b90cc6ee2deaf0a16 rust-lang-llvm-pr57.patch"
This diff is collapsed.
This diff is collapsed.
From 9b74379db3f9e30516f053138fd3697d42b23164 Mon Sep 17 00:00:00 2001
From: David Majnemer <david.majnemer@gmail.com>
Date: Fri, 7 Oct 2016 01:38:35 +0000
Subject: [rust-lang/llvm#54] [SimplifyCFG] Correctly test for unconditional
branches in GetCaseResults
GetCaseResults assumed that a terminator with one successor was an
unconditional branch. This is not necessarily the case, it could be a
cleanupret.
Strengthen the check by querying whether or not the terminator is
exceptional.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283517 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/Transforms/Utils/SimplifyCFG.cpp | 2 +-
.../SimplifyCFG/X86/switch_to_lookup_table.ll | 60 ++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index c197317ac771..d274f97296dc 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4228,7 +4228,7 @@ GetCaseResults(SwitchInst *SI, ConstantInt *CaseVal, BasicBlock *CaseDest,
++I) {
if (TerminatorInst *T = dyn_cast<TerminatorInst>(I)) {
// If the terminator is a simple branch, continue to the next block.
- if (T->getNumSuccessors() != 1)
+ if (T->getNumSuccessors() != 1 || T->isExceptional())
return false;
Pred = CaseDest;
CaseDest = T->getSuccessor(0);
diff --git a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
index bae8c1dc5a4b..77e355a00528 100644
--- a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
+++ b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -1334,3 +1334,63 @@ cleanup4:
br label %while.body
}
+declare void @throw(i1)
+
+define void @wineh_test(i64 %val) personality i32 (...)* @__CxxFrameHandler3 {
+entry:
+ invoke void @throw(i1 false)
+ to label %unreachable unwind label %cleanup1
+
+unreachable:
+ unreachable
+
+cleanup1:
+ %cleanuppad1 = cleanuppad within none []
+ switch i64 %val, label %cleanupdone2 [
+ i64 0, label %cleanupdone1
+ i64 1, label %cleanupdone1
+ i64 6, label %cleanupdone1
+ ]
+
+cleanupdone1:
+ cleanupret from %cleanuppad1 unwind label %cleanup2
+
+cleanupdone2:
+ cleanupret from %cleanuppad1 unwind label %cleanup2
+
+cleanup2:
+ %phi = phi i1 [ true, %cleanupdone1 ], [ false, %cleanupdone2 ]
+ %cleanuppad2 = cleanuppad within none []
+ call void @throw(i1 %phi) [ "funclet"(token %cleanuppad2) ]
+ unreachable
+}
+
+; CHECK-LABEL: @wineh_test(
+; CHECK: entry:
+; CHECK: invoke void @throw(i1 false)
+; CHECK: to label %[[unreachable:.*]] unwind label %[[cleanup1:.*]]
+
+; CHECK: [[unreachable]]:
+; CHECK: unreachable
+
+; CHECK: [[cleanup1]]:
+; CHECK: %[[cleanuppad1:.*]] = cleanuppad within none []
+; CHECK: switch i64 %val, label %[[cleanupdone2:.*]] [
+; CHECK: i64 0, label %[[cleanupdone1:.*]]
+; CHECK: i64 1, label %[[cleanupdone1]]
+; CHECK: i64 6, label %[[cleanupdone1]]
+; CHECK: ]
+
+; CHECK: [[cleanupdone1]]:
+; CHECK: cleanupret from %[[cleanuppad1]] unwind label %[[cleanup2:.*]]
+
+; CHECK: [[cleanupdone2]]:
+; CHECK: cleanupret from %[[cleanuppad1]] unwind label %[[cleanup2]]
+
+; CHECK: [[cleanup2]]:
+; CHECK: %[[phi:.*]] = phi i1 [ true, %[[cleanupdone1]] ], [ false, %[[cleanupdone2]] ]
+; CHECK: %[[cleanuppad2:.*]] = cleanuppad within none []
+; CHECK: call void @throw(i1 %[[phi]]) [ "funclet"(token %[[cleanuppad2]]) ]
+; CHECK: unreachable
+
+declare i32 @__CxxFrameHandler3(...)
--
2.7.4
From eff5dc809ed54701f2bb3e15c58d01881299cedf Mon Sep 17 00:00:00 2001
From: David Majnemer <david.majnemer@gmail.com>
Date: Tue, 11 Oct 2016 01:00:45 +0000
Subject: [rust-lang/llvm#55] [InstCombine] Transform !range metadata to
!nonnull when combining loads
When combining an integer load with !range metadata that does not include 0 to a pointer load, make sure emit !nonnull metadata on the newly-created pointer load. This prevents the !nonnull metadata from being dropped during a ptrtoint/inttoptr pair.
This fixes PR30597.
Patch by Ariel Ben-Yehuda!
Differential Revision: https://reviews.llvm.org/D25215
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283836 91177308-0d34-0410-b5e6-96231b3b80d8
---
.../InstCombine/InstCombineLoadStoreAlloca.cpp | 12 ++++++--
test/Transforms/InstCombine/PR30597.ll | 32 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 test/Transforms/InstCombine/PR30597.ll
diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index d312983ed51b..26f4e764501a 100644
--- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -380,8 +380,16 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
break;
case LLVMContext::MD_range:
// FIXME: It would be nice to propagate this in some way, but the type
- // conversions make it hard. If the new type is a pointer, we could
- // translate it to !nonnull metadata.
+ // conversions make it hard.
+
+ // If it's a pointer now and the range does not contain 0, make it !nonnull.
+ if (NewTy->isPointerTy()) {
+ unsigned BitWidth = IC.getDataLayout().getTypeSizeInBits(NewTy);
+ if (!getConstantRangeFromMetadata(*N).contains(APInt(BitWidth, 0))) {
+ MDNode *NN = MDNode::get(LI.getContext(), None);
+ NewLoad->setMetadata(LLVMContext::MD_nonnull, NN);
+ }
+ }
break;
}
}
diff --git a/test/Transforms/InstCombine/PR30597.ll b/test/Transforms/InstCombine/PR30597.ll
new file mode 100644
index 000000000000..c0803ed71204
--- /dev/null
+++ b/test/Transforms/InstCombine/PR30597.ll
@@ -0,0 +1,32 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: readonly uwtable
+define i1 @dot_ref_s(i32** noalias nocapture readonly dereferenceable(8)) {
+entry-block:
+ %loadedptr = load i32*, i32** %0, align 8, !nonnull !0
+ %ptrtoint = ptrtoint i32* %loadedptr to i64
+ %inttoptr = inttoptr i64 %ptrtoint to i32*
+ %switchtmp = icmp eq i32* %inttoptr, null
+ ret i1 %switchtmp
+
+; CHECK-LABEL: @dot_ref_s
+; CHECK-NEXT: entry-block:
+; CHECK-NEXT: ret i1 false
+}
+
+; Function Attrs: readonly uwtable
+define i64* @function(i64* noalias nocapture readonly dereferenceable(8)) {
+entry-block:
+ %loaded = load i64, i64* %0, align 8, !range !1
+ %inttoptr = inttoptr i64 %loaded to i64*
+ ret i64* %inttoptr
+; CHECK-LABEL: @function
+; CHECK: %{{.+}} = load i64*, i64** %{{.+}}, align 8, !nonnull
+}
+
+
+!0 = !{}
+!1 = !{i64 1, i64 140737488355327}
--
2.9.3
From 5ac4f80be3e8b5d42475aeaba246455e0016c7ef Mon Sep 17 00:00:00 2001
From: Anthony Ramine <n.oxyde@gmail.com>
Date: Sun, 27 Nov 2016 16:28:12 +0100
Subject: [rust-lang/llvm#57] Backport rL277331
---
lib/Target/AArch64/AArch64InstrInfo.cpp | 3 +
.../MIR/AArch64/inst-size-tlsdesc-callseq.mir | 84 ++++++++++++++++++++++
2 files changed, 87 insertions(+)
create mode 100644 test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
diff --git a/lib/Target/AArch64/AArch64InstrInfo.cpp b/lib/Target/AArch64/AArch64InstrInfo.cpp
index 0aa4708f35ac..d39542a8e4eb 100644
--- a/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -56,6 +56,9 @@ unsigned AArch64InstrInfo::GetInstSizeInBytes(const MachineInstr &MI) const {
case TargetOpcode::IMPLICIT_DEF:
case TargetOpcode::KILL:
return 0;
+ case AArch64::TLSDESC_CALLSEQ:
+ // This gets lowered to an instruction sequence which takes 16 bytes
+ return 16;
}
llvm_unreachable("GetInstSizeInBytes()- Unable to determin insn size");
diff --git a/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
new file mode 100644
index 000000000000..2d966ece768e
--- /dev/null
+++ b/test/CodeGen/MIR/AArch64/inst-size-tlsdesc-callseq.mir
@@ -0,0 +1,84 @@
+# RUN: llc -mtriple=aarch64-unknown -run-pass aarch64-branch-relax -aarch64-tbz-offset-bits=4 %s -o - | FileCheck %s
+--- |
+ ; ModuleID = 'test.ll'
+ source_filename = "test.ll"
+ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+ target triple = "aarch64-unknown"
+
+ @ThreadLocalGlobal = external thread_local local_unnamed_addr global i32, align 8
+
+ define i32 @test_tlsdesc_callseq_length(i32 %in) {
+ %val = and i32 %in, 1
+ %tst = icmp eq i32 %val, 0
+ br i1 %tst, label %true, label %false
+
+ true: ; preds = %0
+ %1 = load i32, i32* @ThreadLocalGlobal, align 8
+ ret i32 %1
+
+ false: ; preds = %0
+ ret i32 0
+ }
+
+...
+---
+# CHECK-LABEL: name:{{.*}}test_tlsdesc_callseq_length
+# If the size of TLSDESC_CALLSEQ is computed correctly, that will push
+# the bb.2.false block too far away from the TBNZW, so the branch will
+# have to be relaxed (note that we're using -aarch64-tbz-offset-bits to
+# constrain the range that can be reached with the TBNZW to something smaller
+# than what TLSDESC_CALLSEQ is lowered to).
+# CHECK: TBZW killed %w0, 0, %bb.1.true
+# CHECK: B %bb.2.false
+name: test_tlsdesc_callseq_length
+alignment: 2
+exposesReturnsTwice: false
+hasInlineAsm: false
+allVRegsAllocated: true
+isSSA: false
+tracksRegLiveness: false
+tracksSubRegLiveness: false
+liveins:
+ - { reg: '%w0' }
+frameInfo:
+ isFrameAddressTaken: false
+ isReturnAddressTaken: false
+ hasStackMap: false
+ hasPatchPoint: false
+ stackSize: 16
+ offsetAdjustment: 0
+ maxAlignment: 16
+ adjustsStack: false
+ hasCalls: true
+ maxCallFrameSize: 0
+ hasOpaqueSPAdjustment: false
+ hasVAStart: false
+ hasMustTailInVarArgFunc: false
+stack:
+ - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '%lr' }
+body: |
+ bb.0 (%ir-block.0):
+ successors: %bb.1.true, %bb.2.false
+ liveins: %w0, %lr
+
+ TBNZW killed %w0, 0, %bb.2.false
+
+ bb.1.true:
+ liveins: %lr
+
+ early-clobber %sp = frame-setup STRXpre killed %lr, %sp, -16 :: (store 8 into %stack.0)
+ frame-setup CFI_INSTRUCTION def_cfa_offset 16
+ frame-setup CFI_INSTRUCTION offset %w30, -16
+ TLSDESC_CALLSEQ target-flags(aarch64-tls) @ThreadLocalGlobal, implicit-def dead %lr, implicit-def %x0, implicit-def dead %x1
+ %x8 = MRS 56962
+ %w0 = LDRWroX killed %x8, killed %x0, 0, 0 :: (load 4 from @ThreadLocalGlobal, align 8)
+ early-clobber %sp, %lr = LDRXpost %sp, 16 :: (load 8 from %stack.0)
+ RET killed %lr, implicit killed %w0
+
+ bb.2.false:
+ liveins: %lr
+
+ %w0 = ORRWrs %wzr, %wzr, 0
+ RET killed %lr, implicit killed %w0
+
+...
--
2.9.3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment