authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-01 13:51:53-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-01 13:51:53-05:00
log921825b4c0a83c98782e1b9266522aefb1b17022
tree6d2c75762c3e08dd686710666f8208fa1406be6c
parentb4120423a5f0785e950739ab8c1324691971d680
parentcf96b6f87b5feaa699f0d15b1525d53a374b6227

Merge branch 'llvm5.0.1'


14 files changed, 104 insertions(+), 24 deletions(-)

CMakeLists.txt+8-3
......@@ -47,15 +47,20 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
4747option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead of the embedded LLD" OFF)
4848
4949find_package(llvm)
50include_directories(${LLVM_INCLUDE_DIRS})
51
5250find_package(clang)
53include_directories(${CLANG_INCLUDE_DIRS})
5451
5552if(ZIG_FORCE_EXTERNAL_LLD)
5653 find_package(lld)
54 include_directories(${LLVM_INCLUDE_DIRS})
5755 include_directories(${LLD_INCLUDE_DIRS})
56 include_directories(${CLANG_INCLUDE_DIRS})
5857else()
58 # This goes first so that we find embedded LLD instead
59 # of system LLD.
60 include_directories("${CMAKE_SOURCE_DIR}/deps/lld/include")
61
62 include_directories(${LLVM_INCLUDE_DIRS})
63 include_directories(${CLANG_INCLUDE_DIRS})
5964 set(EMBEDDED_LLD_LIB_SOURCES
6065 "${CMAKE_SOURCE_DIR}/deps/lld/lib/Driver/DarwinLdDriver.cpp"
6166 "${CMAKE_SOURCE_DIR}/deps/lld/lib/Config/Version.cpp"
c_headers/avx512fintrin.h+2-7
......@@ -267,21 +267,16 @@ _mm512_maskz_set1_epi32(__mmask16 __M, int __A)
267267 __M);
268268}
269269
270#ifdef __x86_64__
270271static __inline __m512i __DEFAULT_FN_ATTRS
271272_mm512_maskz_set1_epi64(__mmask8 __M, long long __A)
272273{
273#ifdef __x86_64__
274274 return (__m512i) __builtin_ia32_pbroadcastq512_gpr_mask (__A,
275275 (__v8di)
276276 _mm512_setzero_si512 (),
277277 __M);
278#else
279 return (__m512i) __builtin_ia32_pbroadcastq512_mem_mask (__A,
280 (__v8di)
281 _mm512_setzero_si512 (),
282 __M);
283#endif
284278}
279#endif
285280
286281static __inline __m512 __DEFAULT_FN_ATTRS
287282_mm512_setzero_ps(void)
deps/lld-prebuilt/lld/Config/Version.inc+2-2
......@@ -1,5 +1,5 @@
1#define LLD_VERSION 5.0.0
2#define LLD_VERSION_STRING "5.0.0"
1#define LLD_VERSION 5.0.1
2#define LLD_VERSION_STRING "5.0.1"
33#define LLD_VERSION_MAJOR 5
44#define LLD_VERSION_MINOR 0
55#define LLD_REVISION_STRING ""
deps/lld/COFF/Config.h+1
......@@ -157,6 +157,7 @@ struct Configuration {
157157 uint32_t MinorImageVersion = 0;
158158 uint32_t MajorOSVersion = 6;
159159 uint32_t MinorOSVersion = 0;
160 bool CanExitEarly = false;
160161 bool DynamicBase = true;
161162 bool NxCompat = true;
162163 bool AllowIsolation = true;
deps/lld/COFF/Driver.cpp+8-2
......@@ -52,15 +52,21 @@ BumpPtrAllocator BAlloc;
5252StringSaver Saver{BAlloc};
5353std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
5454
55bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
55bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
5656 ErrorCount = 0;
5757 ErrorOS = &Diag;
5858 Config = make<Configuration>();
5959 Config->Argv = {Args.begin(), Args.end()};
6060 Config->ColorDiagnostics =
6161 (ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
62 Config->CanExitEarly = CanExitEarly;
6263 Driver = make<LinkerDriver>();
6364 Driver->link(Args);
65
66 // Call exit() if we can to avoid calling destructors.
67 if (CanExitEarly)
68 exitLld(ErrorCount ? 1 : 0);
69
6470 freeArena();
6571 return !ErrorCount;
6672}
......@@ -1123,7 +1129,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
11231129 // This is useful because MSVC link.exe can generate complete PDBs.
11241130 if (Args.hasArg(OPT_msvclto)) {
11251131 invokeMSVC(Args);
1126 exit(0);
1132 return;
11271133 }
11281134
11291135 // Do LTO by compiling bitcode input files to a set of native COFF files then
deps/lld/COFF/Error.cpp+3-2
......@@ -32,7 +32,7 @@ namespace coff {
3232uint64_t ErrorCount;
3333raw_ostream *ErrorOS;
3434
35static LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) {
35LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) {
3636 // Dealloc/destroy ManagedStatic variables before calling
3737 // _exit(). In a non-LTO build, this is a nop. In an LTO
3838 // build allows us to get the output of -time-passes.
......@@ -78,7 +78,8 @@ void error(const Twine &Msg) {
7878 print("error: ", raw_ostream::RED);
7979 *ErrorOS << "too many errors emitted, stopping now"
8080 << " (use /ERRORLIMIT:0 to see all errors)\n";
81 exitLld(1);
81 if (Config->CanExitEarly)
82 exitLld(1);
8283 }
8384
8485 ++ErrorCount;
deps/lld/COFF/Error.h+2
......@@ -27,6 +27,8 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
2727LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix);
2828LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error &Err, const Twine &Prefix);
2929
30LLVM_ATTRIBUTE_NORETURN void exitLld(int Val);
31
3032template <class T> T check(ErrorOr<T> V, const Twine &Prefix) {
3133 if (auto EC = V.getError())
3234 fatal(EC, Prefix);
deps/lld/ELF/SyntheticSections.cpp+9-3
......@@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
427427 &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
428428
429429 // Search for an existing CIE by CIE contents/relocation target pair.
430 CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
430 CieRecord *&Cie = CieMap[{Piece.data(), Personality}];
431431
432432 // If not found, create a new one.
433 if (Cie->Piece == nullptr) {
433 if (!Cie) {
434 Cie = make<CieRecord>();
434435 Cie->Piece = &Piece;
435436 Cies.push_back(Cie);
436437 }
......@@ -522,9 +523,14 @@ template <class ELFT>
522523static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
523524 memcpy(Buf, D.data(), D.size());
524525
526 size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint));
527
528 // Zero-clear trailing padding if it exists.
529 memset(Buf + D.size(), 0, Aligned - D.size());
530
525531 // Fix the size field. -4 since size does not include the size field itself.
526532 const endianness E = ELFT::TargetEndianness;
527 write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
533 write32<E>(Buf, Aligned - 4);
528534}
529535
530536template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
deps/lld/ELF/SyntheticSections.h+2-1
......@@ -103,7 +103,8 @@ private:
103103 std::vector<CieRecord *> Cies;
104104
105105 // CIE records are uniquified by their contents and personality functions.
106 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
106 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
107 CieMap;
107108};
108109
109110class GotSection : public SyntheticSection {
deps/lld/include/lld/Driver/Driver.h+1-1
......@@ -15,7 +15,7 @@
1515
1616namespace lld {
1717namespace coff {
18bool link(llvm::ArrayRef<const char *> Args,
18bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly,
1919 llvm::raw_ostream &Diag = llvm::errs());
2020}
2121
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp-1
......@@ -621,7 +621,6 @@ void ArchHandler_x86_64::applyFixupFinal(
621621 // Fall into llvm_unreachable().
622622 break;
623623 }
624 return;
625624}
626625
627626void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,
deps/lld/test/ELF/eh-frame-padding-no-rosegment.s created+64
......@@ -0,0 +1,64 @@
1// REQUIRES: x86
2
3.cfi_startproc
4.cfi_personality 0x1b, bar
5.cfi_endproc
6
7.global bar
8.hidden bar
9bar:
10
11// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
12
13// Check the size of the CIE (0x18 + 4) and FDE (0x10 + 4)
14// RUN: llvm-readobj -s -section-data %t.o | FileCheck --check-prefix=OBJ %s
15
16// OBJ: Name: .eh_frame
17// OBJ-NEXT: Type:
18// OBJ-NEXT: Flags [
19// OBJ-NEXT: SHF_ALLOC
20// OBJ-NEXT: ]
21// OBJ-NEXT: Address:
22// OBJ-NEXT: Offset:
23// OBJ-NEXT: Size:
24// OBJ-NEXT: Link:
25// OBJ-NEXT: Info:
26// OBJ-NEXT: AddressAlignment:
27// OBJ-NEXT: EntrySize:
28// OBJ-NEXT: SectionData (
29// OBJ-NEXT: 0000: 18000000 00000000 017A5052 00017810
30// OBJ-NEXT: 0010: 061B0000 00001B0C 07089001 10000000
31// OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000
32// OBJ-NEXT: )
33
34// RUN: ld.lld %t.o -no-rosegment -o %t -shared
35
36// Check that .eh_frame is in the same segment as .text
37// RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s
38
39// PHDR: Segment Sections
40// PHDR: .text
41// PHDR-SAME: .eh_frame
42
43// Check that the CIE and FDE are padded with 0x00 and not 0xCC when the
44// .eh_frame section is placed in the executable segment
45// RUN: llvm-readobj -s -section-data %t | FileCheck %s
46
47// CHECK: Name: .eh_frame
48// CHECK-NEXT: Type:
49// CHECK-NEXT: Flags
50// CHECK-NEXT: SHF_ALLOC
51// CHECK-NEXT: ]
52// CHECK-NEXT: Address:
53// CHECK-NEXT: Offset:
54// CHECK-NEXT: Size:
55// CHECK-NEXT: Link:
56// CHECK-NEXT: Info:
57// CHECK-NEXT: AddressAlignment:
58// CHECK-NEXT: EntrySize:
59// CHECK-NEXT: SectionData (
60// CHECK-NEXT: 0000: 1C000000 00000000 017A5052 00017810
61// CHECK-NEXT: 0010: 061BBEFF FFFF1B0C 07089001 00000000
62// CHECK-NEXT: 0020: 14000000 24000000 A8FFFFFF 00000000
63// CHECK-NEXT: 0030: 00000000 00000000
64// CHECK-NEXT: )
deps/lld/tools/lld/lld.cpp+1-1
......@@ -103,7 +103,7 @@ int main(int Argc, const char **Argv) {
103103 case Gnu:
104104 return !elf::link(Args, true);
105105 case WinLink:
106 return !coff::link(Args);
106 return !coff::link(Args, true);
107107 case Darwin:
108108 return !mach_o::link(Args);
109109 default:
src/zig_llvm.cpp+1-1
......@@ -789,7 +789,7 @@ bool ZigLLDLink(ZigLLVM_ObjectFormatType oformat, const char **args, size_t arg_
789789 zig_unreachable();
790790
791791 case ZigLLVM_COFF:
792 return lld::coff::link(array_ref_args);
792 return lld::coff::link(array_ref_args, false, diag);
793793
794794 case ZigLLVM_ELF:
795795 return lld::elf::link(array_ref_args, false, diag);