[llvm] [SHT_LLVM_BB_ADDR_MAP] Adds test for when PGO exists but feature bit is off. (PR #77366)
Micah Weston via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 12:02:24 PST 2024
https://github.com/red1bluelost created https://github.com/llvm/llvm-project/pull/77366
New test as mentioned here https://github.com/llvm/llvm-project/pull/77139#discussion_r1443586319
>From 0353f3719169be101cca57ebda0cbffe1a171724 Mon Sep 17 00:00:00 2001
From: Micah Weston <micahsweston at gmail.com>
Date: Mon, 8 Jan 2024 14:58:48 -0500
Subject: [PATCH] [SHT_LLVM_BB_ADDR_MAP] Adds test for when PGO exists but
feature bit is off.
---
llvm/unittests/Object/ELFObjectFileTest.cpp | 28 +++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/llvm/unittests/Object/ELFObjectFileTest.cpp b/llvm/unittests/Object/ELFObjectFileTest.cpp
index 3a2a8e3d3264db..005f1448982a98 100644
--- a/llvm/unittests/Object/ELFObjectFileTest.cpp
+++ b/llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -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");
}
// Test for the ELFObjectFile::readBBAddrMap API with PGOAnalysisMap.
More information about the llvm-commits
mailing list