LLVM  4.0.0
FuncletLayout.cpp
Go to the documentation of this file.
1 //===-- FuncletLayout.cpp - Contiguously lay out funclets -----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements basic block placement transformations which result in
11 // funclets being contiguous.
12 //
13 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/Passes.h"
15 #include "llvm/CodeGen/Analysis.h"
18 using namespace llvm;
19 
20 #define DEBUG_TYPE "funclet-layout"
21 
22 namespace {
23 class FuncletLayout : public MachineFunctionPass {
24 public:
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 {
34  }
35 };
36 }
37 
38 char FuncletLayout::ID = 0;
40 INITIALIZE_PASS(FuncletLayout, "funclet-layout",
41  "Contiguously Lay Out Funclets", false, false)
42 
43 bool FuncletLayout::runOnMachineFunction(MachineFunction &F) {
46  if (FuncletMembership.empty())
47  return false;
48 
49  F.sort([&](MachineBasicBlock &X, MachineBasicBlock &Y) {
50  auto FuncletX = FuncletMembership.find(&X);
51  auto FuncletY = FuncletMembership.find(&Y);
52  assert(FuncletX != FuncletMembership.end());
53  assert(FuncletY != FuncletMembership.end());
54  return FuncletX->second < FuncletY->second;
55  });
56 
57  // Conservatively assume we changed something.
58  return true;
59 }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
char & FuncletLayoutID
This pass lays out funclets contiguously.
INITIALIZE_PASS(FuncletLayout,"funclet-layout","Contiguously Lay Out Funclets", false, false) bool FuncletLayout
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void initializeFuncletLayoutPass(PassRegistry &)
#define F(x, y, z)
Definition: MD5.cpp:51
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
DenseMap< const MachineBasicBlock *, int > getFuncletMembership(const MachineFunction &MF)
MachineFunctionProperties & set(Property P)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
Properties which a MachineFunction may have at a given point in time.