[llvm] r294822 - Address Mehdi's post-commit review comments on r294795.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 19:19:23 PST 2017


Author: pcc
Date: Fri Feb 10 21:19:22 2017
New Revision: 294822

URL: http://llvm.org/viewvc/llvm-project?rev=294822&view=rev
Log:
Address Mehdi's post-commit review comments on r294795.

Modified:
    llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=294822&r1=294821&r2=294822&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Fri Feb 10 21:19:22 2017
@@ -251,7 +251,8 @@ public:
 
   /// An "identifier" for a virtual function. This contains the type identifier
   /// represented as a GUID and the offset from the address point to the virtual
-  /// function pointer.
+  /// function pointer, where "address point" is as defined in the Itanium ABI:
+  /// https://mentorembedded.github.io/cxx-abi/abi.html#vtable-general
   struct VFuncId {
     GlobalValue::GUID GUID;
     uint64_t Offset;
@@ -273,19 +274,26 @@ private:
   /// List of <CalleeValueInfo, CalleeInfo> call edge pairs from this function.
   std::vector<EdgeTy> CallGraphEdgeList;
 
-  /// List of type identifiers used by this function in llvm.type.test
-  /// intrinsics other than by an llvm.assume intrinsic, represented as GUIDs.
-  std::vector<GlobalValue::GUID> TypeTests;
-
-  /// List of virtual calls made by this function using (respectively)
-  /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics that do
-  /// not have all constant integer arguments.
-  std::vector<VFuncId> TypeTestAssumeVCalls, TypeCheckedLoadVCalls;
-
-  /// List of virtual calls made by this function using (respectively)
-  /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics with
-  /// all constant integer arguments.
-  std::vector<ConstVCall> TypeTestAssumeConstVCalls, TypeCheckedLoadConstVCalls;
+  /// All type identifier related information. Because these fields are
+  /// relatively uncommon we only allocate space for them if necessary.
+  struct TypeIdInfo {
+    /// List of type identifiers used by this function in llvm.type.test
+    /// intrinsics other than by an llvm.assume intrinsic, represented as GUIDs.
+    std::vector<GlobalValue::GUID> TypeTests;
+
+    /// List of virtual calls made by this function using (respectively)
+    /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics that do
+    /// not have all constant integer arguments.
+    std::vector<VFuncId> TypeTestAssumeVCalls, TypeCheckedLoadVCalls;
+
+    /// List of virtual calls made by this function using (respectively)
+    /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics with
+    /// all constant integer arguments.
+    std::vector<ConstVCall> TypeTestAssumeConstVCalls,
+        TypeCheckedLoadConstVCalls;
+  };
+
+  std::unique_ptr<TypeIdInfo> TIdInfo;
 
 public:
   /// Summary constructors.
@@ -297,12 +305,16 @@ public:
                   std::vector<ConstVCall> TypeTestAssumeConstVCalls,
                   std::vector<ConstVCall> TypeCheckedLoadConstVCalls)
       : GlobalValueSummary(FunctionKind, Flags, std::move(Refs)),
-        InstCount(NumInsts), CallGraphEdgeList(std::move(CGEdges)),
-        TypeTests(std::move(TypeTests)),
-        TypeTestAssumeVCalls(std::move(TypeTestAssumeVCalls)),
-        TypeCheckedLoadVCalls(std::move(TypeCheckedLoadVCalls)),
-        TypeTestAssumeConstVCalls(std::move(TypeTestAssumeConstVCalls)),
-        TypeCheckedLoadConstVCalls(std::move(TypeCheckedLoadConstVCalls)) {}
+        InstCount(NumInsts), CallGraphEdgeList(std::move(CGEdges)) {
+    if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
+        !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
+        !TypeCheckedLoadConstVCalls.empty())
+      TIdInfo = llvm::make_unique<TypeIdInfo>(TypeIdInfo{
+          std::move(TypeTests), std::move(TypeTestAssumeVCalls),
+          std::move(TypeCheckedLoadVCalls),
+          std::move(TypeTestAssumeConstVCalls),
+          std::move(TypeCheckedLoadConstVCalls)});
+  }
 
   /// Check if this is a function summary.
   static bool classof(const GlobalValueSummary *GVS) {
@@ -318,41 +330,51 @@ public:
   /// Returns the list of type identifiers used by this function in
   /// llvm.type.test intrinsics other than by an llvm.assume intrinsic,
   /// represented as GUIDs.
-  ArrayRef<GlobalValue::GUID> type_tests() const { return TypeTests; }
+  ArrayRef<GlobalValue::GUID> type_tests() const {
+    if (TIdInfo)
+      return TIdInfo->TypeTests;
+    return {};
+  }
 
   /// Returns the list of virtual calls made by this function using
   /// llvm.assume(llvm.type.test) intrinsics that do not have all constant
   /// integer arguments.
   ArrayRef<VFuncId> type_test_assume_vcalls() const {
-    return TypeTestAssumeVCalls;
+    if (TIdInfo)
+      return TIdInfo->TypeTestAssumeVCalls;
+    return {};
   }
 
   /// Returns the list of virtual calls made by this function using
   /// llvm.type.checked.load intrinsics that do not have all constant integer
   /// arguments.
   ArrayRef<VFuncId> type_checked_load_vcalls() const {
-    return TypeCheckedLoadVCalls;
+    if (TIdInfo)
+      return TIdInfo->TypeCheckedLoadVCalls;
+    return {};
   }
 
   /// Returns the list of virtual calls made by this function using
   /// llvm.assume(llvm.type.test) intrinsics with all constant integer
   /// arguments.
   ArrayRef<ConstVCall> type_test_assume_const_vcalls() const {
-    return TypeTestAssumeConstVCalls;
+    if (TIdInfo)
+      return TIdInfo->TypeTestAssumeConstVCalls;
+    return {};
   }
 
   /// Returns the list of virtual calls made by this function using
   /// llvm.type.checked.load intrinsics with all constant integer arguments.
   ArrayRef<ConstVCall> type_checked_load_const_vcalls() const {
-    return TypeCheckedLoadConstVCalls;
+    if (TIdInfo)
+      return TIdInfo->TypeCheckedLoadConstVCalls;
+    return {};
   }
 };
 
 template <> struct DenseMapInfo<FunctionSummary::VFuncId> {
-  static inline FunctionSummary::VFuncId getEmptyKey() {
-    return {0, uint64_t(-1)};
-  }
-  static inline FunctionSummary::VFuncId getTombstoneKey() {
+  static FunctionSummary::VFuncId getEmptyKey() { return {0, uint64_t(-1)}; }
+  static FunctionSummary::VFuncId getTombstoneKey() {
     return {0, uint64_t(-2)};
   }
   static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R) {
@@ -362,10 +384,10 @@ template <> struct DenseMapInfo<Function
 };
 
 template <> struct DenseMapInfo<FunctionSummary::ConstVCall> {
-  static inline FunctionSummary::ConstVCall getEmptyKey() {
+  static FunctionSummary::ConstVCall getEmptyKey() {
     return {{0, uint64_t(-1)}, {}};
   }
-  static inline FunctionSummary::ConstVCall getTombstoneKey() {
+  static FunctionSummary::ConstVCall getTombstoneKey() {
     return {{0, uint64_t(-2)}, {}};
   }
   static bool isEqual(FunctionSummary::ConstVCall L,

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=294822&r1=294821&r2=294822&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Feb 10 21:19:22 2017
@@ -4847,6 +4847,10 @@ Error ModuleSummaryIndexBitcodeReader::p
   // "OriginalName" attachement.
   GlobalValueSummary *LastSeenSummary = nullptr;
   bool Combined = false;
+
+  // We can expect to see any number of type ID information records before
+  // each function summary records; these variables store the information
+  // collected so far so that it can be used to create the summary object.
   std::vector<GlobalValue::GUID> PendingTypeTests;
   std::vector<FunctionSummary::VFuncId> PendingTypeTestAssumeVCalls,
       PendingTypeCheckedLoadVCalls;




More information about the llvm-commits mailing list