[llvm] [SHT_LLVM_BB_ADDR_MAP] Updates ELFYaml and adds tests for PGOAnalysisMap. (PR #77366)

Rahman Lavaee via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 12:59:32 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:

> FWIW, I would lean towards unit tests if the setup is straightforward. Apart from anything else, lit tests on Windows have a non-trivial performance cost (much worse than extending an existing unit test), due to the process launching overhead.

Thanks for chiming in @jh7370 . One problem I have with our unit tests is that if we test multiple cases in a single test function, it's very hard to associate a failure to the test case. Although, while writing this I realized we can extend our test lambda (`DoCheckFails` and `DoCheckSucceeds`) with a string to represent the test case.

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


More information about the llvm-commits mailing list