From ac406dfb70a4c2353230afc83dbcfa05bbcdb79e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 27 Mar 2015 15:55:06 +0000 Subject: [PATCH] Work around pr23045 and make it easier to reproduce. Dropping old debug format requires the entire module to be read upfront. This was failing only with the gold plugin, but that is just because llvm-link was not upgrading metadata. The new testcase using llvm-link shows the problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233381 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Linker/Inputs/drop-debug.bc | Bin 0 -> 1152 bytes test/Linker/drop-debug.ll | 6 ++++++ tools/gold/gold-plugin.cpp | 8 +++++--- tools/llvm-link/llvm-link.cpp | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 test/Linker/Inputs/drop-debug.bc create mode 100644 test/Linker/drop-debug.ll diff --git a/test/Linker/Inputs/drop-debug.bc b/test/Linker/Inputs/drop-debug.bc new file mode 100644 index 0000000000000000000000000000000000000000..f9c471f8e0d1e6960c4efb96961bc1799c3c2bb4 GIT binary patch literal 1152 zcmZuxO=ufO6dwIpv$j^Nb)vTGW_Fp4lj2KZ>l9&I7D(E(vB3qkIn>9Mu!9M-UH_mz z_pp*&twPnHBrWLBgEqL}-U7Yk(1TVsLKrouIT>Mu)!2#&c5K?v=GKl}(^DVJ%$s>{ z-uvG7h6%})wnziOTL5roFt7puE|3A!!}o%9`?P}{9lvi`qp$W+LxTP5s78Na4c&K! z=Gals7{yHwj9$MoHBc0Xw?5J6A#v#ntk>D-MtLJpJ0&5(#~c73k@eE;;n#l?u@p54 z?--~X5n4dlH&9LFy9R1i(4N6p(+Dh6Fjmr+02NQ@UI`{CJvO3yH9bBB<7IuRsC!3X zY)X%T!=UiOK$^+74Ob&5R1JRHaP4*YrzU@Bpnb!&o#vk!e5=B@O}?e^+ahXM@NS21 zVSd*{U2@AJw8|u@(6mUps_4lPsHu88&|ULk=CdY~B6E?61z<{n zD@{jNgK8NrVwh+;UTQGK!dMwD<8$jzEL_r{{I&&X1Q!wPw4Y-XO6<_!OtH}a&W)N~ z{*4OsdxCeYnKwRMv}L|~AJ6_sbQ~1JH^6Oe(h8EK&QD1Ic`U%(1IUT4$hk8FeiJX>z^8?}(_a@jIr_>bOWNx@looL2rh?(3q1Zb8zZ7 zkld$5=4F66sW6>W$5Dm(v&lF&78PAp^<`jN9f8S`zLJ1(kR4aE6KZx0WcwAMZK#G4p)S@ht4VX;rRoogW^bGW%ioQJDE$VUAelx#YfSuMHWG zY`z`Y_c%CFl*b?2{4@Qyho;BzTV%aPX=tm1Zh0*JygatHSqNz`nSjfsMY;>z$1L+o zW3JI5p=$C^40KECJ9EokYS{dB*T>b%QnSV_H literal 0 HcmV?d00001 diff --git a/test/Linker/drop-debug.ll b/test/Linker/drop-debug.ll new file mode 100644 index 00000000000..9c1072a75de --- /dev/null +++ b/test/Linker/drop-debug.ll @@ -0,0 +1,6 @@ +; RUN: llvm-link %p/Inputs/drop-debug.bc -o %t 2>&1 | FileCheck %s + +;; drop-debug.bc was created from "void f(void) {}" with clang 3.5 and +; -gline-tables-only, so it contains old debug info. + +; CHECK: warning: ignoring debug info with an invalid version (1) in {{.*}}/Inputs/drop-debug.bc diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 93ce3bc0f44..16e5045bcb9 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -20,7 +20,6 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/CodeGen/Analysis.h" #include "llvm/CodeGen/CommandFlags.h" -#include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" @@ -603,8 +602,11 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, Module &M = Obj.getModule(); - M.materializeMetadata(); - UpgradeDebugInfo(M); + // Fixme (pr23045). We would like to upgrade the metadata with something like + // Result->materializeMetadata(); + // UpgradeDebugInfo(*Result); + // but that fails to drop old debug info from function bodies. + M.materializeAllPermanently(); SmallPtrSet Used; collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false); diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index e52191a267b..a15855b392a 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -69,6 +69,12 @@ loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) { if (!Result) Err.print(argv0, errs()); + // Fixme (pr23045). We would like to upgrade the metadata with something like + // Result->materializeMetadata(); + // UpgradeDebugInfo(*Result); + // but that fails to drop old debug info from function bodies. + Result->materializeAllPermanently(); + return Result; } -- 2.34.1