diff options
author | Davide Italiano <davide@freebsd.org> | 2016-05-11 01:07:22 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2016-05-11 01:07:22 +0000 |
commit | 334fce92d96127994e84b75ae18a7bf471c66367 (patch) | |
tree | e23f60a0350ecb8495e335c2c4ea4609a73108ca | |
parent | 68e3aa7f302459b0ae1b3327a08ed3ad73e2c04c (diff) | |
download | bcm5719-llvm-334fce92d96127994e84b75ae18a7bf471c66367.tar.gz bcm5719-llvm-334fce92d96127994e84b75ae18a7bf471c66367.zip |
[LTO] Don't crash on old DebugInfo.
Drop them and produce a graceful warning instead.
llvm-svn: 269149
-rw-r--r-- | lld/ELF/LTO.cpp | 5 | ||||
-rw-r--r-- | lld/test/ELF/lto/Inputs/drop-debug-info.bc | bin | 0 -> 1152 bytes | |||
-rw-r--r-- | lld/test/ELF/lto/drop-debug-info.ll | 9 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 9f2457f1277..8ff90f61cc1 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -18,6 +18,7 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/CodeGen/ParallelCG.h" +#include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/Linker/IRMover.h" #include "llvm/Support/StringSaver.h" @@ -100,6 +101,10 @@ void BitcodeCompiler::add(BitcodeFile &F) { if (M.getDataLayoutStr().empty()) fatal("invalid bitcode file: " + F.getName() + " has no datalayout"); + // Discard non-compatible debug infos if necessary. + M.materializeMetadata(); + UpgradeDebugInfo(M); + // If a symbol appears in @llvm.used, the linker is required // to treat the symbol as there is a reference to the symbol // that it cannot see. Therefore, we can't internalize. diff --git a/lld/test/ELF/lto/Inputs/drop-debug-info.bc b/lld/test/ELF/lto/Inputs/drop-debug-info.bc Binary files differnew file mode 100644 index 00000000000..f9c471f8e0d --- /dev/null +++ b/lld/test/ELF/lto/Inputs/drop-debug-info.bc diff --git a/lld/test/ELF/lto/drop-debug-info.ll b/lld/test/ELF/lto/drop-debug-info.ll new file mode 100644 index 00000000000..7a7ed5ea41d --- /dev/null +++ b/lld/test/ELF/lto/drop-debug-info.ll @@ -0,0 +1,9 @@ +; REQUIRES: x86 +; +; drop-debug-info.bc was created from "void f(void) {}" with clang 3.5 and +; -gline-tables-only, so it contains old debug info. +; +; RUN: ld.lld -m elf_x86_64 -shared %p/Inputs/drop-debug-info.bc \ +; RUN: -disable-verify 2>&1 | FileCheck %s +; CHECK: warning: ignoring debug info with an invalid version (1) in {{.*}}drop-debug-info.bc + |