[clang] [compiler-rt] [llvm] Revert "Reapply "[ORC] Enable JIT support for the compact-unwind frame..." with fixes." (PR #125098)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 09:52:48 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ben Langmuir (benlangmuir)
<details>
<summary>Changes</summary>
This reverts commit d6524c8dfa37634257050ca71d16e117b802181c. This reverts commit b1bd73700a1fb6f450e0f6f9c405a9c8bde2cae7.
This was causing bot failures on Darwin
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-cmake-RA-incremental/7315/
Clang.Interpreter.simple-exception.cpp
Clang-Unit.Interpreter/ExceptionTests/_/ClangReplInterpreterExceptionTests/0.1
LLVM.ExecutionEngine/OrcLazy.minimal-throw-catch.ll
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3415/
ORC-x86_64-darwin.TestCases/Darwin/Generic.exceptions.cpp
ORC-x86_64-darwin.TestCases/Darwin/x86-64.lljit-ehframe.cpp
---
Patch is 78.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/125098.diff
24 Files Affected:
- (modified) clang/test/Interpreter/simple-exception.cpp (+2-2)
- (modified) compiler-rt/lib/orc/macho_platform.cpp (-6)
- (removed) compiler-rt/test/orc/TestCases/Darwin/Generic/exceptions.cpp (-13)
- (modified) llvm/include/llvm/ExecutionEngine/Orc/Core.h (+2-7)
- (modified) llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h (-4)
- (modified) llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h (-9)
- (removed) llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h (-78)
- (removed) llvm/include/llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h (-70)
- (modified) llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt (-1)
- (removed) llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.cpp (-103)
- (removed) llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h (-653)
- (modified) llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp (+116)
- (modified) llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h (+11)
- (modified) llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp (+6-43)
- (modified) llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp (+8-49)
- (modified) llvm/lib/ExecutionEngine/Orc/CMakeLists.txt (-1)
- (modified) llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp (-3)
- (modified) llvm/lib/ExecutionEngine/Orc/Core.cpp (+13-21)
- (modified) llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp (-7)
- (modified) llvm/lib/ExecutionEngine/Orc/LLJIT.cpp (+6-23)
- (modified) llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp (-14)
- (modified) llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt (-1)
- (removed) llvm/lib/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.cpp (-188)
- (removed) llvm/lib/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.cpp (-238)
``````````diff
diff --git a/clang/test/Interpreter/simple-exception.cpp b/clang/test/Interpreter/simple-exception.cpp
index 651e8d9402f89e..6749acd6e6bd23 100644
--- a/clang/test/Interpreter/simple-exception.cpp
+++ b/clang/test/Interpreter/simple-exception.cpp
@@ -1,7 +1,7 @@
// clang-format off
// UNSUPPORTED: system-aix
-// XFAIL for arm, or running on Windows.
-// XFAIL: target=arm-{{.*}}, target=armv{{.*}}, system-windows
+// XFAIL for arm and arm64, or running on Windows.
+// XFAIL: target=arm{{.*}}, system-windows
// RUN: cat %s | clang-repl | FileCheck %s
// Incompatible with msan. It passes with -O3 but fail -Oz. Interpreter
diff --git a/compiler-rt/lib/orc/macho_platform.cpp b/compiler-rt/lib/orc/macho_platform.cpp
index 4b603fd95e3163..8ca68587aeb363 100644
--- a/compiler-rt/lib/orc/macho_platform.cpp
+++ b/compiler-rt/lib/orc/macho_platform.cpp
@@ -557,12 +557,6 @@ Error MachOPlatformRuntimeState::registerObjectPlatformSections(
return make_error<StringError>(ErrStream.str());
}
- ORC_RT_DEBUG({
- printdbg(" UnwindInfo: %s, UseCallbackStyleUnwindInfo: %s\n",
- UnwindInfo ? "true" : "false",
- UseCallbackStyleUnwindInfo ? "true" : "false");
- });
-
if (UnwindInfo && UseCallbackStyleUnwindInfo) {
ORC_RT_DEBUG({
printdbg(" Registering new-style unwind info for:\n"
diff --git a/compiler-rt/test/orc/TestCases/Darwin/Generic/exceptions.cpp b/compiler-rt/test/orc/TestCases/Darwin/Generic/exceptions.cpp
deleted file mode 100644
index 7e9c40c724aec6..00000000000000
--- a/compiler-rt/test/orc/TestCases/Darwin/Generic/exceptions.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clangxx -c -o %t %s
-// RUN: %llvm_jitlink -slab-allocate=20Mb %t
-//
-// REQUIRES: system-darwin && host-arch-compatible
-
-int main(int argc, char *argv[]) {
- try {
- throw 42;
- } catch (int E) {
- return 42 - E;
- }
- return 1;
-}
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index 3eddaf4c9c59ff..db853362f65733 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -1204,13 +1204,8 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
JITDylib(ExecutionSession &ES, std::string Name);
- struct RemoveTrackerResult {
- AsynchronousSymbolQuerySet QueriesToFail;
- std::shared_ptr<SymbolDependenceMap> FailedSymbols;
- std::vector<std::unique_ptr<MaterializationUnit>> DefunctMUs;
- };
-
- RemoveTrackerResult IL_removeTracker(ResourceTracker &RT);
+ std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>>
+ IL_removeTracker(ResourceTracker &RT);
void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
index 86e98e74b7055b..dcf5592f1717c2 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h
@@ -20,7 +20,6 @@
#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
-#include "llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h"
#include "llvm/ExecutionEngine/Orc/TaskDispatch.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/MSVCErrorWorkarounds.h"
@@ -508,9 +507,6 @@ class SelfExecutorProcessControl : public ExecutorProcessControl,
SymbolLookupCompleteFn F) override;
std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
-#ifdef __APPLE__
- std::unique_ptr<UnwindInfoManager> UnwindInfoMgr;
-#endif // __APPLE__
char GlobalManglingPrefix = 0;
};
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h
index db5ff135a7164c..aed43f6308cbaa 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h
@@ -88,15 +88,6 @@ using SPSRunAsMainSignature = int64_t(shared::SPSExecutorAddr,
using SPSRunAsVoidFunctionSignature = int32_t(shared::SPSExecutorAddr);
using SPSRunAsIntFunctionSignature = int32_t(shared::SPSExecutorAddr, int32_t);
} // end namespace rt
-
-namespace rt_alt {
-extern const char *UnwindInfoManagerInstanceName;
-extern const char *UnwindInfoManagerFindSectionsHelperName;
-extern const char *UnwindInfoManagerEnableWrapperName;
-extern const char *UnwindInfoManagerDisableWrapperName;
-extern const char *UnwindInfoManagerRegisterActionName;
-extern const char *UnwindInfoManagerDeregisterActionName;
-} // end namespace rt_alt
} // end namespace orc
} // end namespace llvm
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h
deleted file mode 100644
index fc7719f2821222..00000000000000
--- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.h
+++ /dev/null
@@ -1,78 +0,0 @@
-//===--- UnwindInfoManager.h -- Register unwind info sections ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Utilities for managing eh-frame and compact-unwind registration and lookup
-// through libunwind's find_dynamic_unwind_sections mechanism.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_UNWINDINFOMANAGER_H
-#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_UNWINDINFOMANAGER_H
-
-#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
-#include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorBootstrapService.h"
-#include "llvm/Support/Error.h"
-#include <map>
-#include <mutex>
-
-namespace llvm::orc {
-
-class UnwindInfoManager : public ExecutorBootstrapService {
-public:
- // This struct's layout should match the unw_dynamic_unwind_sections struct
- // from libunwind/src/libunwid_ext.h.
- struct UnwindSections {
- uintptr_t dso_base;
- uintptr_t dwarf_section;
- size_t dwarf_section_length;
- uintptr_t compact_unwind_section;
- size_t compact_unwind_section_length;
- };
-
- /// If the libunwind find-dynamic-unwind-info callback registration APIs are
- /// available then this method will return an UnwindInfoManager instance,
- /// otherwise it will return nullptr.
- static std::unique_ptr<UnwindInfoManager> TryCreate();
-
- Error shutdown() override;
- void addBootstrapSymbols(StringMap<ExecutorAddr> &M) override;
-
- Error enable(void *FindDynamicUnwindSections);
- Error disable(void);
-
- Error registerSections(ArrayRef<orc::ExecutorAddrRange> CodeRanges,
- orc::ExecutorAddr DSOBase,
- orc::ExecutorAddrRange DWARFEHFrame,
- orc::ExecutorAddrRange CompactUnwind);
-
- Error deregisterSections(ArrayRef<orc::ExecutorAddrRange> CodeRanges);
-
- int findSections(uintptr_t Addr, UnwindSections *Info);
-
-private:
- UnwindInfoManager(int (*AddFindDynamicUnwindSections)(void *),
- int (*RemoveFindDynamicUnwindSections)(void *))
- : AddFindDynamicUnwindSections(AddFindDynamicUnwindSections),
- RemoveFindDynamicUnwindSections(RemoveFindDynamicUnwindSections) {}
-
- static int findSectionsHelper(UnwindInfoManager *Instance, uintptr_t Addr,
- UnwindSections *Info);
-
- std::mutex M;
- std::map<uintptr_t, UnwindSections> UWSecs;
-
- int (*AddFindDynamicUnwindSections)(void *) = nullptr;
- int (*RemoveFindDynamicUnwindSections)(void *) = nullptr;
- void *FindDynamicUnwindSections = nullptr;
-
- static const char *AddFnName, *RemoveFnName;
-};
-
-} // namespace llvm::orc
-
-#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_UNWINDINFOMANAGER_H
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h b/llvm/include/llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h
deleted file mode 100644
index eb883a79a93d87..00000000000000
--- a/llvm/include/llvm/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-//===- UnwindInfoRegistrationPlugin.h -- libunwind registration -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Register eh-frame and compact-unwind sections with libunwind
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_EXECUTIONENGINE_ORC_UNWINDINFOREGISTRATIONPLUGIN_H
-#define LLVM_EXECUTIONENGINE_ORC_UNWINDINFOREGISTRATIONPLUGIN_H
-
-#include "llvm/ExecutionEngine/Orc/LinkGraphLinkingLayer.h"
-
-namespace llvm::orc {
-
-class UnwindInfoRegistrationPlugin : public LinkGraphLinkingLayer::Plugin {
-public:
- static Expected<std::shared_ptr<UnwindInfoRegistrationPlugin>>
- Create(IRLayer &IRL, JITDylib &PlatformJD, ExecutorAddr Instance,
- ExecutorAddr FindHelper, ExecutorAddr Enable, ExecutorAddr Disable,
- ExecutorAddr Register, ExecutorAddr Deregister);
-
- static Expected<std::shared_ptr<UnwindInfoRegistrationPlugin>>
- Create(IRLayer &IRL, JITDylib &PlatformJD);
-
- ~UnwindInfoRegistrationPlugin();
-
- void modifyPassConfig(MaterializationResponsibility &MR,
- jitlink::LinkGraph &G,
- jitlink::PassConfiguration &PassConfig) override;
-
- Error notifyEmitted(MaterializationResponsibility &MR) override {
- return Error::success();
- }
-
- Error notifyFailed(MaterializationResponsibility &MR) override {
- return Error::success();
- }
-
- Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override {
- return Error::success();
- }
-
- void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
- ResourceKey SrcKey) override {}
-
-private:
- UnwindInfoRegistrationPlugin(ExecutionSession &ES, ExecutorAddr Instance,
- ExecutorAddr Disable, ExecutorAddr Register,
- ExecutorAddr Deregister)
- : ES(ES), Instance(Instance), Disable(Disable), Register(Register),
- Deregister(Deregister) {
- DSOBaseName = ES.intern("__jitlink$libunwind_dso_base");
- }
-
- static Expected<ThreadSafeModule> makeBouncerModule(ExecutionSession &ES);
- Error addUnwindInfoRegistrationActions(jitlink::LinkGraph &G);
-
- ExecutionSession &ES;
- SymbolStringPtr DSOBaseName;
- ExecutorAddr Instance, Disable, Register, Deregister;
-};
-
-} // namespace llvm::orc
-
-#endif // LLVM_EXECUTIONENGINE_ORC_UNWINDINFOREGISTRATIONPLUGIN_H
diff --git a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
index 65dd0c7468ae1d..e5f5a99c39bc00 100644
--- a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
@@ -3,7 +3,6 @@ tablegen(LLVM COFFOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(JITLinkTableGen)
add_llvm_component_library(LLVMJITLink
- CompactUnwindSupport.cpp
DWARFRecordSectionSplitter.cpp
EHFrameSupport.cpp
JITLink.cpp
diff --git a/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.cpp b/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.cpp
deleted file mode 100644
index 51e3d26479ffdf..00000000000000
--- a/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-//=------- CompactUnwindSupport.cpp - Compact Unwind format support -------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Compact Unwind support.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CompactUnwindSupport.h"
-
-#include "llvm/ADT/Sequence.h"
-
-#define DEBUG_TYPE "jitlink"
-
-namespace llvm {
-namespace jitlink {
-
-Error splitCompactUnwindBlocks(LinkGraph &G, Section &CompactUnwindSection,
- size_t RecordSize) {
-
- std::vector<Block *> OriginalBlocks(CompactUnwindSection.blocks().begin(),
- CompactUnwindSection.blocks().end());
- LLVM_DEBUG({
- dbgs() << "In " << G.getName() << " splitting compact unwind section "
- << CompactUnwindSection.getName() << " containing "
- << OriginalBlocks.size() << " initial blocks...\n";
- });
-
- while (!OriginalBlocks.empty()) {
- auto *B = OriginalBlocks.back();
- OriginalBlocks.pop_back();
-
- if (B->getSize() == 0) {
- LLVM_DEBUG({
- dbgs() << " Skipping empty block at "
- << formatv("{0:x16}", B->getAddress()) << "\n";
- });
- continue;
- }
-
- unsigned NumBlocks = B->getSize() / RecordSize;
-
- LLVM_DEBUG({
- dbgs() << " Splitting block at " << formatv("{0:x16}", B->getAddress())
- << " into " << NumBlocks << " compact unwind record(s)\n";
- });
-
- if (B->getSize() % RecordSize)
- return make_error<JITLinkError>(
- "Error splitting compact unwind record in " + G.getName() +
- ": block at " + formatv("{0:x}", B->getAddress()) + " has size " +
- formatv("{0:x}", B->getSize()) +
- " (not a multiple of CU record size of " +
- formatv("{0:x}", RecordSize) + ")");
-
- auto Blocks =
- G.splitBlock(*B, map_range(seq(1U, NumBlocks), [=](Edge::OffsetT Idx) {
- return Idx * RecordSize;
- }));
-
- for (auto *CURec : Blocks) {
- bool AddedKeepAlive = false;
-
- for (auto &E : CURec->edges()) {
- if (E.getOffset() == 0) {
- LLVM_DEBUG({
- dbgs() << " Updating compact unwind record at "
- << CURec->getAddress() << " to point to "
- << (E.getTarget().hasName() ? *E.getTarget().getName()
- : StringRef())
- << " (at " << E.getTarget().getAddress() << ")\n";
- });
-
- if (E.getTarget().isExternal())
- return make_error<JITLinkError>(
- "Error adding keep-alive edge for compact unwind record at " +
- formatv("{0:x}", CURec->getAddress()) + ": target " +
- *E.getTarget().getName() + " is an external symbol");
- auto &TgtBlock = E.getTarget().getBlock();
- auto &CURecSym =
- G.addAnonymousSymbol(*CURec, 0, RecordSize, false, false);
- TgtBlock.addEdge(Edge::KeepAlive, 0, CURecSym, 0);
- AddedKeepAlive = true;
- }
- }
-
- if (!AddedKeepAlive)
- return make_error<JITLinkError>(
- "Error adding keep-alive edge for compact unwind record at " +
- formatv("{0:x}", CURec->getAddress()) +
- ": no outgoing target edge at offset 0");
- }
- }
-
- return Error::success();
-}
-
-} // end namespace jitlink
-} // end namespace llvm
diff --git a/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h b/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h
deleted file mode 100644
index dc3ed942aa8ac8..00000000000000
--- a/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h
+++ /dev/null
@@ -1,653 +0,0 @@
-//===- CompactUnwindSupportImpl.h - Compact Unwind format impl --*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Compact Unwind format support implementation details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LIB_EXECUTIONENGINE_JITLINK_COMPACTUNWINDSUPPORTIMPL_H
-#define LIB_EXECUTIONENGINE_JITLINK_COMPACTUNWINDSUPPORTIMPL_H
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ExecutionEngine/JITLink/MachO.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/Endian.h"
-
-#define DEBUG_TYPE "jitlink_cu"
-
-namespace llvm {
-namespace jitlink {
-
-/// Split blocks in an __LD,__compact_unwind section on record boundaries.
-/// When this function returns edges within each record are guaranteed to be
-/// sorted by offset.
-Error splitCompactUnwindBlocks(LinkGraph &G, Section &CompactUnwindSection,
- size_t RecordSize);
-
-/// CRTP base for compact unwind traits classes. Automatically provides derived
-/// constants.
-///
-/// FIXME: Passing PtrSize as a template parameter is a hack to work around a
-/// bug in older MSVC compilers (until at least MSVC 15) where constexpr
-/// fields in the CRTP impl class were not visible to the base class.
-/// Once we no longer need to support these compilers the PtrSize
-/// template argument should be removed and PointerSize should be
-/// defined as a member in the CRTP Impl classes.
-template <typename CRTPImpl, size_t PtrSize> struct CompactUnwindTraits {
- static constexpr size_t PointerSize = PtrSize;
- static constexpr size_t Size = 3 * PointerSize + 2 * 4;
- static constexpr size_t FnFieldOffset = 0;
- static constexpr size_t SizeFieldOffset = FnFieldOffset + PointerSize;
- static constexpr size_t EncodingFieldOffset = SizeFieldOffset + 4;
- static constexpr size_t PersonalityFieldOffset = EncodingFieldOffset + 4;
- static constexpr size_t LSDAFieldOffset =
- PersonalityFieldOffset + PointerSize;
-
- static uint32_t readPCRangeSize(ArrayRef<char> RecordContent) {
- assert(SizeFieldOffset + 4 <= RecordContent.size() &&
- "Truncated CU record?");
- return support::endian::read32<CRTPImpl::Endianness>(RecordContent.data() +
- SizeFieldOffset);
- }
-
- static uint32_t readEncoding(ArrayRef<char> RecordContent) {
- assert(EncodingFieldOffset + 4 <= RecordContent.size() &&
- "Truncated CU record?");
- return support::endian::read32<CRTPImpl::Endianness>(RecordContent.data() +
- EncodingFieldOffset);
- }
-};
-
-/// Architecture specific implementation of CompactUnwindManager.
-template <typename CURecTraits> class CompactUnwindManager {
-public:
- CompactUnwindManager(StringRef CompactUnwindSectionName,
- StringRef UnwindInfoSectionName,
- StringRef EHFrameSectionName)
- : CompactUnwindSectionName(CompactUnwindSectionName),
- UnwindInfoSectionName(UnwindInfoSectionName),
- EHFrameSectionName(EHFrameSectionName) {}
-
- // Split compact unwind records, add keep-alive edges from functions to
- // compact unwind records, and from compact unwind records to FDEs where
- // needed.
- //
- // This method must be called *after* __eh_frame has been processed: it
- // assumes that eh-frame records have been split up and keep-alive edges have
- // been inserted.
- Error prepareForPrune(LinkGraph &G) {
- Section *CUSec = G.findSectionByName(CompactUnwindSectionName);
- if (!CUSec || CUSec->empty()) {
- LLVM_DEBUG({
- dbgs() << "Compact unwind: No compact unwind info for " << G.getName()
- << "\n";
- });
- return Error::success();
- }
-
- LLVM_DEBUG({
- dbgs() << "Compact unwind: preparing " << G.getName() << " for prune\n";
- });
-
- Section *EHFrameSec = G.findSectionByName(EHFrameSectionName);
-
- if (auto Err = splitCompactUnwindBlocks(G, *CUSec, CURecTraits::Size))
- return Err;
-
- LLVM_DEBUG({
- dbgs() << " Preparing " << CUSec->blocks_size() << " blocks in "
- << CompactUnwindSectionName << "...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/125098
More information about the llvm-commits
mailing list