Skip to content

Commit e5e1b01

Browse files
committed
bump LLVM BB version and use assertion builds on CI
Adds patches for: - #27055 - #27080 - #27032
1 parent 0961ee3 commit e5e1b01

File tree

9 files changed

+343
-3
lines changed

9 files changed

+343
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ before_install:
8686
brew rm --force $(brew deps --HEAD julia);
8787
brew install -v --only-dependencies --HEAD julia;
8888
brew install -v staticfloat/juliadeps/libgfortran;
89-
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 BINARYBUILDER_TRIPLET=x86_64-apple-darwin14";
89+
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 BINARYBUILDER_TRIPLET=x86_64-apple-darwin14 BINARYBUILDER_LLVM_RELDBG=1";
9090
BUILDOPTS="$BUILDOPTS USE_BINARYBUILDER_LLVM=1 LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size";
9191
BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1";
9292
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";

Make.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ INSTALL_M := $(JULIAHOME)/contrib/install.sh 755
223223
# BinaryBuilder options
224224
# TODO: Autodiscover triplet
225225
USE_BINARYBUILDER_LLVM := 0
226+
# Use the RelWithDebInfo+Assertions build
227+
BINARYBUILDER_LLVM_RELDBG := 0
226228
BINARYBUILDER_TRIPLET :=
227229

228230
# LLVM Options

contrib/windows/appveyor_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ if [ -n "$USEMSVC" ]; then
204204
else
205205
# Use BinaryBuilder
206206
echo 'USE_BINARYBUILDER_LLVM = 1' >> Make.user
207+
echo 'BINARYBUILDER_LLVM_RELDBG = 1' >> Make.user
207208
echo 'override DEP_LIBS += llvm openlibm' >> Make.user
208209
make check-whitespace
209210
make VERBOSE=1 -C base version_git.jl.phony

deps/Versions.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
LLVM_VER = 6.0.0
2-
LLVM_BB_REL = 2
2+
LLVM_BB_REL = 3
33
PCRE_VER = 10.30
44
DSFMT_VER = 2.2.3
55
LAPACK_VER = 3.5.0

deps/llvm.mk

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ $(eval $(call LLVM_PATCH,llvm-D45008)) # remove for 7.0
488488
$(eval $(call LLVM_PATCH,llvm-D45070)) # remove for 7.0
489489
$(eval $(call LLVM_PATCH,llvm-6.0.0-ifconv-D45819)) # remove for 7.0
490490
$(eval $(call LLVM_PATCH,llvm-D46460))
491+
$(eval $(call LLVM_PATCH,llvm-rL332680)) # remove for 7.0
492+
$(eval $(call LLVM_PATCH,llvm-rL332682)) # remove for 7.0
493+
$(eval $(call LLVM_PATCH,llvm-rL332302)) # remove for 7.0
494+
$(eval $(call LLVM_PATCH,llvm-rL332694)) # remove for 7.0
491495
endif # LLVM_VER
492496

493497
# Remove hardcoded OS X requirements in compilter-rt cmake build
@@ -574,7 +578,13 @@ endif
574578
endif
575579
else # USE_BINARYBUILDER_LLVM
576580
LLVM_BB_URL_BASE := https://github.com/staticfloat/LLVMBuilder/releases/download
577-
LLVM_BB_URL := $(LLVM_BB_URL_BASE)/v$(LLVM_VER)-$(LLVM_BB_REL)/LLVM.$(BINARYBUILDER_TRIPLET).tar.gz
581+
ifneq ($(BINARYBUILDER_LLVM_RELDBG), 1)
582+
LLVM_BB_NAME := LLVM
583+
else
584+
LLVM_BB_NAME := LLVM.dbg
585+
endif
586+
LLVM_BB_URL := $(LLVM_BB_URL_BASE)/v$(LLVM_VER)-$(LLVM_BB_REL)/$(LLVM_BB_NAME).$(BINARYBUILDER_TRIPLET).tar.gz
587+
578588

579589
$(BUILDDIR)/llvm-$(LLVM_VER)-$(LLVM_BB_REL):
580590
mkdir -p $@

deps/patches/llvm-rL332302.patch

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From 98a42416c93477f430012fc1343a393bccab85b2 Mon Sep 17 00:00:00 2001
2+
From: Valentin Churavy <[email protected]>
3+
Date: Mon, 21 May 2018 16:18:54 -0400
4+
Subject: [PATCH] [InstCombine] fix crash due to ignored addrspacecast
5+
6+
Summary:
7+
Part of the InstCombine code for simplifying GEPs looks through
8+
addrspacecasts. However, this was done by updating a variable
9+
also used by the next transformation, for marking GEPs as
10+
inbounds. This led to replacing a GEP with a similar instruction
11+
in a different addrspace, which caused an assertion failure in RAUW.
12+
13+
This caused julia issue https://github.com/JuliaLang/julia/issues/27055
14+
15+
Patch by Jeff Bezanson <[email protected]>
16+
Adapted to 6.0 by Valentin Churavy <[email protected]>
17+
18+
Differential Revision: https://reviews.llvm.org/D46722
19+
20+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332302 91177308-0d34-0410-b5e6-96231b3b80d8
21+
---
22+
.../InstCombine/InstructionCombining.cpp | 5 +++--
23+
test/Transforms/InstCombine/gep-addrspace.ll | 19 +++++++++++++++++++
24+
2 files changed, 22 insertions(+), 2 deletions(-)
25+
26+
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
27+
index 35ed592ac07..8fa7d0684b9 100644
28+
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
29+
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
30+
@@ -1947,13 +1947,14 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
31+
// addrspacecast between types is canonicalized as a bitcast, then an
32+
// addrspacecast. To take advantage of the below bitcast + struct GEP, look
33+
// through the addrspacecast.
34+
+ Value *ASCStrippedPtrOp = PtrOp;
35+
if (AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(PtrOp)) {
36+
// X = bitcast A addrspace(1)* to B addrspace(1)*
37+
// Y = addrspacecast A addrspace(1)* to B addrspace(2)*
38+
// Z = gep Y, <...constant indices...>
39+
// Into an addrspacecasted GEP of the struct.
40+
if (BitCastInst *BC = dyn_cast<BitCastInst>(ASC->getOperand(0)))
41+
- PtrOp = BC;
42+
+ ASCStrippedPtrOp = BC;
43+
}
44+
45+
/// See if we can simplify:
46+
@@ -1961,7 +1962,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
47+
/// Y = gep X, <...constant indices...>
48+
/// into a gep of the original struct. This is important for SROA and alias
49+
/// analysis of unions. If "A" is also a bitcast, wait for A/X to be merged.
50+
- if (BitCastInst *BCI = dyn_cast<BitCastInst>(PtrOp)) {
51+
+ if (BitCastInst *BCI = dyn_cast<BitCastInst>(ASCStrippedPtrOp)) {
52+
Value *Operand = BCI->getOperand(0);
53+
PointerType *OpType = cast<PointerType>(Operand->getType());
54+
unsigned OffsetBits = DL.getPointerTypeSizeInBits(GEP.getType());
55+
diff --git a/test/Transforms/InstCombine/gep-addrspace.ll b/test/Transforms/InstCombine/gep-addrspace.ll
56+
index aa46ea67130..4a4951dee7f 100644
57+
--- a/test/Transforms/InstCombine/gep-addrspace.ll
58+
+++ b/test/Transforms/InstCombine/gep-addrspace.ll
59+
@@ -32,3 +32,22 @@ entry:
60+
ret void
61+
}
62+
63+
+declare void @escape_alloca(i16*)
64+
+
65+
+; check that addrspacecast is not ignored (leading to an assertion failure)
66+
+; when trying to mark a GEP as inbounds
67+
+define { i8, i8 } @inbounds_after_addrspacecast() {
68+
+top:
69+
+; CHECK-LABEL: @inbounds_after_addrspacecast
70+
+ %0 = alloca i16, align 2
71+
+ call void @escape_alloca(i16* %0)
72+
+ %tmpcast = bitcast i16* %0 to [2 x i8]*
73+
+; CHECK: addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
74+
+ %1 = addrspacecast [2 x i8]* %tmpcast to [2 x i8] addrspace(11)*
75+
+; CHECK: getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
76+
+ %2 = getelementptr [2 x i8], [2 x i8] addrspace(11)* %1, i64 0, i64 1
77+
+; CHECK: addrspace(11)
78+
+ %3 = load i8, i8 addrspace(11)* %2, align 1
79+
+ %.fca.1.insert = insertvalue { i8, i8 } zeroinitializer, i8 %3, 1
80+
+ ret { i8, i8 } %.fca.1.insert
81+
+}
82+
--
83+
2.17.0
84+

deps/patches/llvm-rL332680.patch

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Index: llvm/trunk/lib/Target/X86/X86DomainReassignment.cpp
2+
===================================================================
3+
--- a/lib/Target/X86/X86DomainReassignment.cpp
4+
+++ a/lib/Target/X86/X86DomainReassignment.cpp
5+
@@ -262,25 +262,6 @@
6+
}
7+
};
8+
9+
-/// An Instruction Converter which completely deletes an instruction.
10+
-/// For example, IMPLICIT_DEF instructions can be deleted when converting from
11+
-/// GPR to mask.
12+
-class InstrDeleter : public InstrConverterBase {
13+
-public:
14+
- InstrDeleter(unsigned SrcOpcode) : InstrConverterBase(SrcOpcode) {}
15+
-
16+
- bool convertInstr(MachineInstr *MI, const TargetInstrInfo *TII,
17+
- MachineRegisterInfo *MRI) const override {
18+
- assert(isLegal(MI, TII) && "Cannot convert instruction");
19+
- return true;
20+
- }
21+
-
22+
- double getExtraCost(const MachineInstr *MI,
23+
- MachineRegisterInfo *MRI) const override {
24+
- return 0;
25+
- }
26+
-};
27+
-
28+
// Key type to be used by the Instruction Converters map.
29+
// A converter is identified by <destination domain, source opcode>
30+
typedef std::pair<int, unsigned> InstrConverterBaseKeyTy;
31+
@@ -587,7 +568,7 @@
32+
new InstrIgnore(TargetOpcode::PHI);
33+
34+
Converters[{MaskDomain, TargetOpcode::IMPLICIT_DEF}] =
35+
- new InstrDeleter(TargetOpcode::IMPLICIT_DEF);
36+
+ new InstrIgnore(TargetOpcode::IMPLICIT_DEF);
37+
38+
Converters[{MaskDomain, TargetOpcode::INSERT_SUBREG}] =
39+
new InstrReplaceWithCopy(TargetOpcode::INSERT_SUBREG, 2);
40+
Index: llvm/trunk/test/CodeGen/X86/domain-reassignment-implicit-def.ll
41+
===================================================================
42+
--- a/test/CodeGen/X86/domain-reassignment-implicit-def.ll
43+
+++ b/test/CodeGen/X86/domain-reassignment-implicit-def.ll
44+
@@ -0,0 +1,24 @@
45+
+; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
46+
+
47+
+; Check that the X86 Domain Reassignment pass doesn't drop IMPLICIT_DEF nodes,
48+
+; which would later cause crashes (e.g. in LiveVariables) - see PR37430
49+
+define void @domain_reassignment_implicit_def(i1 %cond, i8 *%mem, float %arg) {
50+
+; CHECK: vxorps %xmm1, %xmm1, %xmm1
51+
+; CHECK: vcmpneqss %xmm1, %xmm0, %k0
52+
+; CHECK: kmovb %k0, (%rsi)
53+
+top:
54+
+ br i1 %cond, label %L19, label %L15
55+
+
56+
+L15: ; preds = %top
57+
+ %tmp47 = fcmp une float 0.000000e+00, %arg
58+
+ %tmp48 = zext i1 %tmp47 to i8
59+
+ br label %L21
60+
+
61+
+L19: ; preds = %top
62+
+ br label %L21
63+
+
64+
+L21: ; preds = %L19, %L15
65+
+ %.sroa.0.0 = phi i8 [ undef, %L19 ], [ %tmp48, %L15 ]
66+
+ store i8 %.sroa.0.0, i8* %mem, align 1
67+
+ ret void
68+
+}

deps/patches/llvm-rL332682.patch

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Index: llvm/trunk/lib/Target/X86/X86DomainReassignment.cpp
2+
===================================================================
3+
--- a/lib/Target/X86/X86DomainReassignment.cpp
4+
+++ b/lib/Target/X86/X86DomainReassignment.cpp
5+
@@ -26,6 +26,7 @@
6+
#include "llvm/CodeGen/MachineRegisterInfo.h"
7+
#include "llvm/CodeGen/TargetRegisterInfo.h"
8+
#include "llvm/Support/Debug.h"
9+
+#include "llvm/Support/Printable.h"
10+
#include <bitset>
11+
12+
using namespace llvm;
13+
@@ -291,8 +292,12 @@
14+
/// Domains which this closure can legally be reassigned to.
15+
std::bitset<NumDomains> LegalDstDomains;
16+
17+
+ /// An ID to uniquely identify this closure, even when it gets
18+
+ /// moved around
19+
+ unsigned ID;
20+
+
21+
public:
22+
- Closure(std::initializer_list<RegDomain> LegalDstDomainList) {
23+
+ Closure(unsigned ID, std::initializer_list<RegDomain> LegalDstDomainList) : ID(ID) {
24+
for (RegDomain D : LegalDstDomainList)
25+
LegalDstDomains.set(D);
26+
}
27+
@@ -328,6 +333,10 @@
28+
return Instrs;
29+
}
30+
31+
+ unsigned getID() const {
32+
+ return ID;
33+
+ }
34+
+
35+
};
36+
37+
class X86DomainReassignment : public MachineFunctionPass {
38+
@@ -339,7 +365,7 @@
39+
DenseSet<unsigned> EnclosedEdges;
40+
41+
/// All instructions that are included in some closure.
42+
- DenseMap<MachineInstr *, Closure *> EnclosedInstrs;
43+
+ DenseMap<MachineInstr *, unsigned> EnclosedInstrs;
44+
45+
public:
46+
static char ID;
47+
@@ -416,14 +442,14 @@
48+
void X86DomainReassignment::encloseInstr(Closure &C, MachineInstr *MI) {
49+
auto I = EnclosedInstrs.find(MI);
50+
if (I != EnclosedInstrs.end()) {
51+
- if (I->second != &C)
52+
+ if (I->second != C.getID())
53+
// Instruction already belongs to another closure, avoid conflicts between
54+
// closure and mark this closure as illegal.
55+
C.setAllIllegal();
56+
return;
57+
}
58+
59+
- EnclosedInstrs[MI] = &C;
60+
+ EnclosedInstrs[MI] = C.getID();
61+
C.addInstruction(MI);
62+
63+
// Mark closure as illegal for reassignment to domains, if there is no
64+
@@ -705,6 +731,7 @@
65+
std::vector<Closure> Closures;
66+
67+
// Go over all virtual registers and calculate a closure.
68+
+ unsigned ClosureID = 0;
69+
for (unsigned Idx = 0; Idx < MRI->getNumVirtRegs(); ++Idx) {
70+
unsigned Reg = TargetRegisterInfo::index2VirtReg(Idx);
71+
72+
@@ -717,20 +744,21 @@
73+
continue;
74+
75+
// Calculate closure starting with Reg.
76+
- Closure C({MaskDomain});
77+
+ Closure C(ClosureID++, {MaskDomain});
78+
buildClosure(C, Reg);
79+
80+
// Collect all closures that can potentially be converted.
81+
if (!C.empty() && C.isLegal(MaskDomain))
82+
Closures.push_back(std::move(C));
83+
}
84+
85+
- for (Closure &C : Closures)
86+
+ for (Closure &C : Closures) {
87+
if (isReassignmentProfitable(C, MaskDomain)) {
88+
reassign(C, MaskDomain);
89+
++NumClosuresConverted;
90+
Changed = true;
91+
}
92+
+ }
93+
94+
DeleteContainerSeconds(Converters);
95+
96+
Index: llvm/trunk/test/CodeGen/X86/domain-reassignment-test.ll
97+
===================================================================
98+
--- a/test/CodeGen/X86/domain-reassignment-test.ll
99+
+++ b/test/CodeGen/X86/domain-reassignment-test.ll
100+
@@ -0,0 +1,37 @@
101+
+; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
102+
+; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | llvm-mc
103+
+
104+
+; Check that the X86 domain reassignment pass doesn't introduce an illegal
105+
+; test instruction. See PR37396
106+
+define void @japi1_foo2_34617() {
107+
+pass2:
108+
+ br label %if5
109+
+
110+
+L174:
111+
+ %tmp = icmp sgt <2 x i64> undef, zeroinitializer
112+
+ %tmp1 = icmp sle <2 x i64> undef, undef
113+
+ %tmp2 = and <2 x i1> %tmp, %tmp1
114+
+ %tmp3 = extractelement <2 x i1> %tmp2, i32 0
115+
+ %tmp4 = extractelement <2 x i1> %tmp2, i32 1
116+
+ %tmp106 = and i1 %tmp4, %tmp3
117+
+ %tmp107 = zext i1 %tmp106 to i8
118+
+ %tmp108 = and i8 %tmp122, %tmp107
119+
+ %tmp109 = icmp eq i8 %tmp108, 0
120+
+; CHECK-NOT: testb {{%k[0-7]}}
121+
+ br i1 %tmp109, label %L188, label %L190
122+
+
123+
+if5:
124+
+ %b.055 = phi i8 [ 1, %pass2 ], [ %tmp122, %if5 ]
125+
+ %tmp118 = icmp sgt i64 undef, 0
126+
+ %tmp119 = icmp sle i64 undef, undef
127+
+ %tmp120 = and i1 %tmp118, %tmp119
128+
+ %tmp121 = zext i1 %tmp120 to i8
129+
+ %tmp122 = and i8 %b.055, %tmp121
130+
+ br i1 undef, label %L174, label %if5
131+
+
132+
+L188:
133+
+ unreachable
134+
+
135+
+L190:
136+
+ ret void
137+
+}

deps/patches/llvm-rL332694.patch

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From f5e705e8039d8b6a5813b47239a9cf801cccbe00 Mon Sep 17 00:00:00 2001
2+
From: Keno Fischer <[email protected]>
3+
Date: Fri, 18 May 2018 04:36:38 +0000
4+
Subject: [PATCH] [X86DomainReassignment] Hopefully fix buildbot failure
5+
6+
The Darwin build bot failed with:
7+
```
8+
llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu domain-reassignment-test.ll -o - | llvm-mc
9+
--
10+
Exit Code: 134
11+
12+
Command Output (stderr):
13+
--
14+
Assertion failed: (MAI->hasSingleParameterDotFile()), function EmitFileDirective, file lib/MC/MCAsmStreamer.cpp, line 1087.
15+
```
16+
17+
Looks like this is because the `llvm-mc` command was missing a triple
18+
directive and defaulting to MachO. Add the triple option.
19+
20+
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332694 91177308-0d34-0410-b5e6-96231b3b80d8
21+
---
22+
test/CodeGen/X86/domain-reassignment-test.ll | 2 +-
23+
1 file changed, 1 insertion(+), 1 deletion(-)
24+
25+
diff --git a/test/CodeGen/X86/domain-reassignment-test.ll b/test/CodeGen/X86/domain-reassignment-test.ll
26+
index 6285537df74..af7aca67c8f 100644
27+
--- a/test/CodeGen/X86/domain-reassignment-test.ll
28+
+++ b/test/CodeGen/X86/domain-reassignment-test.ll
29+
@@ -1,5 +1,5 @@
30+
; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck %s
31+
-; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | llvm-mc
32+
+; RUN: llc -mcpu=skylake-avx512 -mtriple=x86_64-unknown-linux-gnu %s -o - | llvm-mc -triple=x86_64-unknown-linux-gnu
33+
34+
; Check that the X86 domain reassignment pass doesn't introduce an illegal
35+
; test instruction. See PR37396
36+
--
37+
2.17.0
38+

0 commit comments

Comments
 (0)