<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 2, 2016 at 10:29 AM, Mehdi Amini via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br>
Date: Sat Apr  2 12:29:47 2016<br>
New Revision: 265230<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265230&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=265230&view=rev</a><br>
Log:<br>
Rename FunctionIndex into GlobalValueIndex to reflect the recent changes (NFC)<br>
<br>
The index used to contain only Function, but now contains GlobalValue<br>
in general.<br></blockquote><div><br></div><div>Actually this is a DenseMap just used during bitcode writing (not a full Index) and only contains FunctionSummary, so the naming was intentional. </div><div><br></div><div>This is going away in my changes to create the Index as a separate pass in any case.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>><br>
<br>
Modified:<br>
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=265230&r1=265229&r2=265230&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=265230&r1=265229&r2=265230&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)<br>
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Sat Apr  2 12:29:47 2016<br>
@@ -2271,8 +2271,8 @@ static void WriteValueSymbolTable(<br>
     const ValueSymbolTable &VST, const ValueEnumerator &VE,<br>
     BitstreamWriter &Stream, uint64_t VSTOffsetPlaceholder = 0,<br>
     uint64_t BitcodeStartBit = 0,<br>
-    DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>><br>
-        *FunctionIndex = nullptr) {<br>
+    DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> *<br>
+        GlobalValueIndex = nullptr) {<br>
   if (VST.empty()) {<br>
     // WriteValueSymbolTableForwardDecl should have returned early as<br>
     // well. Ensure this handling remains in sync by asserting that<br>
@@ -2361,13 +2361,13 @@ static void WriteValueSymbolTable(<br>
       // Must be the module-level VST, where we pass in the Index and<br>
       // have a VSTOffsetPlaceholder. The function-level VST should not<br>
       // contain any Function symbols.<br>
-      assert(FunctionIndex);<br>
+      assert(GlobalValueIndex);<br>
       assert(VSTOffsetPlaceholder > 0);<br>
<br>
       // Save the word offset of the function (from the start of the<br>
       // actual bitcode written to the stream).<br>
       uint64_t BitcodeIndex =<br>
-          (*FunctionIndex)[F]->bitcodeIndex() - BitcodeStartBit;<br>
+          (*GlobalValueIndex)[F]->bitcodeIndex() - BitcodeStartBit;<br>
       assert((BitcodeIndex & 31) == 0 && "function block not 32-bit aligned");<br>
       NameVals.push_back(BitcodeIndex / 32);<br>
<br>
@@ -2526,11 +2526,12 @@ static void findRefEdges(const User *Cur<br>
 }<br>
<br>
 /// Emit a function body to the module stream.<br>
-static void WriteFunction(<br>
-    const Function &F, const Module *M, ValueEnumerator &VE,<br>
-    BitstreamWriter &Stream,<br>
-    DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> &FunctionIndex,<br>
-    bool EmitSummaryIndex) {<br>
+static void<br>
+WriteFunction(const Function &F, const Module *M, ValueEnumerator &VE,<br>
+              BitstreamWriter &Stream,<br>
+              DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> &<br>
+                  GlobalValueIndex,<br>
+              bool EmitSummaryIndex) {<br>
   // Save the bitcode index of the start of this function block for recording<br>
   // in the VST.<br>
   uint64_t BitcodeIndex = Stream.GetCurrentBitNo();<br>
@@ -2633,7 +2634,7 @@ static void WriteFunction(<br>
     FuncSummary->addCallGraphEdges(CallGraphEdges);<br>
     FuncSummary->addRefEdges(RefEdges);<br>
   }<br>
-  FunctionIndex[&F] =<br>
+  GlobalValueIndex[&F] =<br>
       llvm::make_unique<GlobalValueInfo>(BitcodeIndex, std::move(FuncSummary));<br>
<br>
   // Emit names for all the instructions etc.<br>
@@ -2959,7 +2960,8 @@ static void WriteModuleLevelReferences(c<br>
 /// Emit the per-module summary section alongside the rest of<br>
 /// the module's bitcode.<br>
 static void WritePerModuleGlobalValueSummary(<br>
-    DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> &FunctionIndex,<br>
+    DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> &<br>
+        GlobalValueIndex,<br>
     const Module *M, const ValueEnumerator &VE, BitstreamWriter &Stream) {<br>
   if (M->empty())<br>
     return;<br>
@@ -3000,7 +3002,7 @@ static void WritePerModuleGlobalValueSum<br>
   unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);<br>
<br>
   SmallVector<uint64_t, 64> NameVals;<br>
-  // Iterate over the list of functions instead of the FunctionIndex map to<br>
+  // Iterate over the list of functions instead of the GlobalValueIndex map to<br>
   // ensure the ordering is stable.<br>
   for (const Function &F : *M) {<br>
     if (F.isDeclaration())<br>
@@ -3010,10 +3012,10 @@ static void WritePerModuleGlobalValueSum<br>
     if (!F.hasName())<br>
       continue;<br>
<br>
-    assert(FunctionIndex.count(&F) == 1);<br>
+    assert(GlobalValueIndex.count(&F) == 1);<br>
<br>
     WritePerModuleFunctionSummaryRecord(<br>
-        NameVals, cast<FunctionSummary>(FunctionIndex[&F]->summary()),<br>
+        NameVals, cast<FunctionSummary>(GlobalValueIndex[&F]->summary()),<br>
         VE.getValueID(M->getValueSymbolTable().lookup(F.getName())),<br>
         FSCallsAbbrev, FSCallsProfileAbbrev, Stream, F);<br>
   }<br>
@@ -3025,9 +3027,8 @@ static void WritePerModuleGlobalValueSum<br>
     if (!F || F->isDeclaration())<br>
       continue;<br>
<br>
-    assert(FunctionIndex.count(F) == 1);<br>
-    FunctionSummary *FS =<br>
-        cast<FunctionSummary>(FunctionIndex[F]->summary());<br>
+    assert(GlobalValueIndex.count(F) == 1);<br>
+    FunctionSummary *FS = cast<FunctionSummary>(GlobalValueIndex[F]->summary());<br>
     // Add the alias to the reference list of aliasee function.<br>
     FS->addRefEdge(<br>
         VE.getValueID(M->getValueSymbolTable().lookup(A.getName())));<br>
@@ -3278,18 +3279,19 @@ static void WriteModule(const Module *M,<br>
   WriteOperandBundleTags(M, Stream);<br>
<br>
   // Emit function bodies.<br>
-  DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> FunctionIndex;<br>
+  DenseMap<const Function *, std::unique_ptr<GlobalValueInfo>> GlobalValueIndex;<br>
   for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F)<br>
     if (!F->isDeclaration())<br>
-      WriteFunction(*F, M, VE, Stream, FunctionIndex, EmitSummaryIndex);<br>
+      WriteFunction(*F, M, VE, Stream, GlobalValueIndex, EmitSummaryIndex);<br>
<br>
   // Need to write after the above call to WriteFunction which populates<br>
   // the summary information in the index.<br>
   if (EmitSummaryIndex)<br>
-    WritePerModuleGlobalValueSummary(FunctionIndex, M, VE, Stream);<br>
+    WritePerModuleGlobalValueSummary(GlobalValueIndex, M, VE, Stream);<br>
<br>
   WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream,<br>
-                        VSTOffsetPlaceholder, BitcodeStartBit, &FunctionIndex);<br>
+                        VSTOffsetPlaceholder, BitcodeStartBit,<br>
+                        &GlobalValueIndex);<br>
<br>
   if (GenerateHash) {<br>
     writeModuleHash(Stream, Buffer, BlockStartPos);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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><br><br clear="all"><div><br></div>-- <br><div class="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"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>