[llvm] [SHT_LLVM_FUNC_MAP][ObjectYaml]Introduce function address map section and emit dynamic instruction count(ObjectYaml part) (PR #124332)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 00:32:52 PST 2025


================
@@ -1027,6 +1027,44 @@ struct PGOAnalysisMap {
   }
 };
 
+// Struct representing the FuncMap for one function.
+struct FuncMap {
+
+  // Bitfield of optional features to control the extra information
+  // emitted/encoded in the the section.
+  struct Features {
+    bool DynamicInstCount : 1;
+
+    // Encodes to minimum bit width representation.
+    uint8_t encode() const {
+      return (static_cast<uint8_t>(DynamicInstCount) << 0);
+    }
+
+    // Decodes from minimum bit width representation and validates no
+    // unnecessary bits are used.
+    static Expected<Features> decode(uint8_t Val) {
+      Features Feat{static_cast<bool>(Val & (1 << 0))};
+      if (Feat.encode() != Val)
+        return createStringError(std::error_code(),
+                                 "invalid encoding for FuncMap::Features: 0x%x",
+                                 Val);
+      return Feat;
+    }
+
+    bool operator==(const Features &Other) const {
+      return DynamicInstCount == Other.DynamicInstCount;
+    }
+  };
+
+  uint64_t FunctionAddress = 0;  // Function entry address.
+  uint64_t DynamicInstCount = 0; // Dynamic instruction count for this function
+
+  // Flags to indicate if each feature was enabled in this function
+  Features FeatEnable;
----------------
jh7370 wrote:

`EnabledFeatures` or `FeaturesEnabled` seem better names to me.

https://github.com/llvm/llvm-project/pull/124332


More information about the llvm-commits mailing list