[llvm] 5b0619e - Move function info word into its own data structure (#153627)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 13:16:37 PDT 2025
Author: Sterling-Augustine
Date: 2025-08-15T13:16:34-07:00
New Revision: 5b0619e79b65cbd3c5ad0fc0916d4ba59881b090
URL: https://github.com/llvm/llvm-project/commit/5b0619e79b65cbd3c5ad0fc0916d4ba59881b090
DIFF: https://github.com/llvm/llvm-project/commit/5b0619e79b65cbd3c5ad0fc0916d4ba59881b090.diff
LOG: Move function info word into its own data structure (#153627)
The sframe generator needs to construct this word separately from FDEs
themselves, so split them into a separate data structure.
Added:
Modified:
llvm/include/llvm/BinaryFormat/SFrame.h
llvm/lib/Object/SFrameParser.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/unittests/BinaryFormat/SFrameTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/BinaryFormat/SFrame.h b/llvm/include/llvm/BinaryFormat/SFrame.h
index 74e47ea8acca9..095db18b9c254 100644
--- a/llvm/include/llvm/BinaryFormat/SFrame.h
+++ b/llvm/include/llvm/BinaryFormat/SFrame.h
@@ -104,14 +104,8 @@ template <endianness E> struct Header {
detail::packed<uint32_t, E> FREOff;
};
-template <endianness E> struct FuncDescEntry {
- detail::packed<int32_t, E> StartAddress;
- detail::packed<uint32_t, E> Size;
- detail::packed<uint32_t, E> StartFREOff;
- detail::packed<uint32_t, E> NumFREs;
+template <endianness E> struct FDEInfo {
detail::packed<uint8_t, E> Info;
- detail::packed<uint8_t, E> RepSize;
- detail::packed<uint16_t, E> Padding2;
uint8_t getPAuthKey() const { return (Info >> 5) & 1; }
FDEType getFDEType() const { return static_cast<FDEType>((Info >> 4) & 1); }
@@ -125,6 +119,16 @@ template <endianness E> struct FuncDescEntry {
}
};
+template <endianness E> struct FuncDescEntry {
+ detail::packed<int32_t, E> StartAddress;
+ detail::packed<uint32_t, E> Size;
+ detail::packed<uint32_t, E> StartFREOff;
+ detail::packed<uint32_t, E> NumFREs;
+ FDEInfo<E> Info;
+ detail::packed<uint8_t, E> RepSize;
+ detail::packed<uint16_t, E> Padding2;
+};
+
template <endianness E> struct FREInfo {
detail::packed<uint8_t, E> Info;
diff --git a/llvm/lib/Object/SFrameParser.cpp b/llvm/lib/Object/SFrameParser.cpp
index 0c5638d776ef9..759b579230d9d 100644
--- a/llvm/lib/Object/SFrameParser.cpp
+++ b/llvm/lib/Object/SFrameParser.cpp
@@ -176,10 +176,10 @@ iterator_range<typename SFrameParser<E>::fre_iterator>
SFrameParser<E>::fres(const sframe::FuncDescEntry<E> &FDE, Error &Err) const {
uint64_t Offset = getFREBase() + FDE.StartFREOff;
fre_iterator BeforeBegin = make_fallible_itr(
- FallibleFREIterator(Data, FDE.getFREType(), -1, FDE.NumFREs, Offset),
+ FallibleFREIterator(Data, FDE.Info.getFREType(), -1, FDE.NumFREs, Offset),
Err);
fre_iterator End = make_fallible_end(
- FallibleFREIterator(Data, FDE.getFREType(), FDE.NumFREs, FDE.NumFREs,
+ FallibleFREIterator(Data, FDE.Info.getFREType(), FDE.NumFREs, FDE.NumFREs,
/*Offset=*/0));
return {++BeforeBegin, End};
}
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index c1a2c38ea9b7c..ade025fd3d892 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -6512,12 +6512,13 @@ void ELFDumper<ELFT>::printSFrameFDEs(
{
DictScope InfoScope(W, "Info");
- W.printEnum("FRE Type", It->getFREType(), sframe::getFRETypes());
- W.printEnum("FDE Type", It->getFDEType(), sframe::getFDETypes());
+ W.printEnum("FRE Type", It->Info.getFREType(), sframe::getFRETypes());
+ W.printEnum("FDE Type", It->Info.getFDEType(), sframe::getFDETypes());
switch (Parser.getHeader().ABIArch) {
case sframe::ABI::AArch64EndianBig:
case sframe::ABI::AArch64EndianLittle:
- W.printEnum("PAuth Key", sframe::AArch64PAuthKey(It->getPAuthKey()),
+ W.printEnum("PAuth Key",
+ sframe::AArch64PAuthKey(It->Info.getPAuthKey()),
sframe::getAArch64PAuthKeys());
break;
case sframe::ABI::AMD64EndianLittle:
@@ -6525,12 +6526,13 @@ void ELFDumper<ELFT>::printSFrameFDEs(
break;
}
- W.printHex("Raw", It->Info);
+ W.printHex("Raw", It->Info.Info);
}
W.printHex(
("Repetitive block size" +
- Twine(It->getFDEType() == sframe::FDEType::PCMask ? "" : " (unused)"))
+ Twine(It->Info.getFDEType() == sframe::FDEType::PCMask ? ""
+ : " (unused)"))
.str(),
It->RepSize);
@@ -6541,10 +6543,11 @@ void ELFDumper<ELFT>::printSFrameFDEs(
for (const typename SFrameParser<ELFT::Endianness>::FrameRowEntry &FRE :
Parser.fres(*It, Err)) {
DictScope FREScope(W, "Frame Row Entry");
- W.printHex(
- "Start Address",
- (It->getFDEType() == sframe::FDEType::PCInc ? FDEStartAddress : 0) +
- FRE.StartAddress);
+ W.printHex("Start Address",
+ (It->Info.getFDEType() == sframe::FDEType::PCInc
+ ? FDEStartAddress
+ : 0) +
+ FRE.StartAddress);
W.printBoolean("Return Address Signed", FRE.Info.isReturnAddressSigned());
W.printEnum("Offset Size", FRE.Info.getOffsetSize(),
sframe::getFREOffsets());
diff --git a/llvm/unittests/BinaryFormat/SFrameTest.cpp b/llvm/unittests/BinaryFormat/SFrameTest.cpp
index 394e382e041e9..ab7b0fe20b750 100644
--- a/llvm/unittests/BinaryFormat/SFrameTest.cpp
+++ b/llvm/unittests/BinaryFormat/SFrameTest.cpp
@@ -54,28 +54,28 @@ TYPED_TEST_SUITE(SFrameTest, Types, NameGenerator);
TYPED_TEST(SFrameTest, FDEFlags) {
FuncDescEntry<TestFixture::Endian> FDE = {};
- EXPECT_EQ(FDE.Info, 0u);
- EXPECT_EQ(FDE.getPAuthKey(), 0);
- EXPECT_EQ(FDE.getFDEType(), FDEType::PCInc);
- EXPECT_EQ(FDE.getFREType(), FREType::Addr1);
-
- FDE.setPAuthKey(1);
- EXPECT_EQ(FDE.Info, 0x20u);
- EXPECT_EQ(FDE.getPAuthKey(), 1);
- EXPECT_EQ(FDE.getFDEType(), FDEType::PCInc);
- EXPECT_EQ(FDE.getFREType(), FREType::Addr1);
-
- FDE.setFDEType(FDEType::PCMask);
- EXPECT_EQ(FDE.Info, 0x30u);
- EXPECT_EQ(FDE.getPAuthKey(), 1);
- EXPECT_EQ(FDE.getFDEType(), FDEType::PCMask);
- EXPECT_EQ(FDE.getFREType(), FREType::Addr1);
-
- FDE.setFREType(FREType::Addr4);
- EXPECT_EQ(FDE.Info, 0x32u);
- EXPECT_EQ(FDE.getPAuthKey(), 1);
- EXPECT_EQ(FDE.getFDEType(), FDEType::PCMask);
- EXPECT_EQ(FDE.getFREType(), FREType::Addr4);
+ EXPECT_EQ(FDE.Info.Info, 0u);
+ EXPECT_EQ(FDE.Info.getPAuthKey(), 0);
+ EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCInc);
+ EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);
+
+ FDE.Info.setPAuthKey(1);
+ EXPECT_EQ(FDE.Info.Info, 0x20u);
+ EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
+ EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCInc);
+ EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);
+
+ FDE.Info.setFDEType(FDEType::PCMask);
+ EXPECT_EQ(FDE.Info.Info, 0x30u);
+ EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
+ EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCMask);
+ EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);
+
+ FDE.Info.setFREType(FREType::Addr4);
+ EXPECT_EQ(FDE.Info.Info, 0x32u);
+ EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
+ EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCMask);
+ EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr4);
}
TYPED_TEST(SFrameTest, FREFlags) {
More information about the llvm-commits
mailing list