mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
62 lines
2.2 KiB
C++
62 lines
2.2 KiB
C++
//===-- FuncletLayout.cpp - Contiguously lay out funclets -----------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements basic block placement transformations which result in
|
|
// funclets being contiguous.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#include "llvm/CodeGen/Analysis.h"
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/CodeGen/Passes.h"
|
|
using namespace llvm;
|
|
|
|
#define DEBUG_TYPE "funclet-layout"
|
|
|
|
namespace {
|
|
class FuncletLayout : public MachineFunctionPass {
|
|
public:
|
|
static char ID; // Pass identification, replacement for typeid
|
|
FuncletLayout() : MachineFunctionPass(ID) {
|
|
initializeFuncletLayoutPass(*PassRegistry::getPassRegistry());
|
|
}
|
|
|
|
bool runOnMachineFunction(MachineFunction &F) override;
|
|
MachineFunctionProperties getRequiredProperties() const override {
|
|
return MachineFunctionProperties().set(
|
|
MachineFunctionProperties::Property::NoVRegs);
|
|
}
|
|
};
|
|
}
|
|
|
|
char FuncletLayout::ID = 0;
|
|
char &llvm::FuncletLayoutID = FuncletLayout::ID;
|
|
INITIALIZE_PASS(FuncletLayout, DEBUG_TYPE,
|
|
"Contiguously Lay Out Funclets", false, false)
|
|
|
|
bool FuncletLayout::runOnMachineFunction(MachineFunction &F) {
|
|
// Even though this gets information from getEHScopeMembership(), this pass is
|
|
// only necessary for funclet-based EH personalities, in which these EH scopes
|
|
// are outlined at the end.
|
|
DenseMap<const MachineBasicBlock *, int> FuncletMembership =
|
|
getEHScopeMembership(F);
|
|
if (FuncletMembership.empty())
|
|
return false;
|
|
|
|
F.sort([&](MachineBasicBlock &X, MachineBasicBlock &Y) {
|
|
auto FuncletX = FuncletMembership.find(&X);
|
|
auto FuncletY = FuncletMembership.find(&Y);
|
|
assert(FuncletX != FuncletMembership.end());
|
|
assert(FuncletY != FuncletMembership.end());
|
|
return FuncletX->second < FuncletY->second;
|
|
});
|
|
|
|
// Conservatively assume we changed something.
|
|
return true;
|
|
}
|