diff options
Diffstat (limited to 'llvm/unittests/Object/ELFObjectFileTest.cpp')
-rw-r--r-- | llvm/unittests/Object/ELFObjectFileTest.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/llvm/unittests/Object/ELFObjectFileTest.cpp b/llvm/unittests/Object/ELFObjectFileTest.cpp index 48bebc5..3a2a8e3 100644 --- a/llvm/unittests/Object/ELFObjectFileTest.cpp +++ b/llvm/unittests/Object/ELFObjectFileTest.cpp @@ -1017,10 +1017,23 @@ Sections: BrProb: 0xffffffff - BBFreq: 1000 Successors: [] -)"); + - Name: .llvm_bb_addr_map_5 + Type: SHT_LLVM_BB_ADDR_MAP + # Link: 0 (by default, can be overriden) + Entries: + - Version: 2 + Address: 0x55555 + Feature: 0x0 + BBEntries: + - ID: 2 + AddressOffset: 0x0 + Size: 0x2 + Metadata: 0x4 + PGOAnalyses: [{}] + )"); BBAddrMap E1(0x11111, {{1, 0x0, 0x1, {false, true, false, false, false}}}); - PGOAnalysisMap P1 = {892, {{}}, {true, false, false}}; + PGOAnalysisMap P1 = {892, {}, {true, false, false}}; BBAddrMap E2(0x22222, {{2, 0x0, 0x2, {false, false, true, false, false}}}); PGOAnalysisMap P2 = {{}, {{BlockFrequency(343), {}}}, {false, true, false}}; BBAddrMap E3(0x33333, {{0, 0x0, 0x3, {false, true, true, false, false}}, @@ -1049,16 +1062,18 @@ Sections: {BlockFrequency(18), {{3, BranchProbability::getRaw(0xffff'ffff)}}}, {BlockFrequency(1000), {}}}, {true, true, true}}; + BBAddrMap E5(0x55555, {{2, 0x0, 0x2, {false, false, true, false, false}}}); + PGOAnalysisMap P5 = {{}, {}, {false, false, false}}; - std::vector<BBAddrMap> Section0BBAddrMaps = {E4}; + std::vector<BBAddrMap> Section0BBAddrMaps = {E4, E5}; std::vector<BBAddrMap> Section1BBAddrMaps = {E3}; std::vector<BBAddrMap> Section2BBAddrMaps = {E1, E2}; - std::vector<BBAddrMap> AllBBAddrMaps = {E1, E2, E3, E4}; + std::vector<BBAddrMap> AllBBAddrMaps = {E1, E2, E3, E4, E5}; - std::vector<PGOAnalysisMap> Section0PGOAnalysisMaps = {P4}; + std::vector<PGOAnalysisMap> Section0PGOAnalysisMaps = {P4, P5}; std::vector<PGOAnalysisMap> Section1PGOAnalysisMaps = {P3}; std::vector<PGOAnalysisMap> Section2PGOAnalysisMaps = {P1, P2}; - std::vector<PGOAnalysisMap> AllPGOAnalysisMaps = {P1, P2, P3, P4}; + std::vector<PGOAnalysisMap> AllPGOAnalysisMaps = {P1, P2, P3, P4, P5}; auto DoCheckSucceeds = [&](StringRef YamlString, std::optional<unsigned> TextSectionIndex, @@ -1081,6 +1096,10 @@ Sections: if (ExpectedPGO) { EXPECT_EQ(BBAddrMaps->size(), PGOAnalyses.size()); EXPECT_EQ(PGOAnalyses, *ExpectedPGO); + for (auto &&[BB, PGO] : llvm::zip(*BBAddrMaps, PGOAnalyses)) { + if (PGO.FeatEnable.BBFreq || PGO.FeatEnable.BrProb) + EXPECT_EQ(BB.getBBEntries().size(), PGO.BBEntries.size()); + } } }; @@ -1132,9 +1151,9 @@ Sections: Link: 10 )"; - DoCheckFails(InvalidLinkedYamlString, /*TextSectionIndex=*/4, + DoCheckFails(InvalidLinkedYamlString, /*TextSectionIndex=*/5, "unable to get the linked-to section for " - "SHT_LLVM_BB_ADDR_MAP section with index 4: invalid section " + "SHT_LLVM_BB_ADDR_MAP section with index 5: invalid section " "index: 10"); // Linked sections are not checked when we don't target a specific text // section. @@ -1150,7 +1169,7 @@ Sections: )"; DoCheckFails(TruncatedYamlString, /*TextSectionIndex=*/std::nullopt, - "unable to read SHT_LLVM_BB_ADDR_MAP section with index 4: " + "unable to read SHT_LLVM_BB_ADDR_MAP section with index 5: " "unable to decode LEB128 at offset 0x0000000a: malformed " "uleb128, extends past end"); // Check that we can read the other section's bb-address-maps which are |