mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
The first variant contains all current transformations except transforming switches into lookup tables. The second variant contains all current transformations. The switch-to-lookup-table conversion results in code that is more difficult to analyze and optimize by other passes. Most importantly, it can inhibit Dead Code Elimination. As such it is often beneficial to only apply this transformation very late. A common example is inlining, which can often result in range restrictions for the switch expression. Changes in execution time according to LNT: SingleSource/Benchmarks/Misc/fp-convert +3.03% MultiSource/Benchmarks/ASC_Sequoia/CrystalMk/CrystalMk -11.20% MultiSource/Benchmarks/Olden/perimeter/perimeter -10.43% and a couple of smaller changes. For perimeter it also results 2.6% a smaller binary. Differential Revision: https://reviews.llvm.org/D30333 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298799 91177308-0d34-0410-b5e6-96231b3b80d8
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
//===- SimplifyCFG.h - Simplify and canonicalize the CFG --------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
/// This file provides the interface for the pass responsible for both
|
|
/// simplifying and canonicalizing the CFG.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TRANSFORMS_SCALAR_SIMPLIFYCFG_H
|
|
#define LLVM_TRANSFORMS_SCALAR_SIMPLIFYCFG_H
|
|
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/PassManager.h"
|
|
|
|
namespace llvm {
|
|
|
|
/// \brief A pass to simplify and canonicalize the CFG of a function.
|
|
///
|
|
/// This pass iteratively simplifies the entire CFG of a function, removing
|
|
/// unnecessary control flows and bringing it into the canonical form expected
|
|
/// by the rest of the mid-level optimizer.
|
|
class SimplifyCFGPass : public PassInfoMixin<SimplifyCFGPass> {
|
|
int BonusInstThreshold;
|
|
bool LateSimplifyCFG;
|
|
|
|
public:
|
|
/// \brief Construct a pass with the default thresholds
|
|
/// and switch optimizations.
|
|
SimplifyCFGPass();
|
|
|
|
/// \brief Construct a pass with a specific bonus threshold
|
|
/// and optional switch optimizations.
|
|
SimplifyCFGPass(int BonusInstThreshold, bool LateSimplifyCFG);
|
|
|
|
/// \brief Run the pass over the function.
|
|
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|