Merge branch 'llvm5.0.1'

master
Andrew Kelley 2017-12-01 13:51:53 -05:00
commit 921825b4c0
14 changed files with 104 additions and 24 deletions

View File

@ -47,15 +47,20 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead of the embedded LLD" OFF)
find_package(llvm)
include_directories(${LLVM_INCLUDE_DIRS})
find_package(clang)
include_directories(${CLANG_INCLUDE_DIRS})
if(ZIG_FORCE_EXTERNAL_LLD)
find_package(lld)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${LLD_INCLUDE_DIRS})
include_directories(${CLANG_INCLUDE_DIRS})
else()
# This goes first so that we find embedded LLD instead
# of system LLD.
include_directories("${CMAKE_SOURCE_DIR}/deps/lld/include")
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CLANG_INCLUDE_DIRS})
set(EMBEDDED_LLD_LIB_SOURCES
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Driver/DarwinLdDriver.cpp"
"${CMAKE_SOURCE_DIR}/deps/lld/lib/Config/Version.cpp"

View File

@ -267,21 +267,16 @@ _mm512_maskz_set1_epi32(__mmask16 __M, int __A)
__M);
}
#ifdef __x86_64__
static __inline __m512i __DEFAULT_FN_ATTRS
_mm512_maskz_set1_epi64(__mmask8 __M, long long __A)
{
#ifdef __x86_64__
return (__m512i) __builtin_ia32_pbroadcastq512_gpr_mask (__A,
(__v8di)
_mm512_setzero_si512 (),
__M);
#else
return (__m512i) __builtin_ia32_pbroadcastq512_mem_mask (__A,
(__v8di)
_mm512_setzero_si512 (),
__M);
#endif
}
#endif
static __inline __m512 __DEFAULT_FN_ATTRS
_mm512_setzero_ps(void)

View File

@ -1,5 +1,5 @@
#define LLD_VERSION 5.0.0
#define LLD_VERSION_STRING "5.0.0"
#define LLD_VERSION 5.0.1
#define LLD_VERSION_STRING "5.0.1"
#define LLD_VERSION_MAJOR 5
#define LLD_VERSION_MINOR 0
#define LLD_REVISION_STRING ""

View File

@ -157,6 +157,7 @@ struct Configuration {
uint32_t MinorImageVersion = 0;
uint32_t MajorOSVersion = 6;
uint32_t MinorOSVersion = 0;
bool CanExitEarly = false;
bool DynamicBase = true;
bool NxCompat = true;
bool AllowIsolation = true;

View File

@ -52,15 +52,21 @@ BumpPtrAllocator BAlloc;
StringSaver Saver{BAlloc};
std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
bool link(ArrayRef<const char *> Args, raw_ostream &Diag) {
bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) {
ErrorCount = 0;
ErrorOS = &Diag;
Config = make<Configuration>();
Config->Argv = {Args.begin(), Args.end()};
Config->ColorDiagnostics =
(ErrorOS == &llvm::errs() && Process::StandardErrHasColors());
Config->CanExitEarly = CanExitEarly;
Driver = make<LinkerDriver>();
Driver->link(Args);
// Call exit() if we can to avoid calling destructors.
if (CanExitEarly)
exitLld(ErrorCount ? 1 : 0);
freeArena();
return !ErrorCount;
}
@ -1123,7 +1129,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// This is useful because MSVC link.exe can generate complete PDBs.
if (Args.hasArg(OPT_msvclto)) {
invokeMSVC(Args);
exit(0);
return;
}
// Do LTO by compiling bitcode input files to a set of native COFF files then

View File

@ -32,7 +32,7 @@ namespace coff {
uint64_t ErrorCount;
raw_ostream *ErrorOS;
static LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) {
LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) {
// Dealloc/destroy ManagedStatic variables before calling
// _exit(). In a non-LTO build, this is a nop. In an LTO
// build allows us to get the output of -time-passes.
@ -78,7 +78,8 @@ void error(const Twine &Msg) {
print("error: ", raw_ostream::RED);
*ErrorOS << "too many errors emitted, stopping now"
<< " (use /ERRORLIMIT:0 to see all errors)\n";
exitLld(1);
if (Config->CanExitEarly)
exitLld(1);
}
++ErrorCount;

View File

@ -27,6 +27,8 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix);
LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error &Err, const Twine &Prefix);
LLVM_ATTRIBUTE_NORETURN void exitLld(int Val);
template <class T> T check(ErrorOr<T> V, const Twine &Prefix) {
if (auto EC = V.getError())
fatal(EC, Prefix);

View File

@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece,
&Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]);
// Search for an existing CIE by CIE contents/relocation target pair.
CieRecord *Cie = &CieMap[{Piece.data(), Personality}];
CieRecord *&Cie = CieMap[{Piece.data(), Personality}];
// If not found, create a new one.
if (Cie->Piece == nullptr) {
if (!Cie) {
Cie = make<CieRecord>();
Cie->Piece = &Piece;
Cies.push_back(Cie);
}
@ -522,9 +523,14 @@ template <class ELFT>
static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
memcpy(Buf, D.data(), D.size());
size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint));
// Zero-clear trailing padding if it exists.
memset(Buf + D.size(), 0, Aligned - D.size());
// Fix the size field. -4 since size does not include the size field itself.
const endianness E = ELFT::TargetEndianness;
write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
write32<E>(Buf, Aligned - 4);
}
template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {

View File

@ -103,7 +103,8 @@ private:
std::vector<CieRecord *> Cies;
// CIE records are uniquified by their contents and personality functions.
llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
CieMap;
};
class GotSection : public SyntheticSection {

View File

@ -15,7 +15,7 @@
namespace lld {
namespace coff {
bool link(llvm::ArrayRef<const char *> Args,
bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly,
llvm::raw_ostream &Diag = llvm::errs());
}

View File

@ -621,7 +621,6 @@ void ArchHandler_x86_64::applyFixupFinal(
// Fall into llvm_unreachable().
break;
}
return;
}
void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref,

View File

@ -0,0 +1,64 @@
// REQUIRES: x86
.cfi_startproc
.cfi_personality 0x1b, bar
.cfi_endproc
.global bar
.hidden bar
bar:
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// Check the size of the CIE (0x18 + 4) and FDE (0x10 + 4)
// RUN: llvm-readobj -s -section-data %t.o | FileCheck --check-prefix=OBJ %s
// OBJ: Name: .eh_frame
// OBJ-NEXT: Type:
// OBJ-NEXT: Flags [
// OBJ-NEXT: SHF_ALLOC
// OBJ-NEXT: ]
// OBJ-NEXT: Address:
// OBJ-NEXT: Offset:
// OBJ-NEXT: Size:
// OBJ-NEXT: Link:
// OBJ-NEXT: Info:
// OBJ-NEXT: AddressAlignment:
// OBJ-NEXT: EntrySize:
// OBJ-NEXT: SectionData (
// OBJ-NEXT: 0000: 18000000 00000000 017A5052 00017810
// OBJ-NEXT: 0010: 061B0000 00001B0C 07089001 10000000
// OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000
// OBJ-NEXT: )
// RUN: ld.lld %t.o -no-rosegment -o %t -shared
// Check that .eh_frame is in the same segment as .text
// RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s
// PHDR: Segment Sections
// PHDR: .text
// PHDR-SAME: .eh_frame
// Check that the CIE and FDE are padded with 0x00 and not 0xCC when the
// .eh_frame section is placed in the executable segment
// RUN: llvm-readobj -s -section-data %t | FileCheck %s
// CHECK: Name: .eh_frame
// CHECK-NEXT: Type:
// CHECK-NEXT: Flags
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
// CHECK-NEXT: Address:
// CHECK-NEXT: Offset:
// CHECK-NEXT: Size:
// CHECK-NEXT: Link:
// CHECK-NEXT: Info:
// CHECK-NEXT: AddressAlignment:
// CHECK-NEXT: EntrySize:
// CHECK-NEXT: SectionData (
// CHECK-NEXT: 0000: 1C000000 00000000 017A5052 00017810
// CHECK-NEXT: 0010: 061BBEFF FFFF1B0C 07089001 00000000
// CHECK-NEXT: 0020: 14000000 24000000 A8FFFFFF 00000000
// CHECK-NEXT: 0030: 00000000 00000000
// CHECK-NEXT: )

View File

@ -103,7 +103,7 @@ int main(int Argc, const char **Argv) {
case Gnu:
return !elf::link(Args, true);
case WinLink:
return !coff::link(Args);
return !coff::link(Args, true);
case Darwin:
return !mach_o::link(Args);
default:

View File

@ -789,7 +789,7 @@ bool ZigLLDLink(ZigLLVM_ObjectFormatType oformat, const char **args, size_t arg_
zig_unreachable();
case ZigLLVM_COFF:
return lld::coff::link(array_ref_args);
return lld::coff::link(array_ref_args, false, diag);
case ZigLLVM_ELF:
return lld::elf::link(array_ref_args, false, diag);