[PATCH] D143229: [FunctionImporter] Don't upgrade debug info if llvm.idents match

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 11:25:06 PST 2023


aeubanks updated this revision to Diff 495902.
aeubanks added a comment.

put under a flag


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143229/new/

https://reviews.llvm.org/D143229

Files:
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/test/LTO/X86/strip-debug-info.ll


Index: llvm/test/LTO/X86/strip-debug-info.ll
===================================================================
--- llvm/test/LTO/X86/strip-debug-info.ll
+++ llvm/test/LTO/X86/strip-debug-info.ll
@@ -24,10 +24,18 @@
 ; RUN:     -exported-symbol foo -exported-symbol _foo \
 ; RUN:     %t-stripped.bc -disable-verify 2>&1 | \
 ; RUN:     FileCheck %s -allow-empty -check-prefix=CHECK-WARN
+; ---- Thin LTO (optimize, don't strip imported file)
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t-stripped.bc %t2.bc
+; RUN: llvm-lto -thinlto -thinlto-action=import -bitcode-built-from-same-version \
+; RUN:     -thinlto-index=%t.index.bc \
+; RUN:     -exported-symbol foo -exported-symbol _foo \
+; RUN:     %t-stripped.bc -disable-verify 2>&1 | \
+; RUN:     FileCheck %s -allow-empty -check-prefix=CHECK-NO-WARN
 
 ; CHECK-WARN: warning{{.*}} ignoring invalid debug info
 ; CHECK-WARN-NOT: Broken module found
 ; CHECK: foo
+; CHECK-NO-WARN-NOT: ignoring invalid debug info
 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.12"
 
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -82,6 +82,11 @@
     "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
     cl::desc("Only import first N functions if N>=0 (default -1)"));
 
+static cl::opt<bool> InputBitcodeBuiltFromSameVersion(
+    "bitcode-built-from-same-version", cl::init(false), cl::Hidden,
+    cl::desc("Assume that imported functions are built at the same revision of "
+             "LLVM as this consumer to avoid upgrading debug info"));
+
 static cl::opt<bool>
     ForceImportAll("force-import-all", cl::init(false), cl::Hidden,
                    cl::desc("Import functions with noinline attribute"));
@@ -1351,7 +1356,8 @@
 
     // Upgrade debug info after we're done materializing all the globals and we
     // have loaded all the required metadata!
-    UpgradeDebugInfo(*SrcModule);
+    if (!InputBitcodeBuiltFromSameVersion)
+      UpgradeDebugInfo(*SrcModule);
 
     // Set the partial sample profile ratio in the profile summary module flag
     // of the imported source module, if applicable, so that the profile summary


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143229.495902.patch
Type: text/x-patch
Size: 2375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230208/b4d22aca/attachment.bin>


More information about the llvm-commits mailing list