[llvm] r278615 - Fix bitcode auto-upgrade when using bitcode lazy loading

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 13 17:01:27 PDT 2016


Author: mehdi_amini
Date: Sat Aug 13 19:01:27 2016
New Revision: 278615

URL: http://llvm.org/viewvc/llvm-project?rev=278615&view=rev
Log:
Fix bitcode auto-upgrade when using bitcode lazy loading

The auto-upgrade path could be called before the VST (global
names) was fully parsed, and thus intrinsic names were not
available and the autoupgrade logic could not operate.

Fix link failures with ThinLTO.

This is a recommit of r278610 with a different fix.

Added:
    llvm/trunk/test/ThinLTO/X86/Inputs/autoupgrade.bc
    llvm/trunk/test/ThinLTO/X86/autoupgrade.ll
Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=278615&r1=278614&r2=278615&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat Aug 13 19:01:27 2016
@@ -3682,7 +3682,9 @@ std::error_code BitcodeReader::parseModu
         // have been seen yet. In this case, just finish the parse now.
         if (SeenValueSymbolTable) {
           NextUnreadBit = Stream.GetCurrentBitNo();
-          return std::error_code();
+          // After the VST has been parsed, we need to make sure intrinsic name
+          // are auto-upgraded.
+          return globalCleanup();
         }
         break;
       case bitc::USELIST_BLOCK_ID:

Added: llvm/trunk/test/ThinLTO/X86/Inputs/autoupgrade.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/autoupgrade.bc?rev=278615&view=auto
==============================================================================
Binary files llvm/trunk/test/ThinLTO/X86/Inputs/autoupgrade.bc (added) and llvm/trunk/test/ThinLTO/X86/Inputs/autoupgrade.bc Sat Aug 13 19:01:27 2016 differ

Added: llvm/trunk/test/ThinLTO/X86/autoupgrade.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/autoupgrade.ll?rev=278615&view=auto
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/autoupgrade.ll (added)
+++ llvm/trunk/test/ThinLTO/X86/autoupgrade.ll Sat Aug 13 19:01:27 2016
@@ -0,0 +1,23 @@
+; Verify that auto-upgrading intrinsics works with Lazy loaded bitcode
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %p/Inputs/autoupgrade.bc
+
+; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc -o - | llvm-bcanalyzer -dump | FileCheck %s
+
+; We can't use llvm-dis here, because it would do the autoupgrade itself.
+
+; CHECK-NOT: 'llvm.invariant.start'
+; CHECK: record string = 'llvm.invariant.start.p0i8'
+; CHECK-NOT: 'llvm.invariant.start'
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+define i32 @main() #0 {
+entry:
+  call void (...) @globalfunc1()
+  ret i32 0
+}
+
+declare void @globalfunc1(...) #1




More information about the llvm-commits mailing list