LLVM  16.0.0git
SEHFrameSupport.h
Go to the documentation of this file.
1 //===------- SEHFrameSupport.h - JITLink seh-frame utils --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // SEHFrame utils for JITLink.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_JITLINK_SEHFRAMESUPPORT_H
14 #define LLVM_EXECUTIONENGINE_JITLINK_SEHFRAMESUPPORT_H
15 
16 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Error.h"
20 
21 namespace llvm {
22 namespace jitlink {
23 /// This pass adds keep-alive edge from SEH frame sections
24 /// to the parent function content block.
26 public:
27  SEHFrameKeepAlivePass(StringRef SEHFrameSectionName)
28  : SEHFrameSectionName(SEHFrameSectionName) {}
29 
31  auto *S = G.findSectionByName(SEHFrameSectionName);
32  if (!S)
33  return Error::success();
34 
35  // Simply consider every block pointed by seh frame block as parants.
36  // This adds some unnecessary keep-alive edges to unwind info blocks,
37  // (xdata) but these blocks are usually dead by default, so they wouldn't
38  // count for the fate of seh frame block.
39  for (auto *B : S->blocks()) {
40  auto &DummySymbol = G.addAnonymousSymbol(*B, 0, 0, false, false);
41  DenseSet<Block *> Children;
42  for (auto &E : B->edges()) {
43  auto &Sym = E.getTarget();
44  if (!Sym.isDefined())
45  continue;
46  Children.insert(&Sym.getBlock());
47  }
48  for (auto *Child : Children)
49  Child->addEdge(Edge(Edge::KeepAlive, 0, DummySymbol, 0));
50  }
51  return Error::success();
52  }
53 
54 private:
55  StringRef SEHFrameSectionName;
56 };
57 
58 } // end namespace jitlink
59 } // end namespace llvm
60 
61 #endif // LLVM_EXECUTIONENGINE_JITLINK_SEHFRAMESUPPORT_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
JITSymbol.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
Error.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseSet< Block * >
Triple.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155