LLVM  14.0.0git
EscapeEnumerator.h
Go to the documentation of this file.
1 //===-- EscapeEnumerator.h --------------------------------------*- 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 // Defines a helper class that enumerates all possible exits from a function,
10 // including exception handling.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
15 #define LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
16 
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/IRBuilder.h"
19 
20 namespace llvm {
21 
22 class DomTreeUpdater;
23 
24 /// EscapeEnumerator - This is a little algorithm to find all escape points
25 /// from a function so that "finally"-style code can be inserted. In addition
26 /// to finding the existing return and unwind instructions, it also (if
27 /// necessary) transforms any call instructions into invokes and sends them to
28 /// a landing pad.
30  Function &F;
31  const char *CleanupBBName;
32 
33  Function::iterator StateBB, StateE;
34  IRBuilder<> Builder;
35  bool Done;
36  bool HandleExceptions;
37 
38  DomTreeUpdater *DTU;
39 
40 public:
41  EscapeEnumerator(Function &F, const char *N = "cleanup",
42  bool HandleExceptions = true, DomTreeUpdater *DTU = nullptr)
43  : F(F), CleanupBBName(N), StateBB(F.begin()), StateE(F.end()),
44  Builder(F.getContext()), Done(false),
45  HandleExceptions(HandleExceptions), DTU(DTU) {}
46 
47  IRBuilder<> *Next();
48 };
49 
50 }
51 
52 #endif // LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::EscapeEnumerator
EscapeEnumerator - This is a little algorithm to find all escape points from a function so that "fina...
Definition: EscapeEnumerator.h:29
llvm::Function
Definition: Function.h:61
llvm::IRBuilder<>
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
F
#define F(x, y, z)
Definition: MD5.cpp:56
false
Definition: StackSlotColoring.cpp:142
llvm::DomTreeUpdater
Definition: DomTreeUpdater.h:28
llvm::EscapeEnumerator::EscapeEnumerator
EscapeEnumerator(Function &F, const char *N="cleanup", bool HandleExceptions=true, DomTreeUpdater *DTU=nullptr)
Definition: EscapeEnumerator.h:41
IRBuilder.h
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::EscapeEnumerator::Next
IRBuilder * Next()
Definition: EscapeEnumerator.cpp:30
Function.h
N
#define N
llvm::Function::iterator
BasicBlockListType::iterator iterator
Definition: Function.h:67