mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-14 20:10:58 +00:00

This patch implements a optimization bisect feature, which will allow optimizations to be selectively disabled at compile time in order to track down test failures that are caused by incorrect optimizations. The bisection is enabled using a new command line option (-opt-bisect-limit). Individual passes that may be skipped call the OptBisect object (via an LLVMContext) to see if they should be skipped based on the bisect limit. A finer level of control (disabling individual transformations) can be managed through an addition OptBisect method, but this is not yet used. The skip checking in this implementation is based on (and replaces) the skipOptnoneFunction check. Where that check was being called, a new call has been inserted in its place which checks the bisect limit and the optnone attribute. A new function call has been added for module and SCC passes that behaves in a similar way. Differential Revision: http://reviews.llvm.org/D19172 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267022 91177308-0d34-0410-b5e6-96231b3b80d8
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
//===-- TailDuplication.cpp - Duplicate blocks into predecessors' tails ---===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This pass duplicates basic blocks ending in unconditional branches into
|
|
// the tails of their predecessors, using the TailDuplicator utility class.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/CodeGen/Passes.h"
|
|
#include "llvm/CodeGen/TailDuplicator.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/Support/Debug.h"
|
|
using namespace llvm;
|
|
|
|
#define DEBUG_TYPE "tailduplication"
|
|
|
|
namespace {
|
|
/// Perform tail duplication. Delegates to TailDuplicator
|
|
class TailDuplicatePass : public MachineFunctionPass {
|
|
TailDuplicator Duplicator;
|
|
|
|
public:
|
|
static char ID;
|
|
explicit TailDuplicatePass() : MachineFunctionPass(ID) {}
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
|
};
|
|
|
|
char TailDuplicatePass::ID = 0;
|
|
}
|
|
|
|
char &llvm::TailDuplicateID = TailDuplicatePass::ID;
|
|
|
|
INITIALIZE_PASS(TailDuplicatePass, "tailduplication", "Tail Duplication", false,
|
|
false)
|
|
|
|
bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) {
|
|
if (skipFunction(*MF.getFunction()))
|
|
return false;
|
|
|
|
auto MMI = getAnalysisIfAvailable<MachineModuleInfo>();
|
|
auto MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
|
|
|
|
Duplicator.initMF(MF, MMI, MBPI);
|
|
|
|
bool MadeChange = false;
|
|
while (Duplicator.tailDuplicateBlocks(MF))
|
|
MadeChange = true;
|
|
|
|
return MadeChange;
|
|
}
|
|
|
|
void TailDuplicatePass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
AU.addRequired<MachineBranchProbabilityInfo>();
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
}
|