[llvm] r233381 - Work around pr23045 and make it easier to reproduce.

Rafael Espindola rafael.espindola at gmail.com
Fri Mar 27 08:55:07 PDT 2015


Author: rafael
Date: Fri Mar 27 10:55:06 2015
New Revision: 233381

URL: http://llvm.org/viewvc/llvm-project?rev=233381&view=rev
Log:
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.

Added:
    llvm/trunk/test/Linker/Inputs/drop-debug.bc
    llvm/trunk/test/Linker/drop-debug.ll
Modified:
    llvm/trunk/tools/gold/gold-plugin.cpp
    llvm/trunk/tools/llvm-link/llvm-link.cpp

Added: llvm/trunk/test/Linker/Inputs/drop-debug.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/drop-debug.bc?rev=233381&view=auto
==============================================================================
Binary files llvm/trunk/test/Linker/Inputs/drop-debug.bc (added) and llvm/trunk/test/Linker/Inputs/drop-debug.bc Fri Mar 27 10:55:06 2015 differ

Added: llvm/trunk/test/Linker/drop-debug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/drop-debug.ll?rev=233381&view=auto
==============================================================================
--- llvm/trunk/test/Linker/drop-debug.ll (added)
+++ llvm/trunk/test/Linker/drop-debug.ll Fri Mar 27 10:55:06 2015
@@ -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

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=233381&r1=233380&r2=233381&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Fri Mar 27 10:55:06 2015
@@ -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, c
 
   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<GlobalValue *, 8> Used;
   collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false);

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=233381&r1=233380&r2=233381&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Fri Mar 27 10:55:06 2015
@@ -69,6 +69,12 @@ loadFile(const char *argv0, const std::s
   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;
 }
 





More information about the llvm-commits mailing list