<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Mar 2, 2018 at 4:03 PM Teresa Johnson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 2, 2018 at 3:43 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry for the trouble, but this patch introduced multiple failures for us with ThinLTO. We're seeing link failures due to missing symbols as well as runtime failures.<div><br></div><div><a class="m_7428358921693877826m_5971008527850850986m_-2862663351128771654m_-3249117264373797138GWVZpf m_7428358921693877826m_5971008527850850986m_-2862663351128771654m_-3249117264373797138gW" id="m_7428358921693877826m_5971008527850850986m_-2862663351128771654m_-3249117264373797138IloFPc-0" href="mailto:tejohnson@google.com" target="_blank">+Teresa Johnson</a> is going to work on getting test cases for these, but it'll probably be Monday or Tuesday when we can make progress there. For now, I've reverted this in r326638 so that the tree is back to green.<br></div><div><br></div><div>Note that I'm also deeply troubled by the data race mentioned. Turning off threads doesn't fix a data race, it just hides it. The code really needs to be made thread safe and that should probably happen prior to re-committing the patch. I've reverted r325361 and r325362 as well for now, but they probably shouldn't be re-introduced and instead the data race issue fixed.</div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>The description of it being a data race is incorrect - it was just interleaved debug/trace output that is being checked (i.e. the list of imported functions/variables emitted under debug option in the backends). The backend parallelism needs to be turned down to 1 to get deterministic messages from the otherwise parallel backends. </div></div></div></div></blockquote><div><br></div><div>Ahhh, that description makes *much* more sense, thanks. Of course, feel free to just roll all this together then once the issues are sorted. Sorry for my confusion on this point.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Teresa</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,</div><div>-Chandler</div></div><div class="m_7428358921693877826m_5971008527850850986m_-2862663351128771654HOEnZb"><div class="m_7428358921693877826m_5971008527850850986m_-2862663351128771654h5"><br><div class="gmail_quote"><div dir="ltr">On Fri, Feb 16, 2018 at 8:58 AM Evgeny Leviant via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">See r325361<br>
________________________________________<br>
От: David Green <<a href="mailto:David.Green@arm.com" target="_blank">David.Green@arm.com</a>><br>
Отправлено: 16 февраля 2018 г. 19:37<br>
Кому: Evgeny Leviant; llvm-commits<br>
Копия: nd<br>
Тема: Re: [llvm] r325320 - [ThinLTO] Import global variables<br>
<br>
Hello again,<br>
<br>
Looking through the llvm-lto2 help, perhaps adding -thinlto-threads=1 to this specific test is all we need? At least to get the output correct.<br>
<br>
That seems to work here, it just depends whether -print-imports should be thread safe or not?<br>
Dave<br>
<br>
________________________________________<br>
From: David Green<br>
Sent: 16 February 2018 16:20:15<br>
To: Evgeny Leviant; llvm-commits<br>
Cc: nd<br>
Subject: Re: [llvm] r325320 - [ThinLTO] Import global variables<br>
<br>
Yeah, no probs. Like I said the error seems quite rare. If I spam this command then it eventually fails (but it may not on your machine if it's an thread-timing problem) (plus, sorry for the paths):<br>
<br>
/work/llvm-git/build/bin/llvm-lto2 run -save-temps -o /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp3 /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp.bc /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp2.bc -r /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp.bc,fptr,plx -r /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp.bc,main,plx -r /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp2.bc,_Z6updatei,pl -r /work/llvm-git/build/test/Transforms/PGOProfile/Output/thinlto_samplepgo_icp3.ll.tmp2.bc,fptr,l -print-imports 2>&1 | tee output.txt | /work/llvm-git/build/bin/FileCheck /work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll --check-prefix=IMPORTS<br>
<br>
I just noticed that before this commit, it would print:<br>
/work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll: Import _ZL3foov.llvm.0 from /work/llvm-git/test/Transforms/PGOProfile/Inputs/thinlto_samplepgo_icp3.ll<br>
<br>
i.e no second output ("fptr") for it to interleave.<br>
<br>
I've attached the thinlto_samplepgo_icp3.ll.tmp.bc and thinlto_samplepgo_icp3.ll.tmp2.bc files, but I don't think they change between passing and failing runs, it's just the output of the llvm-lto2 that is different.<br>
<br>
Let me know if I can do anything else,<br>
Thanks,<br>
Dave<br>
<br>
<br>
From: Evgeny Leviant <<a href="mailto:eleviant@accesssoftek.com" target="_blank">eleviant@accesssoftek.com</a>><br>
Sent: 16 February 2018 16:06<br>
To: David Green; llvm-commits<br>
Cc: nd<br>
Subject: Re: [llvm] r325320 - [ThinLTO] Import global variables<br>
<br>
Hello David,<br>
<br>
I got single buildbot failure today, but I can't reproduce this failure locally<br>
Can you please send test artifacts (BC files, e.t.c) when it fails? Thanks.<br>
________________________________________<br>
От: David Green <<a href="mailto:David.Green@arm.com" target="_blank">David.Green@arm.com</a>><br>
Отправлено: 16 февраля 2018 г. 19:04<br>
Кому: Evgeny Leviant; llvm-commits<br>
Копия: nd<br>
Тема: Re: [llvm] r325320 - [ThinLTO] Import global variables<br>
<br>
Hello Eugene,<br>
<br>
After this patch, about 1 time in 20 I'm seeing failures in Transforms/PGOProfile/thinlto_samplepgo_icp3.ll. When it passes it prints something like:<br>
/work/llvm-git/test/Transforms/PGOProfile/Inputs/thinlto_samplepgo_icp3.ll: Import fptr from /work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll<br>
/work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll: Import _ZL3foov.llvm.0 from /work/llvm-git/test/Transforms/PGOProfile/Inputs/thinlto_samplepgo_icp3.ll<br>
<br>
When it fails it prints:<br>
/work/llvm-git/test/Transforms/PGOProfile/Inputs/thinlto_samplepgo_icp3.ll/work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll: Import : Import fptr_ZL3foov.llvm.0 from /work/llvm-git/test/Transforms/PGOProfile/thinlto_samplepgo_icp3.ll from<br>
/work/llvm-git/test/Transforms/PGOProfile/Inputs/thinlto_samplepgo_icp3.ll<br>
<br>
I cant reproduce before this patch, but don't see anything very thread-y in here that may be causing this. Perhaps some knock-on affect? Perhaps it's printing more output now?<br>
<br>
Any ideas?<br>
Thanks,<br>
Dave<br>
<br>
<br>
<br>
From: llvm-commits <<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a>> on behalf of Eugene Leviant via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><br>
Sent: 16 February 2018 08:11<br>
To: <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
Subject: [llvm] r325320 - [ThinLTO] Import global variables<br>
<br>
Author: evgeny777<br>
Date: Fri Feb 16 00:11:04 2018<br>
New Revision: 325320<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=325320&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=325320&view=rev</a><br>
Log:<br>
[ThinLTO] Import global variables<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D43077" rel="noreferrer" target="_blank">https://reviews.llvm.org/D43077</a><br>
<br>
Added:<br>
    llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll<br>
    llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll<br>
Modified:<br>
    llvm/trunk/lib/Linker/IRMover.cpp<br>
    llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp<br>
    llvm/trunk/test/Transforms/FunctionImport/funcimport.ll<br>
<br>
Modified: llvm/trunk/lib/Linker/IRMover.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=325320&r1=325319&r2=325320&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=325320&r1=325319&r2=325320&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Linker/IRMover.cpp (original)<br>
+++ llvm/trunk/lib/Linker/IRMover.cpp Fri Feb 16 00:11:04 2018<br>
@@ -1051,14 +1051,10 @@ void IRLinker::prepareCompileUnitsForImp<br>
     ValueMap.MD()[CU->getRawEnumTypes()].reset(nullptr);<br>
     ValueMap.MD()[CU->getRawMacros()].reset(nullptr);<br>
     ValueMap.MD()[CU->getRawRetainedTypes()].reset(nullptr);<br>
-    // If we ever start importing global variable defs, we'll need to<br>
-    // add their DIGlobalVariable to the globals list on the imported<br>
-    // DICompileUnit. Confirm none are imported, and then we can<br>
-    // map the list of global variables to nullptr.<br>
-    assert(none_of(<br>
-               ValuesToLink,<br>
-               [](const GlobalValue *GV) { return isa<GlobalVariable>(GV); }) &&<br>
-           "Unexpected importing of a GlobalVariable definition");<br>
+    // We import global variables only temporarily in order for instcombine<br>
+    // and globalopt to perform constant folding and static constructor<br>
+    // evaluation. After that elim-avail-extern will covert imported globals<br>
+    // back to declarations, so we don't need debug info for them.<br>
     ValueMap.MD()[CU->getRawGlobalVariables()].reset(nullptr);<br>
<br>
     // Imported entities only need to be mapped in if they have local<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=325320&r1=325319&r2=325320&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=325320&r1=325319&r2=325320&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Fri Feb 16 00:11:04 2018<br>
@@ -61,6 +61,7 @@ using namespace llvm;<br>
 #define DEBUG_TYPE "function-import"<br>
<br>
 STATISTIC(NumImportedFunctions, "Number of functions imported");<br>
+STATISTIC(NumImportedGlobalVars, "Number of global variables imported");<br>
 STATISTIC(NumImportedModules, "Number of modules imported from");<br>
 STATISTIC(NumDeadSymbols, "Number of dead stripped symbols in index");<br>
 STATISTIC(NumLiveSymbols, "Number of live symbols in index");<br>
@@ -238,6 +239,33 @@ updateValueInfoForIndirectCalls(const Mo<br>
   return Index.getValueInfo(GUID);<br>
 }<br>
<br>
+static void computeImportForReferencedGlobals(<br>
+    const FunctionSummary &Summary, const GVSummaryMapTy &DefinedGVSummaries,<br>
+    FunctionImporter::ImportMapTy &ImportList,<br>
+    StringMap<FunctionImporter::ExportSetTy> *ExportLists) {<br>
+  for (auto &VI : Summary.refs()) {<br>
+    if (DefinedGVSummaries.count(VI.getGUID())) {<br>
+      DEBUG(dbgs() << "Ref ignored! Target already in destination module.\n");<br>
+      continue;<br>
+    }<br>
+<br>
+    DEBUG(dbgs() << " ref -> " << VI.getGUID() << "\n");<br>
+<br>
+    for (auto &RefSummary : VI.getSummaryList())<br>
+      if (RefSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind &&<br>
+          // Don't try to import regular LTO summaries added to dummy module.<br>
+          !RefSummary->modulePath().empty() &&<br>
+          !GlobalValue::isInterposableLinkage(RefSummary->linkage()) &&<br>
+          // For now we don't import global variables which have outgoing<br>
+          // refs. Otherwise we have to promote referenced vars/functions.<br>
+          RefSummary->refs().empty()) {<br>
+        ImportList[RefSummary->modulePath()][VI.getGUID()] = 1;<br>
+        if (ExportLists)<br>
+          (*ExportLists)[RefSummary->modulePath()].insert(VI.getGUID());<br>
+      }<br>
+  }<br>
+}<br>
+<br>
 /// Compute the list of functions to import for a given caller. Mark these<br>
 /// imported functions and the symbols they reference in their source module as<br>
 /// exported from their source module.<br>
@@ -247,6 +275,8 @@ static void computeImportForFunction(<br>
     SmallVectorImpl<EdgeInfo> &Worklist,<br>
     FunctionImporter::ImportMapTy &ImportList,<br>
     StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) {<br>
+  computeImportForReferencedGlobals(Summary, DefinedGVSummaries, ImportList,<br>
+                                    ExportLists);<br>
   for (auto &Edge : Summary.calls()) {<br>
     ValueInfo VI = Edge.first;<br>
     DEBUG(dbgs() << " edge -> " << VI.getGUID() << " Threshold:" << Threshold<br>
@@ -389,6 +419,34 @@ static void ComputeImportForModule(<br>
   }<br>
 }<br>
<br>
+#ifndef NDEBUG<br>
+static bool isGlobalVarSummary(const ModuleSummaryIndex &Index,<br>
+                               GlobalValue::GUID G) {<br>
+  if (const auto &VI = Index.getValueInfo(G)) {<br>
+    auto SL = VI.getSummaryList();<br>
+    if (!SL.empty())<br>
+      return SL[0]->getSummaryKind() == GlobalValueSummary::GlobalVarKind;<br>
+  }<br>
+  return false;<br>
+}<br>
+<br>
+static GlobalValue::GUID getGUID(GlobalValue::GUID G) { return G; }<br>
+<br>
+static GlobalValue::GUID<br>
+getGUID(const std::pair<const GlobalValue::GUID, unsigned> &P) {<br>
+  return P.first;<br>
+}<br>
+<br>
+template <class T><br>
+unsigned numGlobalVarSummaries(const ModuleSummaryIndex &Index, T &Cont) {<br>
+  unsigned NumGVS = 0;<br>
+  for (auto &V : Cont)<br>
+    if (isGlobalVarSummary(Index, getGUID(V)))<br>
+      ++NumGVS;<br>
+  return NumGVS;<br>
+}<br>
+#endif<br>
+<br>
 /// Compute all the import and export for every module using the Index.<br>
 void llvm::ComputeCrossModuleImport(<br>
     const ModuleSummaryIndex &Index,<br>
@@ -426,12 +484,17 @@ void llvm::ComputeCrossModuleImport(<br>
   for (auto &ModuleImports : ImportLists) {<br>
     auto ModName = ModuleImports.first();<br>
     auto &Exports = ExportLists[ModName];<br>
-    DEBUG(dbgs() << "* Module " << ModName << " exports " << Exports.size()<br>
-                 << " functions. Imports from " << ModuleImports.second.size()<br>
-                 << " modules.\n");<br>
+    unsigned NumGVS = numGlobalVarSummaries(Index, Exports);<br>
+        DEBUG(dbgs() << "* Module " << ModName << " exports "<br>
+                     << Exports.size() - NumGVS << " functions and " << NumGVS<br>
+                     << " vars. Imports from "<br>
+                     << ModuleImports.second.size() << " modules.\n");<br>
     for (auto &Src : ModuleImports.second) {<br>
       auto SrcModName = Src.first();<br>
-      DEBUG(dbgs() << " - " << Src.second.size() << " functions imported from "<br>
+      unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second);<br>
+      DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod<br>
+                   << " functions imported from " << SrcModName << "\n");<br>
+      DEBUG(dbgs() << " - " << NumGVSPerMod << " global vars imported from "<br>
                    << SrcModName << "\n");<br>
     }<br>
   }<br>
@@ -439,13 +502,17 @@ void llvm::ComputeCrossModuleImport(<br>
 }<br>
<br>
 #ifndef NDEBUG<br>
-static void dumpImportListForModule(StringRef ModulePath,<br>
+static void dumpImportListForModule(const ModuleSummaryIndex &Index,<br>
+                                    StringRef ModulePath,<br>
                                     FunctionImporter::ImportMapTy &ImportList) {<br>
   DEBUG(dbgs() << "* Module " << ModulePath << " imports from "<br>
                << ImportList.size() << " modules.\n");<br>
   for (auto &Src : ImportList) {<br>
     auto SrcModName = Src.first();<br>
-    DEBUG(dbgs() << " - " << Src.second.size() << " functions imported from "<br>
+    unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second);<br>
+    DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod<br>
+                 << " functions imported from " << SrcModName << "\n");<br>
+    DEBUG(dbgs() << " - " << NumGVSPerMod << " vars imported from "<br>
                  << SrcModName << "\n");<br>
   }<br>
 }<br>
@@ -465,7 +532,7 @@ void llvm::ComputeCrossModuleImportForMo<br>
   ComputeImportForModule(FunctionSummaryMap, Index, ImportList);<br>
<br>
 #ifndef NDEBUG<br>
-  dumpImportListForModule(ModulePath, ImportList);<br>
+  dumpImportListForModule(Index, ModulePath, ImportList);<br>
 #endif<br>
 }<br>
<br>
@@ -492,7 +559,7 @@ void llvm::ComputeCrossModuleImportForMo<br>
     ImportList[Summary->modulePath()][GUID] = 1;<br>
   }<br>
 #ifndef NDEBUG<br>
-  dumpImportListForModule(ModulePath, ImportList);<br>
+  dumpImportListForModule(Index, ModulePath, ImportList);<br>
 #endif<br>
 }<br>
<br>
@@ -770,7 +837,7 @@ Expected<bool> FunctionImporter::importF<br>
     Module &DestModule, const FunctionImporter::ImportMapTy &ImportList) {<br>
   DEBUG(dbgs() << "Starting import for Module "<br>
                << DestModule.getModuleIdentifier() << "\n");<br>
-  unsigned ImportedCount = 0;<br>
+  unsigned ImportedCount = 0, ImportedGVCount = 0;<br>
<br>
   IRMover Mover(DestModule);<br>
   // Do the actual import of functions now, one Module at a time<br>
@@ -830,7 +897,7 @@ Expected<bool> FunctionImporter::importF<br>
       if (Import) {<br>
         if (Error Err = GV.materialize())<br>
           return std::move(Err);<br>
-        GlobalsToImport.insert(&GV);<br>
+        ImportedGVCount += GlobalsToImport.insert(&GV);<br>
       }<br>
     }<br>
     for (GlobalAlias &GA : SrcModule->aliases()) {<br>
@@ -887,9 +954,14 @@ Expected<bool> FunctionImporter::importF<br>
     NumImportedModules++;<br>
   }<br>
<br>
-  NumImportedFunctions += ImportedCount;<br>
+  NumImportedFunctions += (ImportedCount - ImportedGVCount);<br>
+  NumImportedGlobalVars += ImportedGVCount;<br>
<br>
-  DEBUG(dbgs() << "Imported " << ImportedCount << " functions for Module "<br>
+  DEBUG(dbgs() << "Imported " << ImportedCount - ImportedGVCount<br>
+               << " functions for Module " << DestModule.getModuleIdentifier()<br>
+               << "\n");<br>
+  DEBUG(dbgs() << "Imported " << ImportedGVCount<br>
+               << " global variables for Module "<br>
                << DestModule.getModuleIdentifier() << "\n");<br>
   return ImportedCount;<br>
 }<br>
<br>
Added: llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll?rev=325320&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll?rev=325320&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll (added)<br>
+++ llvm/trunk/test/ThinLTO/X86/Inputs/globals-import-cf-baz.ll Fri Feb 16 00:11:04 2018<br>
@@ -0,0 +1,4 @@<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
+target triple = "x86_64-pc-linux-gnu"<br>
+<br>
+@baz = local_unnamed_addr constant i32 10, align 4<br>
<br>
Added: llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll?rev=325320&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll?rev=325320&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll (added)<br>
+++ llvm/trunk/test/ThinLTO/X86/globals-import-const-fold.ll Fri Feb 16 00:11:04 2018<br>
@@ -0,0 +1,23 @@<br>
+; RUN: opt -module-summary %s -o %t1.bc<br>
+; RUN: opt -module-summary %p/Inputs/globals-import-cf-baz.ll -o %t2.bc<br>
+; RUN: llvm-lto -thinlto-action=thinlink %t1.bc %t2.bc -o %t3.index.bc<br>
+<br>
+; RUN: llvm-lto -thinlto-action=import %t1.bc %t2.bc -thinlto-index=%t3.index.bc<br>
+; RUN: llvm-dis %t1.bc.thinlto.imported.bc -o - | FileCheck --check-prefix=IMPORT %s<br>
+; RUN: llvm-lto -thinlto-action=optimize %t1.bc.thinlto.imported.bc -o %t1.bc.thinlto.opt.bc<br>
+; RUN: llvm-dis %t1.bc.thinlto.opt.bc -o - | FileCheck --check-prefix=OPTIMIZE %s<br>
+<br>
+; IMPORT: @baz = available_externally local_unnamed_addr constant i32 10<br>
+<br>
+; OPTIMIZE:       define i32 @main()<br>
+; OPTIMIZE-NEXT:    ret i32 10<br>
+<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
+target triple = "x86_64-pc-linux-gnu"<br>
+<br>
+@baz = external local_unnamed_addr constant i32, align 4<br>
+<br>
+define i32 @main() local_unnamed_addr {<br>
+  %1 = load i32, i32* @baz, align 4<br>
+  ret i32 %1<br>
+}<br>
<br>
Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=325320&r1=325319&r2=325320&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=325320&r1=325319&r2=325320&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)<br>
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Fri Feb 16 00:11:04 2018<br>
@@ -7,7 +7,8 @@<br>
 ; RUN: opt -function-import -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF<br>
 ; Try again with new pass manager<br>
 ; RUN: opt -passes='function-import' -stats -print-imports -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=INSTLIMDEF<br>
-; "-stats" requires +Asserts.<br>
+; RUN: opt -passes='function-import' -debug-only=function-import -enable-import-metadata -summary-file %t3.thinlto.bc %t.bc -S 2>&1 | FileCheck %s --check-prefix=DUMP<br>
+; "-stats" and "-debug-only" require +Asserts.<br>
 ; REQUIRES: asserts<br>
<br>
 ; Test import with smaller instruction limit<br>
@@ -80,7 +81,7 @@ declare void @callfuncptr(...) #1<br>
<br>
 ; Ensure that all uses of local variable @P which has used in setfuncptr<br>
 ; and callfuncptr are to the same promoted/renamed global.<br>
-; CHECK-DAG: @P.llvm.{{.*}} = external hidden global void ()*<br>
+; CHECK-DAG: @P.llvm.{{.*}} = available_externally hidden global void ()* null<br>
 ; CHECK-DAG: %0 = load void ()*, void ()** @P.llvm.<br>
 ; CHECK-DAG: store void ()* @staticfunc2.llvm.{{.*}}, void ()** @P.llvm.<br>
<br>
@@ -107,6 +108,8 @@ declare void @variadic(...)<br>
<br>
 ; INSTLIMDEF-DAG: Import globalfunc2<br>
 ; INSTLIMDEF-DAG: 13 function-import - Number of functions imported<br>
+; INSTLIMDEF-DAG: 4 function-import - Number of global variables imported<br>
+<br>
 ; CHECK-DAG: !0 = !{!"{{.*}}/Inputs/funcimport.ll"}<br>
<br>
 ; The actual GUID values will depend on path to test.<br>
@@ -142,3 +145,9 @@ declare void @variadic(...)<br>
 ; GUID-DAG: GUID {{.*}} is linkoncealias<br>
 ; GUID-DAG: GUID {{.*}} is callfuncptr<br>
 ; GUID-DAG: GUID {{.*}} is linkoncefunc<br>
+<br>
+; DUMP:       Module [[M1:.*]] imports from 1 module<br>
+; DUMP-NEXT:  13 functions imported from [[M2:.*]]<br>
+; DUMP-NEXT:  4 vars imported from [[M2]]<br>
+; DUMP:       Imported 13 functions for Module [[M1]]<br>
+; DUMP-NEXT:  Imported 4 global variables for Module [[M1]]<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="m_7428358921693877826m_5971008527850850986m_-2862663351128771654gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>