[llvm] [SHT_LLVM_BB_ADDR_MAP] Adds test for when PGO exists but feature bit is off. (PR #77366)

Rahman Lavaee via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 12:35:26 PST 2024


================
@@ -897,6 +897,34 @@ TEST(ELFObjectFileTest, InvalidDecodePGOAnalysisMap) {
 
   DoCheck(MissingBrProb, "unable to decode LEB128 at offset 0x00000017: "
                          "malformed uleb128, extends past end");
+
+  // Check that we fail when pgo data exists but the feature bits are disabled.
+  SmallString<128> ZeroFeatureButWithAnalyses(CommonYamlString);
+  ZeroFeatureButWithAnalyses += R"(
+        Version: 2
+        Feature: 0x00
+        BBEntries:
+          - ID:            1
+            AddressOffset: 0x0
+            Size:          0x1
+            Metadata:      0x6
+          - ID:            2
+            AddressOffset: 0x1
+            Size:          0x1
+            Metadata:      0x2
+      - Address: 0x11111
+        Version: 2
+        Feature: 0x00
+        BBEntries: []
+    PGOAnalyses:
+      - PGOBBEntries:
+         - BBFreq:        1000
+         - BBFreq:        1000
+      - PGOBBEntries: []
+)";
+
+  DoCheck(ZeroFeatureButWithAnalyses,
+          "unsupported SHT_LLVM_BB_ADDR_MAP version: 232");
----------------
rlavaee wrote:

My guess (based on code in llvm/lib/ObjectYAML/ELFEmitter.cpp) is that PGOAnalyses data won't be emitted in the section. We should be able to encode and emit the data (regardless of the feature value), but decoding must fail because of the inconsistent feature value. @jh7370 initially asked me to test a similar scenario for the NumBlocks and Version fields.

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


More information about the llvm-commits mailing list