[PATCH] D19405: Add "hasSection" flag in the Summary

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 00:30:50 PDT 2016


joker.eph updated this revision to Diff 54618.
joker.eph added a comment.
Herald added a subscriber: joker.eph.

Forgot to `git add` the test


http://reviews.llvm.org/D19405

Files:
  include/llvm/IR/ModuleSummaryIndex.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  test/Bitcode/thinlto-summary-section.ll

Index: test/Bitcode/thinlto-summary-section.ll
===================================================================
--- /dev/null
+++ test/Bitcode/thinlto-summary-section.ll
@@ -0,0 +1,11 @@
+; Check the linkage types in both the per-module and combined summaries.
+; RUN: opt -module-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+; RUN: llvm-lto -thinlto -o %t2 %t.o
+; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
+
+; CHECK: <PERMODULE {{.*}} op1=16
+; COMBINED-DAG: <COMBINED {{.*}} op1=16
+define void @functionWithSection() section "some_section" {
+    ret void
+}
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -536,10 +536,14 @@
 // Decode the flags for GlobalValue in the summary
 static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) {
   uint64_t RawFlags = 0;
+
+  RawFlags |= Flags.HasSection; // bool
+
   // Linkage don't need to be remapped at that time for the summary. Any future
   // change to the getEncodedLinkage() function will need to be taken into
   // account here as well.
-  RawFlags |= Flags.Linkage; // 4 bits
+  RawFlags = (RawFlags << 4) | Flags.Linkage; // 4 bits
+
   return RawFlags;
 }
 
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -706,7 +706,9 @@
   // as well
   //
   auto Linkage = GlobalValue::LinkageTypes(RawFlags & 0xF); // 4 bits
-  return GlobalValueSummary::GVFlags(Linkage);
+  RawFlags = RawFlags >> 4;
+  auto HasSection = RawFlags & 0x1; // bool
+  return GlobalValueSummary::GVFlags(Linkage, HasSection);
 }
 
 static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
Index: include/llvm/IR/ModuleSummaryIndex.h
===================================================================
--- include/llvm/IR/ModuleSummaryIndex.h
+++ include/llvm/IR/ModuleSummaryIndex.h
@@ -103,9 +103,14 @@
     /// types based on global summary-based analysis.
     GlobalValue::LinkageTypes Linkage : 4;
 
+    /// Indicate if the global value is located in a specific section.
+    unsigned HasSection : 1;
+
     /// Convenience Constructors
-    explicit GVFlags(GlobalValue::LinkageTypes Linkage) : Linkage(Linkage) {}
-    GVFlags(const GlobalValue &GV) : Linkage(GV.getLinkage()) {}
+    explicit GVFlags(GlobalValue::LinkageTypes Linkage, bool HasSection)
+        : Linkage(Linkage), HasSection(HasSection) {}
+    GVFlags(const GlobalValue &GV)
+        : Linkage(GV.getLinkage()), HasSection(GV.hasSection()) {}
   };
 
 private:
@@ -152,6 +157,9 @@
   /// Return linkage type recorded for this global value.
   GlobalValue::LinkageTypes linkage() const { return Flags.Linkage; }
 
+  /// Return true if this global value is located in a specific section.
+  bool hasSection() const { return Flags.HasSection; }
+
   /// Record a reference from this global value to the global value identified
   /// by \p RefGUID.
   void addRefEdge(GlobalValue::GUID RefGUID) { RefEdgeList.push_back(RefGUID); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19405.54618.patch
Type: text/x-patch
Size: 3242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160422/262614cf/attachment.bin>


More information about the llvm-commits mailing list