LLVM 24.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//===----------------------------------------------------------------------===//
17#include "llvm/CodeGen/Passes.h"
19using namespace llvm;
20
21#define DEBUG_TYPE "funclet-layout"
22
24 // Even though this gets information from getEHScopeMembership(), this pass is
25 // only necessary for funclet-based EH personalities, in which these EH scopes
26 // are outlined at the end.
29 if (FuncletMembership.empty())
30 return false;
31
33 auto FuncletX = FuncletMembership.find(&X);
34 auto FuncletY = FuncletMembership.find(&Y);
35 assert(FuncletX != FuncletMembership.end());
36 assert(FuncletY != FuncletMembership.end());
37 return FuncletX->second < FuncletY->second;
38 });
39
40 // Conservatively assume we changed something.
41 return true;
42}
43
44namespace {
45class FuncletLayoutLegacy : public MachineFunctionPass {
46public:
47 static char ID; // Pass identification, replacement for typeid
48 FuncletLayoutLegacy() : MachineFunctionPass(ID) {}
49
50 bool runOnMachineFunction(MachineFunction &F) override {
51 return runFuncletLayout(F);
52 }
53 MachineFunctionProperties getRequiredProperties() const override {
54 return MachineFunctionProperties().setNoVRegs();
55 }
56};
57} // namespace
58
59char FuncletLayoutLegacy::ID = 0;
60char &llvm::FuncletLayoutID = FuncletLayoutLegacy::ID;
61INITIALIZE_PASS(FuncletLayoutLegacy, DEBUG_TYPE,
62 "Contiguously Lay Out Funclets", false, false)
63
66 MFPropsModifier _(*this, MF);
67 if (!runFuncletLayout(MF))
69
71}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define X(NUM, ENUM, NAME)
Definition ELF.h:856
static bool runFuncletLayout(MachineFunction &F)
#define DEBUG_TYPE
#define _
#define F(x, y, z)
Definition MD5.cpp:54
#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")
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:223
bool empty() const
Definition DenseMap.h:171
iterator end()
Definition DenseMap.h:141
An RAII based helper class to modify MachineFunctionProperties when running pass.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI char & FuncletLayoutID
This pass lays out funclets contiguously.
LLVM_ABI DenseMap< const MachineBasicBlock *, int > getEHScopeMembership(const MachineFunction &MF)
Definition Analysis.cpp:757