LLVM 22.0.0git
FuncletLayout.cpp
Go to the documentation of this file.
1//===-- FuncletLayout.cpp - Contiguously lay out funclets -----------------===//
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// This file implements basic block placement transformations which result in
10// funclets being contiguous.
11//
12//===----------------------------------------------------------------------===//
16#include "llvm/CodeGen/Passes.h"
18using namespace llvm;
19
20#define DEBUG_TYPE "funclet-layout"
21
22namespace {
23class FuncletLayout : public MachineFunctionPass {
24public:
25 static char ID; // Pass identification, replacement for typeid
26 FuncletLayout() : MachineFunctionPass(ID) {
28 }
29
30 bool runOnMachineFunction(MachineFunction &F) override;
31 MachineFunctionProperties getRequiredProperties() const override {
32 return MachineFunctionProperties().setNoVRegs();
33 }
34};
35}
36
37char FuncletLayout::ID = 0;
38char &llvm::FuncletLayoutID = FuncletLayout::ID;
40 "Contiguously Lay Out Funclets", false, false)
41
42bool FuncletLayout::runOnMachineFunction(MachineFunction &F) {
43 // Even though this gets information from getEHScopeMembership(), this pass is
44 // only necessary for funclet-based EH personalities, in which these EH scopes
45 // are outlined at the end.
48 if (FuncletMembership.empty())
49 return false;
50
52 auto FuncletX = FuncletMembership.find(&X);
53 auto FuncletY = FuncletMembership.find(&Y);
54 assert(FuncletX != FuncletMembership.end());
55 assert(FuncletY != FuncletMembership.end());
56 return FuncletX->second < FuncletY->second;
57 });
58
59 // Conservatively assume we changed something.
60 return true;
61}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define DEBUG_TYPE
#define F(x, y, z)
Definition MD5.cpp:55
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:165
bool empty() const
Definition DenseMap.h:107
iterator end()
Definition DenseMap.h:81
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Properties which a MachineFunction may have at a given point in time.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void initializeFuncletLayoutPass(PassRegistry &)
LLVM_ABI char & FuncletLayoutID
This pass lays out funclets contiguously.
DenseMap< const MachineBasicBlock *, int > getEHScopeMembership(const MachineFunction &MF)
Definition Analysis.cpp:761