From 198b24bc24d7b14ccb1a5ab711fe8d34ee15cf01 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 01 2017 03:35:44 +0000 Subject: import llvm-private-3.9.1-9.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc0bf12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +SOURCES/cfe-3.9.1.src.tar.xz +SOURCES/cmake-3.4.3.tar.gz +SOURCES/llvm-3.9.1.src.tar.xz diff --git a/.llvm-private.metadata b/.llvm-private.metadata new file mode 100644 index 0000000..c00ad8d --- /dev/null +++ b/.llvm-private.metadata @@ -0,0 +1,3 @@ +95e4be54b70f32cf98a8de36821ea5495b84add8 SOURCES/cfe-3.9.1.src.tar.xz +49e4f05d46d4752e514b19ba36bf97d20a7da66a SOURCES/cmake-3.4.3.tar.gz +ce801cf456b8dacd565ce8df8288b4d90e7317ff SOURCES/llvm-3.9.1.src.tar.xz diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/clang-config.h b/SOURCES/clang-config.h new file mode 100644 index 0000000..c369b45 --- /dev/null +++ b/SOURCES/clang-config.h @@ -0,0 +1,9 @@ +#include + +#if __WORDSIZE == 32 +#include "config-32.h" +#elif __WORDSIZE == 64 +#include "config-64.h" +#else +#error "Unknown word size" +#endif diff --git a/SOURCES/clang-hardcode-have-zlib.patch b/SOURCES/clang-hardcode-have-zlib.patch new file mode 100644 index 0000000..b76dd00 --- /dev/null +++ b/SOURCES/clang-hardcode-have-zlib.patch @@ -0,0 +1,29 @@ +From 47e5b1e80979631b6476e99f78d7a6ae17d1a8ff Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Tue, 21 Feb 2017 23:58:19 +0000 +Subject: [PATCH] test: Hard-code have_zlib to "1" in lit.site.cfg.in + +The stand-alone clang builds don't do zlib detection at all, so +have_zlib is always false, which is incorrect, since we build llvm +with zlib enabled. + +This fixes Driver/nozlibcompress.c +--- + test/lit.site.cfg.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in +index f368c99..5ca4d03 100644 +--- a/test/lit.site.cfg.in ++++ b/test/lit.site.cfg.in +@@ -14,7 +14,7 @@ config.clang_tools_dir = "@CLANG_TOOLS_DIR@" + config.host_triple = "@LLVM_HOST_TRIPLE@" + config.target_triple = "@TARGET_TRIPLE@" + config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" +-config.have_zlib = "@HAVE_LIBZ@" ++config.have_zlib = "1" + config.clang_arcmt = @ENABLE_CLANG_ARCMT@ + config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@ + config.clang_examples = @ENABLE_CLANG_EXAMPLES@ +-- +2.9.3 diff --git a/SOURCES/fix-cmake-include.patch b/SOURCES/fix-cmake-include.patch new file mode 100644 index 0000000..842b5c1 --- /dev/null +++ b/SOURCES/fix-cmake-include.patch @@ -0,0 +1,41 @@ +diff -up llvm-3.8.0rc2.src/CMakeLists.txt.fixinc llvm-3.8.0rc2.src/CMakeLists.txt +--- llvm-3.8.0rc2.src/CMakeLists.txt.fixinc 2016-01-14 05:03:44.000000000 +1000 ++++ llvm-3.8.0rc2.src/CMakeLists.txt 2016-02-26 10:21:44.477295728 +1000 +@@ -192,6 +192,7 @@ else() + endif() + + # Each of them corresponds to llvm-config's. ++# + set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir + set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir + set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root +@@ -558,6 +559,11 @@ set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LL + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + ++if(INCLUDE_INSTALL_DIR) ++else() ++set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include) ++endif() ++ + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) + if (APPLE) + set(CMAKE_INSTALL_NAME_DIR "@rpath") +@@ -728,7 +734,7 @@ add_subdirectory(cmake/modules) + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + install(DIRECTORY include/llvm include/llvm-c +- DESTINATION include ++ DESTINATION "${INCLUDE_INSTALL_DIR}" + COMPONENT llvm-headers + FILES_MATCHING + PATTERN "*.def" +@@ -740,7 +746,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + ) + + install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm +- DESTINATION include ++ DESTINATION "${INCLUDE_INSTALL_DIR}" + COMPONENT llvm-headers + FILES_MATCHING + PATTERN "*.def" diff --git a/SOURCES/llvm-config.h b/SOURCES/llvm-config.h new file mode 100644 index 0000000..2fa08c9 --- /dev/null +++ b/SOURCES/llvm-config.h @@ -0,0 +1,9 @@ +#include + +#if __WORDSIZE == 32 +#include "llvm-config-32.h" +#elif __WORDSIZE == 64 +#include "llvm-config-64.h" +#else +#error "Unknown word size" +#endif diff --git a/SOURCES/rust-lang-clang-pr47.patch b/SOURCES/rust-lang-clang-pr47.patch new file mode 100644 index 0000000..1abadc8 --- /dev/null +++ b/SOURCES/rust-lang-clang-pr47.patch @@ -0,0 +1,38 @@ +From d4852c7a1a3ac86af2ac9197da4d26f49f270ab9 Mon Sep 17 00:00:00 2001 +From: David Majnemer +Date: Sun, 7 Aug 2016 08:28:58 +0000 +Subject: [PATCH] Update clang tests for LLVM r277950 + +We infer inbounds on GEPs of allocas leading to minor perturbations in +tests. + +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277953 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + test/CodeGenObjCXX/exceptions-legacy.mm | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/CodeGenObjCXX/exceptions-legacy.mm b/test/CodeGenObjCXX/exceptions-legacy.mm +index dac259d..0650509 100644 +--- a/test/CodeGenObjCXX/exceptions-legacy.mm ++++ b/test/CodeGenObjCXX/exceptions-legacy.mm +@@ -16,7 +16,7 @@ void test0(id obj) { + // Enter the @synchronized block. + // CHECK: call i32 @objc_sync_enter(i8* [[OBJ:%.*]]) + // CHECK: call void @objc_exception_try_enter([[BUF_T:%.*]]* nonnull [[BUF:%.*]]) +-// CHECK-NEXT: [[T0:%.*]] = getelementptr [[BUF_T]], [[BUF_T]]* [[BUF]], i32 0, i32 0, i32 0 ++// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BUF_T]], [[BUF_T]]* [[BUF]], i32 0, i32 0, i32 0 + // CHECK-NEXT: [[T1:%.*]] = call i32 @_setjmp(i32* [[T0]]) + // CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0 + // CHECK-NEXT: br i1 [[T2]], +@@ -55,7 +55,7 @@ void test1(id obj, bool *failed) { + // CHECK-LABEL: define void @_Z5test1P11objc_objectPb( + // Enter the @try block. + // CHECK: call void @objc_exception_try_enter([[BUF_T]]* nonnull [[BUF:%.*]]) +-// CHECK-NEXT: [[T0:%.*]] = getelementptr [[BUF_T]], [[BUF_T]]* [[BUF]], i32 0, i32 0, i32 0 ++// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BUF_T]], [[BUF_T]]* [[BUF]], i32 0, i32 0, i32 0 + // CHECK-NEXT: [[T1:%.*]] = call i32 @_setjmp(i32* [[T0]]) + // CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0 + // CHECK-NEXT: br i1 [[T2]], +-- +1.8.3.1 + diff --git a/SOURCES/rust-lang-llvm-pr47.patch b/SOURCES/rust-lang-llvm-pr47.patch new file mode 100644 index 0000000..2457068 --- /dev/null +++ b/SOURCES/rust-lang-llvm-pr47.patch @@ -0,0 +1,272 @@ +From ae32815f9281a5a8d48014e180901fcdb658285a Mon Sep 17 00:00:00 2001 +From: David Majnemer +Date: Sun, 7 Aug 2016 07:58:00 +0000 +Subject: [rust-lang/llvm#47 1/4] [InstCombine] Infer inbounds on geps of + allocas + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277950 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Transforms/InstCombine/InstructionCombining.cpp | 19 +++++++++++++++++++ + test/Transforms/InstCombine/getelementptr.ll | 6 +++--- + 2 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp +index 377ccb9c37f7..31b5ad6ae8af 100644 +--- a/lib/Transforms/InstCombine/InstructionCombining.cpp ++++ b/lib/Transforms/InstCombine/InstructionCombining.cpp +@@ -1898,6 +1898,25 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { + } + } + ++ if (!GEP.isInBounds()) { ++ unsigned PtrWidth = ++ DL.getPointerSizeInBits(PtrOp->getType()->getPointerAddressSpace()); ++ APInt BasePtrOffset(PtrWidth, 0); ++ Value *UnderlyingPtrOp = ++ PtrOp->stripAndAccumulateInBoundsConstantOffsets(DL, ++ BasePtrOffset); ++ if (auto *AI = dyn_cast(UnderlyingPtrOp)) { ++ if (GEP.accumulateConstantOffset(DL, BasePtrOffset) && ++ BasePtrOffset.isNonNegative()) { ++ APInt AllocSize(PtrWidth, DL.getTypeAllocSize(AI->getAllocatedType())); ++ if (BasePtrOffset.ule(AllocSize)) { ++ return GetElementPtrInst::CreateInBounds( ++ PtrOp, makeArrayRef(Ops).slice(1), GEP.getName()); ++ } ++ } ++ } ++ } ++ + return nullptr; + } + +diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll +index 7446734e210c..14abd84fd18e 100644 +--- a/test/Transforms/InstCombine/getelementptr.ll ++++ b/test/Transforms/InstCombine/getelementptr.ll +@@ -366,7 +366,7 @@ define i32 @test21() { + %rval = load i32, i32* %pbobel + ret i32 %rval + ; CHECK-LABEL: @test21( +-; CHECK: getelementptr %intstruct, %intstruct* %pbob1, i64 0, i32 0 ++; CHECK: getelementptr inbounds %intstruct, %intstruct* %pbob1, i64 0, i32 0 + } + + +@@ -540,8 +540,8 @@ define i8* @test32(i8* %v) { + %G = load i8*, i8** %F + ret i8* %G + ; CHECK-LABEL: @test32( +-; CHECK: %D = getelementptr [4 x i8*], [4 x i8*]* %A, i64 0, i64 1 +-; CHECK: %F = getelementptr [4 x i8*], [4 x i8*]* %A, i64 0, i64 2 ++; CHECK: %D = getelementptr inbounds [4 x i8*], [4 x i8*]* %A, i64 0, i64 1 ++; CHECK: %F = getelementptr inbounds [4 x i8*], [4 x i8*]* %A, i64 0, i64 2 + } + + ; PR3290 +-- +2.7.4 + +From d31c987130ff1bf9cea9a287195ecceda91c37d1 Mon Sep 17 00:00:00 2001 +From: David Majnemer +Date: Sun, 7 Aug 2016 07:58:10 +0000 +Subject: [rust-lang/llvm#47 2/4] [InstSimplify] Try hard to simplify pointer + comparisons + +Simplify ptrtoint comparisons involving operands with different source +types. + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277951 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Analysis/InstructionSimplify.cpp | 10 ++++++++++ + test/Transforms/InstSimplify/compare.ll | 13 +++++++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp +index 7c6edbfca270..8b70d89d62cb 100644 +--- a/lib/Analysis/InstructionSimplify.cpp ++++ b/lib/Analysis/InstructionSimplify.cpp +@@ -3092,6 +3092,16 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, + if (LHS->getType()->isPointerTy()) + if (auto *C = computePointerICmp(Q.DL, Q.TLI, Q.DT, Pred, Q.CxtI, LHS, RHS)) + return C; ++ if (auto *CLHS = dyn_cast(LHS)) ++ if (auto *CRHS = dyn_cast(RHS)) ++ if (Q.DL.getTypeSizeInBits(CLHS->getPointerOperandType()) == ++ Q.DL.getTypeSizeInBits(CLHS->getType()) && ++ Q.DL.getTypeSizeInBits(CRHS->getPointerOperandType()) == ++ Q.DL.getTypeSizeInBits(CRHS->getType())) ++ if (auto *C = computePointerICmp(Q.DL, Q.TLI, Q.DT, Pred, Q.CxtI, ++ CLHS->getPointerOperand(), ++ CRHS->getPointerOperand())) ++ return C; + + if (GetElementPtrInst *GLHS = dyn_cast(LHS)) { + if (GEPOperator *GRHS = dyn_cast(RHS)) { +diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll +index 9d6fd74ae56f..3e7316ec6b48 100644 +--- a/test/Transforms/InstSimplify/compare.ll ++++ b/test/Transforms/InstSimplify/compare.ll +@@ -205,6 +205,19 @@ define i1 @gep16(i8* %ptr, i32 %a) { + ; CHECK-NEXT: ret i1 false + } + ++define i1 @gep17() { ++; CHECK-LABEL: @gep17( ++ %alloca = alloca i32, align 4 ++ %bc = bitcast i32* %alloca to [4 x i8]* ++ %gep1 = getelementptr inbounds i32, i32* %alloca, i32 1 ++ %pti1 = ptrtoint i32* %gep1 to i32 ++ %gep2 = getelementptr inbounds [4 x i8], [4 x i8]* %bc, i32 0, i32 1 ++ %pti2 = ptrtoint i8* %gep2 to i32 ++ %cmp = icmp ugt i32 %pti1, %pti2 ++ ret i1 %cmp ++; CHECK-NEXT: ret i1 true ++} ++ + define i1 @zext(i32 %x) { + ; CHECK-LABEL: @zext( + %e1 = zext i32 %x to i64 +-- +2.7.4 + +From bd3e05cb1f5293635edff14fcf23cfc73985c977 Mon Sep 17 00:00:00 2001 +From: David Majnemer +Date: Sun, 7 Aug 2016 07:58:12 +0000 +Subject: [rust-lang/llvm#47 3/4] [InstSimplify] Fold gep (gep V, C), (sub 0, + V) to C + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277952 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Analysis/InstructionSimplify.cpp | 20 ++++++++++++++++++++ + test/Transforms/InstSimplify/compare.ll | 13 +++++++++++++ + 2 files changed, 33 insertions(+) + +diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp +index 8b70d89d62cb..9d2a47957125 100644 +--- a/lib/Analysis/InstructionSimplify.cpp ++++ b/lib/Analysis/InstructionSimplify.cpp +@@ -3597,6 +3597,26 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops, + } + } + ++ // gep (gep V, C), (sub 0, V) -> C ++ if (Q.DL.getTypeAllocSize(LastType) == 1 && ++ all_of(Ops.slice(1).drop_back(1), ++ [](Value *Idx) { return match(Idx, m_Zero()); })) { ++ unsigned PtrWidth = ++ Q.DL.getPointerSizeInBits(Ops[0]->getType()->getPointerAddressSpace()); ++ if (Q.DL.getTypeSizeInBits(Ops.back()->getType()) == PtrWidth) { ++ APInt BasePtrOffset(PtrWidth, 0); ++ Value *StrippedBasePtr = ++ Ops[0]->stripAndAccumulateInBoundsConstantOffsets(Q.DL, ++ BasePtrOffset); ++ ++ if (match(Ops.back(), ++ m_Sub(m_Zero(), m_PtrToInt(m_Specific(StrippedBasePtr))))) { ++ auto *CI = ConstantInt::get(GEPTy->getContext(), BasePtrOffset); ++ return ConstantExpr::getIntToPtr(CI, GEPTy); ++ } ++ } ++ } ++ + // Check to see if this is constant foldable. + for (unsigned i = 0, e = Ops.size(); i != e; ++i) + if (!isa(Ops[i])) +diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll +index 3e7316ec6b48..addb63c57222 100644 +--- a/test/Transforms/InstSimplify/compare.ll ++++ b/test/Transforms/InstSimplify/compare.ll +@@ -218,6 +218,19 @@ define i1 @gep17() { + ; CHECK-NEXT: ret i1 true + } + ++define i32 @gep18() { ++; CHECK-LABEL: @gep18( ++ %alloca = alloca i32, align 4 ; alloca + 0 ++ %gep = getelementptr inbounds i32, i32* %alloca, i32 1 ; alloca + 4 ++ %bc = bitcast i32* %gep to [4 x i8]* ; alloca + 4 ++ %pti = ptrtoint i32* %alloca to i32 ; alloca ++ %sub = sub i32 0, %pti ; -alloca ++ %add = getelementptr [4 x i8], [4 x i8]* %bc, i32 0, i32 %sub ; alloca + 4 - alloca == 4 ++ %add_to_int = ptrtoint i8* %add to i32 ; 4 ++ ret i32 %add_to_int ; 4 ++; CHECK-NEXT: ret i32 4 ++} ++ + define i1 @zext(i32 %x) { + ; CHECK-LABEL: @zext( + %e1 = zext i32 %x to i64 +-- +2.7.4 + +From c3eb3c7608f439231d0c1340af6b720f113b4bf4 Mon Sep 17 00:00:00 2001 +From: David Majnemer +Date: Tue, 16 Aug 2016 06:13:46 +0000 +Subject: [rust-lang/llvm#47 4/4] [InstSimplify] Fold gep (gep V, C), (xor V, + -1) to C-1 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278779 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Analysis/InstructionSimplify.cpp | 8 +++++++- + test/Transforms/InstSimplify/compare.ll | 13 ------------- + 2 files changed, 7 insertions(+), 14 deletions(-) + +diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp +index 9d2a47957125..f7a435d1ad46 100644 +--- a/lib/Analysis/InstructionSimplify.cpp ++++ b/lib/Analysis/InstructionSimplify.cpp +@@ -3597,7 +3597,6 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops, + } + } + +- // gep (gep V, C), (sub 0, V) -> C + if (Q.DL.getTypeAllocSize(LastType) == 1 && + all_of(Ops.slice(1).drop_back(1), + [](Value *Idx) { return match(Idx, m_Zero()); })) { +@@ -3609,11 +3608,18 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef Ops, + Ops[0]->stripAndAccumulateInBoundsConstantOffsets(Q.DL, + BasePtrOffset); + ++ // gep (gep V, C), (sub 0, V) -> C + if (match(Ops.back(), + m_Sub(m_Zero(), m_PtrToInt(m_Specific(StrippedBasePtr))))) { + auto *CI = ConstantInt::get(GEPTy->getContext(), BasePtrOffset); + return ConstantExpr::getIntToPtr(CI, GEPTy); + } ++ // gep (gep V, C), (xor V, -1) -> C-1 ++ if (match(Ops.back(), ++ m_Xor(m_PtrToInt(m_Specific(StrippedBasePtr)), m_AllOnes()))) { ++ auto *CI = ConstantInt::get(GEPTy->getContext(), BasePtrOffset - 1); ++ return ConstantExpr::getIntToPtr(CI, GEPTy); ++ } + } + } + +diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll +index addb63c57222..3e7316ec6b48 100644 +--- a/test/Transforms/InstSimplify/compare.ll ++++ b/test/Transforms/InstSimplify/compare.ll +@@ -218,19 +218,6 @@ define i1 @gep17() { + ; CHECK-NEXT: ret i1 true + } + +-define i32 @gep18() { +-; CHECK-LABEL: @gep18( +- %alloca = alloca i32, align 4 ; alloca + 0 +- %gep = getelementptr inbounds i32, i32* %alloca, i32 1 ; alloca + 4 +- %bc = bitcast i32* %gep to [4 x i8]* ; alloca + 4 +- %pti = ptrtoint i32* %alloca to i32 ; alloca +- %sub = sub i32 0, %pti ; -alloca +- %add = getelementptr [4 x i8], [4 x i8]* %bc, i32 0, i32 %sub ; alloca + 4 - alloca == 4 +- %add_to_int = ptrtoint i8* %add to i32 ; 4 +- ret i32 %add_to_int ; 4 +-; CHECK-NEXT: ret i32 4 +-} +- + define i1 @zext(i32 %x) { + ; CHECK-LABEL: @zext( + %e1 = zext i32 %x to i64 +-- +2.7.4 + diff --git a/SOURCES/rust-lang-llvm-pr53.patch b/SOURCES/rust-lang-llvm-pr53.patch new file mode 100644 index 0000000..05970a1 --- /dev/null +++ b/SOURCES/rust-lang-llvm-pr53.patch @@ -0,0 +1,349 @@ +From 0d4331af6e01235479e44f9775b3fde9e19200a3 Mon Sep 17 00:00:00 2001 +From: Keith Walker +Date: Tue, 27 Sep 2016 16:46:07 +0000 +Subject: [rust-lang/llvm#53 1/2] Propagate DBG_VALUE entries when there are + unvisited predecessors + +Variables are sometimes missing their debug location information in +blocks in which the variables should be available. This would occur +when one or more predecessor blocks had not yet been visited by the +routine which propagated the information from predecessor blocks. + +This is addressed by only considering predecessor blocks which have +already been visited. + +The solution to this problem was suggested by Daniel Berlin on the +LLVM developer mailing list. + +Differential Revision: https://reviews.llvm.org/D24927 + + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282506 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/CodeGen/LiveDebugValues.cpp | 34 ++-- + test/CodeGen/ARM/dbg-range-extension.mir | 282 +++++++++++++++++++++++++++++++ + 2 files changed, 306 insertions(+), 10 deletions(-) + create mode 100644 test/CodeGen/ARM/dbg-range-extension.mir + +diff --git a/lib/CodeGen/LiveDebugValues.cpp b/lib/CodeGen/LiveDebugValues.cpp +index 4ff88d528108..4cadd5855ed5 100644 +--- a/lib/CodeGen/LiveDebugValues.cpp ++++ b/lib/CodeGen/LiveDebugValues.cpp +@@ -201,7 +201,8 @@ private: + VarLocInMBB &OutLocs, VarLocMap &VarLocIDs); + + bool join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, VarLocInMBB &InLocs, +- const VarLocMap &VarLocIDs); ++ const VarLocMap &VarLocIDs, ++ SmallPtrSet &Visited); + + bool ExtendRanges(MachineFunction &MF); + +@@ -368,7 +369,8 @@ bool LiveDebugValues::transfer(MachineInstr &MI, OpenRangesSet &OpenRanges, + /// inserting a new DBG_VALUE instruction at the start of the @MBB - if the same + /// source variable in all the predecessors of @MBB reside in the same location. + bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, +- VarLocInMBB &InLocs, const VarLocMap &VarLocIDs) { ++ VarLocInMBB &InLocs, const VarLocMap &VarLocIDs, ++ SmallPtrSet &Visited) { + DEBUG(dbgs() << "join MBB: " << MBB.getName() << "\n"); + bool Changed = false; + +@@ -376,21 +378,32 @@ bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, + + // For all predecessors of this MBB, find the set of VarLocs that + // can be joined. ++ int NumVisited = 0; + for (auto p : MBB.predecessors()) { ++ // Ignore unvisited predecessor blocks. As we are processing ++ // the blocks in reverse post-order any unvisited block can ++ // be considered to not remove any incoming values. ++ if (!Visited.count(p)) ++ continue; + auto OL = OutLocs.find(p); + // Join is null in case of empty OutLocs from any of the pred. + if (OL == OutLocs.end()) + return false; + +- // Just copy over the Out locs to incoming locs for the first predecessor. +- if (p == *MBB.pred_begin()) { ++ // Just copy over the Out locs to incoming locs for the first visited ++ // predecessor, and for all other predecessors join the Out locs. ++ if (!NumVisited) + InLocsT = OL->second; +- continue; +- } +- // Join with this predecessor. +- InLocsT &= OL->second; ++ else ++ InLocsT &= OL->second; ++ NumVisited++; + } + ++ // As we are processing blocks in reverse post-order we ++ // should have processed at least one predecessor, unless it ++ // is the entry block which has no predecessor. ++ assert((NumVisited || MBB.pred_empty()) && ++ "Should have processed at least one predecessor"); + if (InLocsT.empty()) + return false; + +@@ -463,6 +476,7 @@ bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { + // To solve it, we perform join() and transfer() using the two worklist method + // until the ranges converge. + // Ranges have converged when both worklists are empty. ++ SmallPtrSet Visited; + while (!Worklist.empty() || !Pending.empty()) { + // We track what is on the pending worklist to avoid inserting the same + // thing twice. We could avoid this with a custom priority queue, but this +@@ -471,8 +485,8 @@ bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { + while (!Worklist.empty()) { + MachineBasicBlock *MBB = OrderToBB[Worklist.top()]; + Worklist.pop(); +- MBBJoined = join(*MBB, OutLocs, InLocs, VarLocIDs); +- ++ MBBJoined = join(*MBB, OutLocs, InLocs, VarLocIDs, Visited); ++ Visited.insert(MBB); + if (MBBJoined) { + MBBJoined = false; + Changed = true; +-- +2.7.4 + +From 8a0fc26559123bb6eab3ceae93d5a2c94943614b Mon Sep 17 00:00:00 2001 +From: Adrian Prantl +Date: Wed, 28 Sep 2016 17:51:14 +0000 +Subject: [rust-lang/llvm#53 2/2] Teach LiveDebugValues about lexical scopes. + +This addresses PR26055 LiveDebugValues is very slow. + +Contrary to the old LiveDebugVariables pass LiveDebugValues currently +doesn't look at the lexical scopes before inserting a DBG_VALUE +intrinsic. This means that we often propagate DBG_VALUEs much further +down than necessary. This is especially noticeable in large C++ +functions with many inlined method calls that all use the same +"this"-pointer. + +For example, in the following code it makes no sense to propagate the +inlined variable a from the first inlined call to f() into any of the +subsequent basic blocks, because the variable will always be out of +scope: + +void sink(int a); +void __attribute((always_inline)) f(int a) { sink(a); } +void foo(int i) { + f(i); + if (i) + f(i); + f(i); +} + +This patch reuses the LexicalScopes infrastructure we have for +LiveDebugVariables to take this into account. + +The effect on compile time and memory consumption is quite noticeable: +I tested a benchmark that is a large C++ source with an enormous +amount of inlined "this"-pointers that would previously eat >24GiB +(most of them for DBG_VALUE intrinsics) and whose compile time was +dominated by LiveDebugValues. With this patch applied the memory +consumption is 1GiB and 1.7% of the time is spent in LiveDebugValues. + +https://reviews.llvm.org/D24994 +Thanks to Daniel Berlin and Keith Walker for reviewing! + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282611 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/CodeGen/LiveDebugValues.cpp | 51 ++++- + test/CodeGen/ARM/dbg-range-extension.mir | 1 - + test/DebugInfo/COFF/register-variables.ll | 8 +- + test/DebugInfo/MIR/X86/livedebugvalues-limit.mir | 228 +++++++++++++++++++++++ + test/DebugInfo/X86/fission-ranges.ll | 6 +- + 5 files changed, 278 insertions(+), 16 deletions(-) + create mode 100644 test/DebugInfo/MIR/X86/livedebugvalues-limit.mir + +diff --git a/lib/CodeGen/LiveDebugValues.cpp b/lib/CodeGen/LiveDebugValues.cpp +index 4cadd5855ed5..969944eb24a2 100644 +--- a/lib/CodeGen/LiveDebugValues.cpp ++++ b/lib/CodeGen/LiveDebugValues.cpp +@@ -23,6 +23,7 @@ + #include "llvm/ADT/SparseBitVector.h" + #include "llvm/ADT/Statistic.h" + #include "llvm/ADT/UniqueVector.h" ++#include "llvm/CodeGen/LexicalScopes.h" + #include "llvm/CodeGen/MachineFunction.h" + #include "llvm/CodeGen/MachineFunctionPass.h" + #include "llvm/CodeGen/MachineInstrBuilder.h" +@@ -60,6 +61,26 @@ class LiveDebugValues : public MachineFunctionPass { + private: + const TargetRegisterInfo *TRI; + const TargetInstrInfo *TII; ++ LexicalScopes LS; ++ ++ /// Keeps track of lexical scopes associated with a user value's source ++ /// location. ++ class UserValueScopes { ++ DebugLoc DL; ++ LexicalScopes &LS; ++ SmallPtrSet LBlocks; ++ ++ public: ++ UserValueScopes(DebugLoc D, LexicalScopes &L) : DL(std::move(D)), LS(L) {} ++ ++ /// Return true if current scope dominates at least one machine ++ /// instruction in a given machine basic block. ++ bool dominates(MachineBasicBlock *MBB) { ++ if (LBlocks.empty()) ++ LS.getMachineBasicBlocks(DL, LBlocks); ++ return LBlocks.count(MBB) != 0 || LS.dominates(DL, MBB); ++ } ++ }; + + /// Based on std::pair so it can be used as an index into a DenseMap. + typedef std::pair +@@ -83,7 +104,7 @@ private: + struct VarLoc { + const DebugVariable Var; + const MachineInstr &MI; ///< Only used for cloning a new DBG_VALUE. +- ++ mutable UserValueScopes UVS; + enum { InvalidKind = 0, RegisterKind } Kind; + + /// The value location. Stored separately to avoid repeatedly +@@ -96,9 +117,9 @@ private: + uint64_t Hash; + } Loc; + +- VarLoc(const MachineInstr &MI) ++ VarLoc(const MachineInstr &MI, LexicalScopes &LS) + : Var(MI.getDebugVariable(), MI.getDebugLoc()->getInlinedAt()), MI(MI), +- Kind(InvalidKind) { ++ UVS(MI.getDebugLoc(), LS), Kind(InvalidKind) { + static_assert((sizeof(Loc) == sizeof(uint64_t)), + "hash does not cover all members of Loc"); + assert(MI.isDebugValue() && "not a DBG_VALUE"); +@@ -125,6 +146,10 @@ private: + return 0; + } + ++ /// Determine whether the lexical scope of this value's debug location ++ /// dominates MBB. ++ bool dominates(MachineBasicBlock &MBB) const { return UVS.dominates(&MBB); } ++ + void dump() const { MI.dump(); } + + bool operator==(const VarLoc &Other) const { +@@ -229,6 +254,7 @@ public: + /// Calculate the liveness information for the given machine function. + bool runOnMachineFunction(MachineFunction &MF) override; + }; ++ + } // namespace + + //===----------------------------------------------------------------------===// +@@ -295,7 +321,7 @@ void LiveDebugValues::transferDebugValue(const MachineInstr &MI, + // Add the VarLoc to OpenRanges from this DBG_VALUE. + // TODO: Currently handles DBG_VALUE which has only reg as location. + if (isDbgValueDescribedByReg(MI)) { +- VarLoc VL(MI); ++ VarLoc VL(MI, LS); + unsigned ID = VarLocIDs.insert(VL); + OpenRanges.insert(ID, VL.Var); + } +@@ -399,6 +425,13 @@ bool LiveDebugValues::join(MachineBasicBlock &MBB, VarLocInMBB &OutLocs, + NumVisited++; + } + ++ // Filter out DBG_VALUES that are out of scope. ++ VarLocSet KillSet; ++ for (auto ID : InLocsT) ++ if (!VarLocIDs[ID].dominates(MBB)) ++ KillSet.set(ID); ++ InLocsT.intersectWithComplement(KillSet); ++ + // As we are processing blocks in reverse post-order we + // should have processed at least one predecessor, unless it + // is the entry block which has no predecessor. +@@ -519,12 +552,14 @@ bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { + } + + bool LiveDebugValues::runOnMachineFunction(MachineFunction &MF) { ++ if (!MF.getFunction()->getSubprogram()) ++ // LiveDebugValues will already have removed all DBG_VALUEs. ++ return false; ++ + TRI = MF.getSubtarget().getRegisterInfo(); + TII = MF.getSubtarget().getInstrInfo(); ++ LS.initialize(MF); + +- bool Changed = false; +- +- Changed |= ExtendRanges(MF); +- ++ bool Changed = ExtendRanges(MF); + return Changed; + } +diff --git a/test/DebugInfo/COFF/register-variables.ll b/test/DebugInfo/COFF/register-variables.ll +index 9bb782853a3d..08246fef9603 100644 +--- a/test/DebugInfo/COFF/register-variables.ll ++++ b/test/DebugInfo/COFF/register-variables.ll +@@ -37,8 +37,8 @@ + ; ASM: #DEBUG_VALUE: c <- %EAX + ; ASM: testl %esi, %esi + ; ASM: je .LBB0_2 ++; ASM: [[after_je:\.Ltmp.*]]: + ; ASM: # BB#1: # %if.then +-; ASM-DAG: #DEBUG_VALUE: c <- %EAX + ; ASM-DAG: #DEBUG_VALUE: inlineinc:a <- %EAX + ; ASM-DAG: #DEBUG_VALUE: a <- %EAX + ; ASM-DAG: #DEBUG_VALUE: f:p <- %ESI +@@ -65,7 +65,7 @@ + ; ASM: .cv_def_range [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000" + ; ASM: .short 4414 # Record kind: S_LOCAL + ; ASM: .asciz "c" +-; ASM: .cv_def_range [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000" ++; ASM: .cv_def_range [[after_getint]] [[after_je]], "A\021\021\000\000\000" + ; ASM: .short 4414 # Record kind: S_LOCAL + ; ASM: .asciz "b" + ; ASM: .cv_def_range [[after_inc_eax]] [[after_if]], "A\021\021\000\000\000" +@@ -132,7 +132,7 @@ + ; OBJ: LocalVariableAddrRange { + ; OBJ: OffsetStart: .text+0xC + ; OBJ: ISectStart: 0x0 +-; OBJ: Range: 0x6 ++; OBJ: Range: 0x4 + ; OBJ: } + ; OBJ: } + ; OBJ: Local { +@@ -143,7 +143,7 @@ + ; OBJ: } + ; OBJ: DefRangeRegister { + ; OBJ: Register: 17 +-; OBJ: LocalVariableAddrRange { ++; OBJ: MayHaveNoName: 0 + ; OBJ: OffsetStart: .text+0x12 + ; OBJ: ISectStart: 0x0 + ; OBJ: Range: 0x6 +diff --git a/test/DebugInfo/X86/fission-ranges.ll b/test/DebugInfo/X86/fission-ranges.ll +index 3c05f223ee79..0dfb13ab66b7 100644 +--- a/test/DebugInfo/X86/fission-ranges.ll ++++ b/test/DebugInfo/X86/fission-ranges.ll +@@ -32,13 +32,13 @@ + ; CHECK-NEXT: Length: 25 + ; CHECK-NEXT: Location description: 50 93 04 + ; CHECK: [[E]]: Beginning address index: 4 +-; CHECK-NEXT: Length: 23 ++; CHECK-NEXT: Length: 19 + ; CHECK-NEXT: Location description: 50 93 04 + ; CHECK: [[B]]: Beginning address index: 5 +-; CHECK-NEXT: Length: 21 ++; CHECK-NEXT: Length: 17 + ; CHECK-NEXT: Location description: 50 93 04 + ; CHECK: [[D]]: Beginning address index: 6 +-; CHECK-NEXT: Length: 21 ++; CHECK-NEXT: Length: 17 + ; CHECK-NEXT: Location description: 50 93 04 + + ; Make sure we don't produce any relocations in any .dwo section (though in particular, debug_info.dwo) +-- +2.7.4 + diff --git a/SOURCES/rust-lang-llvm-pr54.patch b/SOURCES/rust-lang-llvm-pr54.patch new file mode 100644 index 0000000..942e74e --- /dev/null +++ b/SOURCES/rust-lang-llvm-pr54.patch @@ -0,0 +1,103 @@ +From 9b74379db3f9e30516f053138fd3697d42b23164 Mon Sep 17 00:00:00 2001 +From: David Majnemer +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(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 + diff --git a/SOURCES/rust-lang-llvm-pr55.patch b/SOURCES/rust-lang-llvm-pr55.patch new file mode 100644 index 0000000..f534f31 --- /dev/null +++ b/SOURCES/rust-lang-llvm-pr55.patch @@ -0,0 +1,85 @@ +From eff5dc809ed54701f2bb3e15c58d01881299cedf Mon Sep 17 00:00:00 2001 +From: David Majnemer +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 + diff --git a/SOURCES/rust-lang-llvm-pr57.patch b/SOURCES/rust-lang-llvm-pr57.patch new file mode 100644 index 0000000..24b6a58 --- /dev/null +++ b/SOURCES/rust-lang-llvm-pr57.patch @@ -0,0 +1,28 @@ +From 5ac4f80be3e8b5d42475aeaba246455e0016c7ef Mon Sep 17 00:00:00 2001 +From: Anthony Ramine +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"); +-- +2.9.3 + diff --git a/SPECS/llvm.spec b/SPECS/llvm.spec new file mode 100644 index 0000000..99ee9dd --- /dev/null +++ b/SPECS/llvm.spec @@ -0,0 +1,354 @@ +# Components enabled if supported by target architecture: +%ifarch %ix86 x86_64 + %bcond_without gold +%else + %bcond_with gold +%endif + +%if 0%{?rhel} == 6 +%define rhel6 1 +%endif + +# llvm works on the 64-bit versions of these, but not the 32 versions. +# consequently we build swrast on them instead of llvmpipe. +ExcludeArch: ppc s390 %{?rhel6:s390x} + +%ifarch s390x +%global host_target SystemZ +%endif +%ifarch ppc64 ppc64le +%global host_target PowerPC +%endif +%ifarch %ix86 x86_64 +%global host_target X86 +%endif +%ifarch aarch64 +%global host_target AArch64 +%endif +%ifarch %{arm} +%global host_target ARM +%endif + +%ifnarch s390x +%global amdgpu ;AMDGPU +%endif + +%global llvm_lib_suffix rhel + +Name: llvm-private +Version: 3.9.1 +Release: 9%{?dist} +Summary: llvm engine for Mesa + +Group: System Environment/Libraries +License: NCSA +URL: http://llvm.org +Source0: http://llvm.org/releases/%{version}/llvm-%{version}.src.tar.xz +Source1: cmake-3.4.3.tar.gz +Source2: http://llvm.org/releases/%{version}/cfe-%{version}.src.tar.xz +Source100: llvm-config.h +Source101: clang-config.h + +Patch1: fix-cmake-include.patch +Patch2: clang-hardcode-have-zlib.patch +# Clang patch for changes in rust-lang-llvm-pr47.patch (LLVM r277951 to be exact). +Patch3: rust-lang-clang-pr47.patch +# backports cribbed from https://github.com/rust-lang/llvm/ +Patch47: rust-lang-llvm-pr47.patch +Patch53: rust-lang-llvm-pr53.patch +Patch54: rust-lang-llvm-pr54.patch +Patch55: rust-lang-llvm-pr55.patch +Patch57: rust-lang-llvm-pr57.patch + + +BuildRequires: cmake +BuildRequires: zlib-devel +%if %{with gold} +BuildRequires: binutils-devel +%endif +BuildRequires: libstdc++-static +BuildRequires: python + +%description +This package contains the LLVM-based runtime support for Mesa. It is not a +fully-featured build of LLVM, and use by any package other than Mesa is not +supported. + +%package devel +Summary: Libraries and header files for LLVM +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains library and header files needed to build the LLVM +support in Mesa. + +%prep +%setup -T -q -b 2 -n cfe-%{version}.src + +%patch2 -p1 -b .havezlib +%patch3 -p1 -b .clangrust47 + +%setup -q -n llvm-%{version}.src + +tar xf %{SOURCE1} + +%patch1 -p1 -b .fixinc +%patch47 -p1 -b .rust47 +%patch53 -p1 -b .rust53 +%patch54 -p1 -b .rust54 +%patch55 -p1 -b .rust55 +%patch57 -p1 -b .rust57 + +%build + +BUILD_DIR=`pwd`/cmake_build +cd cmake-3.4.3 +cmake . -DCMAKE_INSTALL_PREFIX=$BUILD_DIR +make +make install +cd - + + +sed -i 's|ActiveIncludeDir = ActivePrefix + "/include|&/llvm-private|g' tools/llvm-config/llvm-config.cpp + +mkdir -p _build +cd _build + +export PATH=$BUILD_DIR/bin:$PATH +%global __cmake $BUILD_DIR/bin/cmake +# force off shared libs as cmake macros turns it on. +%cmake .. \ + -DINCLUDE_INSTALL_DIR=%{_includedir}/llvm-private \ + -DLLVM_VERSION_SUFFIX="-%{llvm_lib_suffix}" \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-Bsymbolic -static-libstdc++" \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif + \ + -DLLVM_TARGETS_TO_BUILD="%{host_target}%{?amdgpu}" \ + -DLLVM_ENABLE_LIBCXX:BOOL=OFF \ + -DLLVM_ENABLE_ZLIB:BOOL=ON \ + -DLLVM_ENABLE_FFI:BOOL=OFF \ + -DLLVM_ENABLE_RTTI:BOOL=OFF \ +%if %{with gold} + -DLLVM_BINUTILS_INCDIR=%{_includedir} \ +%endif + \ + -DLLVM_BUILD_RUNTIME:BOOL=ON \ + \ + -DLLVM_INCLUDE_TOOLS:BOOL=ON \ + -DLLVM_BUILD_TOOLS:BOOL=ON \ + \ + -DLLVM_INCLUDE_TESTS:BOOL=ON \ + -DLLVM_BUILD_TESTS:BOOL=ON \ + \ + -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \ + -DLLVM_BUILD_EXAMPLES:BOOL=OFF \ + \ + -DLLVM_INCLUDE_UTILS:BOOL=ON \ + -DLLVM_INSTALL_UTILS:BOOL=OFF \ + \ + -DLLVM_INCLUDE_DOCS:BOOL=OFF \ + -DLLVM_BUILD_DOCS:BOOL=OFF \ + -DLLVM_ENABLE_SPHINX:BOOL=OFF \ + -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \ + \ + -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ + -DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \ + -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF + +make %{?_smp_mflags} VERBOSE=1 + +# Build clang separately, because we need to build with +# -DBUILD_SHARED_LIBS:BOOL=ON for clang, but we don't want +# this for LLVM. + +cd ../../cfe-%{version}.src +mkdir -p _build +cd _build +%cmake .. \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DLLVM_CONFIG:FILEPATH=%{_builddir}/llvm-%{version}.src/_build/bin/llvm-config \ + \ + -DCLANG_ENABLE_ARCMT:BOOL=ON \ + -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ + -DCLANG_INCLUDE_DOCS:BOOL=ON \ + -DCLANG_INCLUDE_TESTS:BOOL=ON \ + -DCLANG_PLUGIN_SUPPORT:BOOL=ON \ + -DENABLE_LINKER_BUILD_ID:BOOL=ON \ + \ + -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif + -DLIB_SUFFIX= + +make %{?_smp_mflags} + +%install + +# Install LLVM +cd _build +make install DESTDIR=%{buildroot} + +cd ../../cfe-%{version}.src/_build +make install DESTDIR=%{buildroot} + + +# fix multi-lib +mv -v %{buildroot}%{_bindir}/llvm-config %{buildroot}%{_bindir}/%{name}-config-%{__isa_bits} +mv -v %{buildroot}%{_includedir}/llvm-private/llvm/Config/llvm-config{,-%{__isa_bits}}.h +install -m 0644 %{SOURCE100} %{buildroot}%{_includedir}/llvm-private/llvm/Config/llvm-config.h +mv -v %{buildroot}%{_includedir}/clang/Config/config{,-%{__isa_bits}}.h +install -m 0644 %{SOURCE101} %{buildroot}%{_includedir}/clang/Config/config.h + +rm -f %{buildroot}%{_libdir}/*.a + +rm -f %{buildroot}%{_libdir}/libLLVM.so + +# remove documentation makefiles: +# they require the build directory to work +find examples -name 'Makefile' | xargs -0r rm -f + +# Rename tools needed by rust. +for t in mc ar as; do mv -v %{buildroot}/%{_bindir}/llvm-$t %{buildroot}/%{_bindir}/llvm-private-$t-%{__isa_bits}; done; + +# RHEL: strip out most binaries, most libs, and man pages +ls %{buildroot}%{_bindir}/* | grep -v bin/llvm-private | xargs rm -f +ls %{buildroot}%{_libdir}/* | grep -v libLLVM | grep -v libclang | xargs rm -f +rm -rf %{buildroot}%{_mandir}/man1 + +# RHEL: Strip out some headers Mesa doesn't need +rm -rf %{buildroot}%{_includedir}/llvm-private/llvm/{Assembly} +rm -rf %{buildroot}%{_includedir}/llvm-private/llvm/Option +rm -rf %{buildroot}%{_includedir}/llvm-private/llvm/TableGen +rm -rf %{buildroot}%{_includedir}/llvm-c/lto.h + +# RHEL: Strip out cmake build foo +rm -rf %{buildroot}%{_datadir}/llvm/cmake +rm -rf %{buildroot}%{_libdir}/cmake/clang + +# RHEL: bcc uses find_package(LLVM) in its cmake file, which requires +# LLVMConfig.cmake to be installed. +find %{buildroot}%{_libdir}/cmake/llvm/ ! -name 'LLVMConfig.cmake' -type f -exec rm -rf {} + + + +# RHEL: Strip out eveything in _datadir and _libexedir +rm -rf %{buildroot}%{_datadir}/* +rm -rf %{buildroot}%{_libexecdir}/* + +# clang seems to ignore INCLUDE_INSTALL_DIR +mv %{buildroot}%{_includedir}/{,llvm-private}/clang +mv %{buildroot}%{_includedir}/{,llvm-private}/clang-c + +# Move clang libraries: +mkdir %{buildroot}%{_libdir}/clang-private +for f in `find %{buildroot}%{_libdir} -iname 'libclang*' `; do mv $f %{buildroot}%{_libdir}/clang-private; done + +%check +cd _build +# 3.8.1 note: skx failures are XFAIL. the skylake backport does not wire +# up AVX512 for skylake, but the tests are from code that expects that. +# safe to ignore. +make check-all || : + +cd ../../cfe-%{version}.src/_build +make check-all || : + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%doc LICENSE.TXT +%{_libdir}/libLLVM-3.9*-%{llvm_lib_suffix}.so +%{_libdir}/clang-private/libclang*.so* + +%files devel +%{_bindir}/llvm-private* +%{_includedir}/llvm-private/llvm +%{_includedir}/llvm-private/llvm-c +%{_libdir}/cmake/llvm/LLVMConfig.cmake +%{_includedir}/llvm-private/clang +%{_includedir}/llvm-private/clang-c +%{_libdir}/clang/%{version}/include + +%changelog +* Thu Jun 01 2017 Tilmann Scheller - 3.9.1-9 +- Fix two Clang test failures and enable Clang regression tests during build. + +* Mon May 08 2017 Tom Stellard - 3.9.1-8 +- Fix clang headers with multilib. + +* Fri Apr 07 2017 Tom Stellard - 3.9.1-7 +- Add clang libs + +* Mon Mar 27 2017 Tom Stellard - 3.9.1-6 +- Ignore test failures due APFloat unit test failure on AArch64. + +* Mon Feb 27 2017 Tom Stellard - 3.9.1-5 +- Add rust patches + +* Mon Feb 27 2017 Tom Stellard - 3.9.1-4 +- Don't ignore make check failures + +* Mon Feb 27 2017 Tom Stellard - 3.9.1-3 +- Remove old patches + +* Mon Feb 27 2017 Tom Stellard - 3.9.1-2 +- Rename mesa-private-llvm -> llvm-private + +* Tue Jan 10 2017 Jeff Law - 3.9.1-1 +- Update to 3.9.1 + +* Wed Jul 13 2016 Adam Jackson - 3.8.1-1 +- Update to 3.8.1 +- Sync some x86 getHostCPUName updates from trunk + +* Tue Jun 14 2016 Dave Airlie - 3.8.0-2 +- drop private cmake build + +* Thu Mar 10 2016 Dave Airlie 3.8.0-1 +- llvm 3.8.0 final release + +* Thu Mar 03 2016 Dave Airlie 3.8.0-0.2 +- llvm 3.8.0 rc3 release + +* Fri Feb 19 2016 Dave Airlie 3.8.0-0.1 +- llvm 3.8.0 rc2 release + +* Tue Feb 16 2016 Dan HorĂ¡k 3.7.1-7 +- recognize s390 as SystemZ when configuring build + +* Sat Feb 13 2016 Dave Airlie 3.7.1-6 +- export C++ API for mesa. + +* Sat Feb 13 2016 Dave Airlie 3.7.1-5 +- reintroduce llvm-static, clang needs it currently. + +* Fri Feb 12 2016 Dave Airlie 3.7.1-4 +- jump back to single llvm library, the split libs aren't working very well. + +* Fri Feb 05 2016 Dave Airlie 3.7.1-3 +- add missing obsoletes (#1303497) + +* Thu Feb 04 2016 Fedora Release Engineering - 3.7.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Thu Jan 07 2016 Jan Vcelak 3.7.1-1 +- new upstream release +- enable gold linker + +* Wed Nov 04 2015 Jan Vcelak 3.7.0-100 +- fix Requires for subpackages on the main package + +* Tue Oct 06 2015 Jan Vcelak 3.7.0-100 +- initial version using cmake build system