1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861

llvm-svn: 80766
This commit is contained in:
Chris Lattner 2009-09-02 06:11:42 +00:00
parent 52279dbf17
commit 5f54c5bd1c
30 changed files with 82 additions and 118 deletions

View File

@ -21,19 +21,17 @@
#include "llvm/IntrinsicInst.h"
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
STATISTIC(NumRemoved, "Number of instructions removed");
namespace {
struct VISIBILITY_HIDDEN ADCE : public FunctionPass {
struct ADCE : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
ADCE() : FunctionPass(&ID) {}

View File

@ -31,7 +31,6 @@
#include "llvm/Function.h"
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Transforms/Scalar.h"
#include <set>
@ -40,7 +39,7 @@ using namespace llvm;
STATISTIC(NumMoved, "Number of basic blocks moved");
namespace {
struct VISIBILITY_HIDDEN BlockPlacement : public FunctionPass {
struct BlockPlacement : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
BlockPlacement() : FunctionPass(&ID) {}

View File

@ -33,7 +33,6 @@
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/PatternMatch.h"
@ -45,7 +44,7 @@ static cl::opt<bool> FactorCommonPreds("split-critical-paths-tweak",
cl::init(false), cl::Hidden);
namespace {
class VISIBILITY_HIDDEN CodeGenPrepare : public FunctionPass {
class CodeGenPrepare : public FunctionPass {
/// TLI - Keep a pointer of a TargetLowering to consult for determining
/// transformation profitability.
const TargetLowering *TLI;

View File

@ -22,14 +22,13 @@
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
using namespace llvm;
STATISTIC(NumBrThread, "Number of CFG edges threaded through branches");
STATISTIC(NumSwThread, "Number of CFG edges threaded through switches");
namespace {
struct VISIBILITY_HIDDEN CondProp : public FunctionPass {
struct CondProp : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
CondProp() : FunctionPass(&ID) {}

View File

@ -24,7 +24,6 @@
#include "llvm/Constant.h"
#include "llvm/Instruction.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/ADT/Statistic.h"
#include <set>
@ -33,7 +32,7 @@ using namespace llvm;
STATISTIC(NumInstKilled, "Number of instructions killed");
namespace {
struct VISIBILITY_HIDDEN ConstantPropagation : public FunctionPass {
struct ConstantPropagation : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
ConstantPropagation() : FunctionPass(&ID) {}

View File

@ -21,7 +21,6 @@
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Instruction.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/ADT/Statistic.h"
#include <set>
@ -34,7 +33,7 @@ namespace {
//===--------------------------------------------------------------------===//
// DeadInstElimination pass implementation
//
struct VISIBILITY_HIDDEN DeadInstElimination : public BasicBlockPass {
struct DeadInstElimination : public BasicBlockPass {
static char ID; // Pass identification, replacement for typeid
DeadInstElimination() : BasicBlockPass(&ID) {}
virtual bool runOnBasicBlock(BasicBlock &BB) {

View File

@ -29,14 +29,13 @@
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/Compiler.h"
using namespace llvm;
STATISTIC(NumFastStores, "Number of stores deleted");
STATISTIC(NumFastOther , "Number of other instrs removed");
namespace {
struct VISIBILITY_HIDDEN DSE : public FunctionPass {
struct DSE : public FunctionPass {
TargetData *TD;
static char ID; // Pass identification, replacement for typeid

View File

@ -35,7 +35,6 @@
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
@ -62,7 +61,7 @@ static cl::opt<bool> EnableLoadPRE("enable-load-pre", cl::init(true));
/// as an efficient mechanism to determine the expression-wise equivalence of
/// two values.
namespace {
struct VISIBILITY_HIDDEN Expression {
struct Expression {
enum ExpressionOpcode { ADD, FADD, SUB, FSUB, MUL, FMUL,
UDIV, SDIV, FDIV, UREM, SREM,
FREM, SHL, LSHR, ASHR, AND, OR, XOR, ICMPEQ,
@ -119,7 +118,7 @@ namespace {
}
};
class VISIBILITY_HIDDEN ValueTable {
class ValueTable {
private:
DenseMap<Value*, uint32_t> valueNumbering;
DenseMap<Expression, uint32_t> expressionNumbering;
@ -678,7 +677,7 @@ void ValueTable::verifyRemoved(const Value *V) const {
//===----------------------------------------------------------------------===//
namespace {
struct VISIBILITY_HIDDEN ValueNumberScope {
struct ValueNumberScope {
ValueNumberScope* parent;
DenseMap<uint32_t, Value*> table;
@ -688,7 +687,7 @@ namespace {
namespace {
class VISIBILITY_HIDDEN GVN : public FunctionPass {
class GVN : public FunctionPass {
bool runOnFunction(Function &F);
public:
static char ID; // Pass identification, replacement for typeid

View File

@ -37,7 +37,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@ -133,7 +132,7 @@ struct Expression {
}
namespace {
class VISIBILITY_HIDDEN ValueTable {
class ValueTable {
private:
DenseMap<Value*, uint32_t> valueNumbering;
DenseMap<Expression, uint32_t> expressionNumbering;
@ -675,8 +674,7 @@ class ValueNumberedSet {
//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN GVNPRE : public FunctionPass {
class GVNPRE : public FunctionPass {
bool runOnFunction(Function &F);
public:
static char ID; // Pass identification, replacement for typeid

View File

@ -51,7 +51,6 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@ -68,7 +67,7 @@ STATISTIC(NumReplaced, "Number of exit values replaced");
STATISTIC(NumLFTR , "Number of loop exit tests replaced");
namespace {
class VISIBILITY_HIDDEN IndVarSimplify : public LoopPass {
class IndVarSimplify : public LoopPass {
IVUsers *IU;
LoopInfo *LI;
ScalarEvolution *SE;

View File

@ -55,7 +55,6 @@
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/PatternMatch.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
@ -159,9 +158,8 @@ namespace {
namespace {
class VISIBILITY_HIDDEN InstCombiner
: public FunctionPass,
public InstVisitor<InstCombiner, Instruction*> {
class InstCombiner : public FunctionPass,
public InstVisitor<InstCombiner, Instruction*> {
TargetData *TD;
bool MustPreserveLCSSA;
bool MadeIRChange;

View File

@ -26,7 +26,6 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/Support/raw_ostream.h"
@ -57,7 +56,7 @@ namespace {
/// In this case, the unconditional branch at the end of the first if can be
/// revectored to the false side of the second if.
///
class VISIBILITY_HIDDEN JumpThreading : public FunctionPass {
class JumpThreading : public FunctionPass {
TargetData *TD;
#ifdef NDEBUG
SmallPtrSet<BasicBlock*, 16> LoopHeaders;

View File

@ -46,7 +46,6 @@
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
@ -74,7 +73,7 @@ EnableLICMConstantMotion("enable-licm-constant-variables", cl::Hidden,
"global variables"));
namespace {
struct VISIBILITY_HIDDEN LICM : public LoopPass {
struct LICM : public LoopPass {
static char ID; // Pass identification, replacement for typeid
LICM() : LoopPass(&ID) {}

View File

@ -15,19 +15,17 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "loop-delete"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SmallVector.h"
using namespace llvm;
STATISTIC(NumDeleted, "Number of loops deleted");
namespace {
class VISIBILITY_HIDDEN LoopDeletion : public LoopPass {
class LoopDeletion : public LoopPass {
public:
static char ID; // Pass ID, replacement for typeid
LoopDeletion() : LoopPass(&ID) {}

View File

@ -51,7 +51,6 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "loop-index-split"
#include "llvm/Transforms/Scalar.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
@ -61,7 +60,6 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
@ -73,8 +71,7 @@ STATISTIC(NumRestrictBounds, "Number of loop iteration space restricted");
namespace {
class VISIBILITY_HIDDEN LoopIndexSplit : public LoopPass {
class LoopIndexSplit : public LoopPass {
public:
static char ID; // Pass ID, replacement for typeid
LoopIndexSplit() : LoopPass(&ID) {}

View File

@ -32,7 +32,7 @@ using namespace llvm;
STATISTIC(NumRotated, "Number of loops rotated");
namespace {
class VISIBILITY_HIDDEN RenameData {
class RenameData {
public:
RenameData(Instruction *O, Value *P, Instruction *H)
: Original(O), PreHeader(P), Header(H) { }
@ -42,8 +42,7 @@ namespace {
Instruction *Header; // New header replacement
};
class VISIBILITY_HIDDEN LoopRotate : public LoopPass {
class LoopRotate : public LoopPass {
public:
static char ID; // Pass ID, replacement for typeid
LoopRotate() : LoopPass(&ID) {}

View File

@ -38,7 +38,6 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/Support/raw_ostream.h"
@ -65,7 +64,7 @@ namespace {
/// IVInfo - This structure keeps track of one IV expression inserted during
/// StrengthReduceStridedIVUsers. It contains the stride, the common base, as
/// well as the PHI node and increment value created for rewrite.
struct VISIBILITY_HIDDEN IVExpr {
struct IVExpr {
const SCEV *Stride;
const SCEV *Base;
PHINode *PHI;
@ -76,7 +75,7 @@ namespace {
/// IVsOfOneStride - This structure keeps track of all IV expression inserted
/// during StrengthReduceStridedIVUsers for a particular stride of the IV.
struct VISIBILITY_HIDDEN IVsOfOneStride {
struct IVsOfOneStride {
std::vector<IVExpr> IVs;
void addIV(const SCEV *const Stride, const SCEV *const Base, PHINode *PHI) {
@ -84,7 +83,7 @@ namespace {
}
};
class VISIBILITY_HIDDEN LoopStrengthReduce : public LoopPass {
class LoopStrengthReduce : public LoopPass {
IVUsers *IU;
LoopInfo *LI;
DominatorTree *DT;

View File

@ -17,7 +17,6 @@
#include "llvm/Transforms/Scalar.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@ -40,7 +39,7 @@ UnrollAllowPartial("unroll-allow-partial", cl::init(false), cl::Hidden,
"-unroll-threshold loop size is reached."));
namespace {
class VISIBILITY_HIDDEN LoopUnroll : public LoopPass {
class LoopUnroll : public LoopPass {
public:
static char ID; // Pass ID, replacement for typeid
LoopUnroll() : LoopPass(&ID) {}

View File

@ -44,7 +44,6 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@ -62,7 +61,7 @@ Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
cl::init(10), cl::Hidden);
namespace {
class VISIBILITY_HIDDEN LoopUnswitch : public LoopPass {
class LoopUnswitch : public LoopPass {
LoopInfo *LI; // Loop information
LPPassManager *LPM;

View File

@ -296,8 +296,7 @@ void MemsetRanges::addStore(int64_t Start, StoreInst *SI) {
//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN MemCpyOpt : public FunctionPass {
class MemCpyOpt : public FunctionPass {
bool runOnFunction(Function &F);
public:
static char ID; // Pass identification, replacement for typeid

View File

@ -93,7 +93,6 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InstVisitor.h"
@ -377,12 +376,12 @@ namespace {
}
/// ValueNumbering stores the scope-specific value numbers for a given Value.
class VISIBILITY_HIDDEN ValueNumbering {
class ValueNumbering {
/// VNPair is a tuple of {Value, index number, DomTreeDFS::Node}. It
/// includes the comparison operators necessary to allow you to store it
/// in a sorted vector.
class VISIBILITY_HIDDEN VNPair {
class VNPair {
public:
Value *V;
unsigned index;
@ -592,7 +591,7 @@ namespace {
///
/// The InequalityGraph class may invalidate Node*s after any mutator call.
/// @brief The InequalityGraph stores the relationships between values.
class VISIBILITY_HIDDEN InequalityGraph {
class InequalityGraph {
ValueNumbering &VN;
DomTreeDFS::Node *TreeRoot;
@ -608,7 +607,7 @@ namespace {
/// and contains a pointer to the other end. The edge contains a lattice
/// value specifying the relationship and an DomTreeDFS::Node specifying
/// the root in the dominator tree to which this edge applies.
class VISIBILITY_HIDDEN Edge {
class Edge {
public:
Edge(unsigned T, LatticeVal V, DomTreeDFS::Node *ST)
: To(T), LV(V), Subtree(ST) {}
@ -639,7 +638,7 @@ namespace {
/// for the node, as well as the relationships with the neighbours.
///
/// @brief A single node in the InequalityGraph.
class VISIBILITY_HIDDEN Node {
class Node {
friend class InequalityGraph;
typedef SmallVector<Edge, 4> RelationsType;
@ -904,12 +903,12 @@ namespace {
/// ValueRanges tracks the known integer ranges and anti-ranges of the nodes
/// in the InequalityGraph.
class VISIBILITY_HIDDEN ValueRanges {
class ValueRanges {
ValueNumbering &VN;
TargetData *TD;
LLVMContext *Context;
class VISIBILITY_HIDDEN ScopedRange {
class ScopedRange {
typedef std::vector<std::pair<DomTreeDFS::Node *, ConstantRange> >
RangeListType;
RangeListType RangeList;
@ -1270,7 +1269,7 @@ namespace {
/// another discovered to be unreachable. This is used to cull the graph when
/// analyzing instructions, and to mark blocks with the "unreachable"
/// terminator instruction after the function has executed.
class VISIBILITY_HIDDEN UnreachableBlocks {
class UnreachableBlocks {
private:
std::vector<BasicBlock *> DeadBlocks;
@ -1324,7 +1323,7 @@ namespace {
/// variables, and forwards changes along to the InequalityGraph. It
/// also maintains the correct choice for "canonical" in the IG.
/// @brief VRPSolver calculates inferences from a new relationship.
class VISIBILITY_HIDDEN VRPSolver {
class VRPSolver {
private:
friend class ValueRanges;
@ -2266,7 +2265,7 @@ namespace {
/// one equivalent variable with another. It also tracks what
/// can't be equal and will solve setcc instructions when possible.
/// @brief Root of the predicate simplifier optimization.
class VISIBILITY_HIDDEN PredicateSimplifier : public FunctionPass {
class PredicateSimplifier : public FunctionPass {
DomTreeDFS *DTDFS;
bool modified;
ValueNumbering *VN;
@ -2295,7 +2294,7 @@ namespace {
/// PredicateSimplifier::proceedToSuccessor(s) interface to enter the
/// basic block.
/// @brief Performs abstract execution of the program.
class VISIBILITY_HIDDEN Forwards : public InstVisitor<Forwards> {
class Forwards : public InstVisitor<Forwards> {
friend class InstVisitor<Forwards>;
PredicateSimplifier *PS;
DomTreeDFS::Node *DTNode;

View File

@ -31,7 +31,6 @@
#include "llvm/Pass.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ValueHandle.h"
#include "llvm/Support/raw_ostream.h"
@ -47,7 +46,7 @@ STATISTIC(NumAnnihil, "Number of expr tree annihilated");
STATISTIC(NumFactor , "Number of multiplies factored");
namespace {
struct VISIBILITY_HIDDEN ValueEntry {
struct ValueEntry {
unsigned Rank;
Value *Op;
ValueEntry(unsigned R, Value *O) : Rank(R), Op(O) {}
@ -72,7 +71,7 @@ static void PrintOps(Instruction *I, const std::vector<ValueEntry> &Ops) {
#endif
namespace {
class VISIBILITY_HIDDEN Reassociate : public FunctionPass {
class Reassociate : public FunctionPass {
std::map<BasicBlock*, unsigned> RankMap;
std::map<AssertingVH<>, unsigned> ValueRankMap;
bool MadeChange;

View File

@ -26,7 +26,6 @@
#include "llvm/BasicBlock.h"
#include "llvm/Instructions.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CFG.h"
#include <list>
using namespace llvm;
@ -35,7 +34,7 @@ STATISTIC(NumRegsDemoted, "Number of registers demoted");
STATISTIC(NumPhisDemoted, "Number of phi-nodes demoted");
namespace {
struct VISIBILITY_HIDDEN RegToMem : public FunctionPass {
struct RegToMem : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
RegToMem() : FunctionPass(&ID) {}

View File

@ -33,7 +33,6 @@
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
@ -60,7 +59,7 @@ namespace {
/// LatticeVal class - This class represents the different lattice values that
/// an LLVM value may occupy. It is a simple class with value semantics.
///
class VISIBILITY_HIDDEN LatticeVal {
class LatticeVal {
enum {
/// undefined - This LLVM Value has no known value yet.
undefined,
@ -1506,7 +1505,7 @@ namespace {
/// SCCP Class - This class uses the SCCPSolver to implement a per-function
/// Sparse Conditional Constant Propagator.
///
struct VISIBILITY_HIDDEN SCCP : public FunctionPass {
struct SCCP : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
SCCP() : FunctionPass(&ID) {}
@ -1621,7 +1620,7 @@ namespace {
/// IPSCCP Class - This class implements interprocedural Sparse Conditional
/// Constant Propagation.
///
struct VISIBILITY_HIDDEN IPSCCP : public ModulePass {
struct IPSCCP : public ModulePass {
static char ID;
IPSCCP() : ModulePass(&ID) {}
bool runOnModule(Module &M);

View File

@ -38,7 +38,6 @@
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
@ -50,7 +49,7 @@ STATISTIC(NumConverted, "Number of aggregates converted to scalar");
STATISTIC(NumGlobals, "Number of allocas copied from constant global");
namespace {
struct VISIBILITY_HIDDEN SROA : public FunctionPass {
struct SROA : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
explicit SROA(signed T = -1) : FunctionPass(&ID) {
if (T == -1)

View File

@ -30,7 +30,6 @@
#include "llvm/Module.h"
#include "llvm/Attributes.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Pass.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallPtrSet.h"
@ -40,7 +39,7 @@ using namespace llvm;
STATISTIC(NumSimpl, "Number of blocks simplified");
namespace {
struct VISIBILITY_HIDDEN CFGSimplifyPass : public FunctionPass {
struct CFGSimplifyPass : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
CFGSimplifyPass() : FunctionPass(&ID) {}

View File

@ -22,15 +22,13 @@
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Config/config.h"
using namespace llvm;
namespace {
/// This pass optimizes well half_powr function calls.
///
class VISIBILITY_HIDDEN SimplifyHalfPowrLibCalls : public FunctionPass {
class SimplifyHalfPowrLibCalls : public FunctionPass {
const TargetData *TD;
public:
static char ID; // Pass identification
@ -59,8 +57,9 @@ FunctionPass *llvm::createSimplifyHalfPowrLibCallsPass() {
/// InlineHalfPowrs - Inline a sequence of adjacent half_powr calls, rearranging
/// their control flow to better facilitate subsequent optimization.
Instruction *
SimplifyHalfPowrLibCalls::InlineHalfPowrs(const std::vector<Instruction *> &HalfPowrs,
Instruction *InsertPt) {
SimplifyHalfPowrLibCalls::
InlineHalfPowrs(const std::vector<Instruction *> &HalfPowrs,
Instruction *InsertPt) {
std::vector<BasicBlock *> Bodies;
BasicBlock *NewBlock = 0;

View File

@ -30,7 +30,6 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Config/config.h"
@ -46,7 +45,7 @@ STATISTIC(NumAnnotated, "Number of attributes added to library functions");
/// This class is the abstract base class for the set of optimizations that
/// corresponds to one library call.
namespace {
class VISIBILITY_HIDDEN LibCallOptimization {
class LibCallOptimization {
protected:
Function *Caller;
const TargetData *TD;
@ -508,7 +507,7 @@ namespace {
// 'exit' Optimizations
/// ExitOpt - int main() { exit(4); } --> int main() { return 4; }
struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization {
struct ExitOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify we have a reasonable prototype for exit.
if (Callee->arg_size() == 0 || !CI->use_empty())
@ -552,7 +551,7 @@ struct VISIBILITY_HIDDEN ExitOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strcat' Optimizations
struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
struct StrCatOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strcat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -602,7 +601,7 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strncat' Optimizations
struct VISIBILITY_HIDDEN StrNCatOpt : public StrCatOpt {
struct StrNCatOpt : public StrCatOpt {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strncat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -650,7 +649,7 @@ struct VISIBILITY_HIDDEN StrNCatOpt : public StrCatOpt {
//===---------------------------------------===//
// 'strchr' Optimizations
struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
struct StrChrOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strchr" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -706,7 +705,7 @@ struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strcmp' Optimizations
struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
struct StrCmpOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strcmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -753,7 +752,7 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strncmp' Optimizations
struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
struct StrNCmpOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strncmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -799,7 +798,7 @@ struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strcpy' Optimizations
struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
struct StrCpyOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Verify the "strcpy" function prototype.
const FunctionType *FT = Callee->getFunctionType();
@ -830,7 +829,7 @@ struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strncpy' Optimizations
struct VISIBILITY_HIDDEN StrNCpyOpt : public LibCallOptimization {
struct StrNCpyOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
@ -879,7 +878,7 @@ struct VISIBILITY_HIDDEN StrNCpyOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strlen' Optimizations
struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
struct StrLenOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 1 ||
@ -905,7 +904,7 @@ struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'strto*' Optimizations
struct VISIBILITY_HIDDEN StrToOpt : public LibCallOptimization {
struct StrToOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if ((FT->getNumParams() != 2 && FT->getNumParams() != 3) ||
@ -927,7 +926,7 @@ struct VISIBILITY_HIDDEN StrToOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'memcmp' Optimizations
struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
struct MemCmpOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || !isa<PointerType>(FT->getParamType(0)) ||
@ -974,7 +973,7 @@ struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'memcpy' Optimizations
struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization {
struct MemCpyOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// These optimizations require TargetData.
if (!TD) return 0;
@ -995,7 +994,7 @@ struct VISIBILITY_HIDDEN MemCpyOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'memmove' Optimizations
struct VISIBILITY_HIDDEN MemMoveOpt : public LibCallOptimization {
struct MemMoveOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// These optimizations require TargetData.
if (!TD) return 0;
@ -1025,7 +1024,7 @@ struct VISIBILITY_HIDDEN MemMoveOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'memset' Optimizations
struct VISIBILITY_HIDDEN MemSetOpt : public LibCallOptimization {
struct MemSetOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// These optimizations require TargetData.
if (!TD) return 0;
@ -1051,7 +1050,7 @@ struct VISIBILITY_HIDDEN MemSetOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'pow*' Optimizations
struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
struct PowOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// Just make sure this has 2 arguments of the same FP type, which match the
@ -1102,7 +1101,7 @@ struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'exp2' Optimizations
struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
struct Exp2Opt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// Just make sure this has 1 argument of FP type, which matches the
@ -1152,7 +1151,7 @@ struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
//===---------------------------------------===//
// Double -> Float Shrinking Optimizations for Unary Functions like 'floor'
struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
struct UnaryDoubleFPOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 1 || FT->getReturnType() != Type::getDoubleTy(*Context) ||
@ -1178,7 +1177,7 @@ struct VISIBILITY_HIDDEN UnaryDoubleFPOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'ffs*' Optimizations
struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
struct FFSOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// Just make sure this has 2 arguments of the same FP type, which match the
@ -1213,7 +1212,7 @@ struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'isdigit' Optimizations
struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization {
struct IsDigitOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
@ -1234,7 +1233,7 @@ struct VISIBILITY_HIDDEN IsDigitOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'isascii' Optimizations
struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization {
struct IsAsciiOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
@ -1253,7 +1252,7 @@ struct VISIBILITY_HIDDEN IsAsciiOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'abs', 'labs', 'llabs' Optimizations
struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization {
struct AbsOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// We require integer(integer) where the types agree.
@ -1275,7 +1274,7 @@ struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'toascii' Optimizations
struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization {
struct ToAsciiOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
// We require i32(i32)
@ -1296,7 +1295,7 @@ struct VISIBILITY_HIDDEN ToAsciiOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'printf' Optimizations
struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
struct PrintFOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Require one fixed pointer argument and an integer/void result.
const FunctionType *FT = Callee->getFunctionType();
@ -1359,7 +1358,7 @@ struct VISIBILITY_HIDDEN PrintFOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'sprintf' Optimizations
struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization {
struct SPrintFOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Require two fixed pointer arguments and an integer result.
const FunctionType *FT = Callee->getFunctionType();
@ -1431,7 +1430,7 @@ struct VISIBILITY_HIDDEN SPrintFOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'fwrite' Optimizations
struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization {
struct FWriteOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Require a pointer, an integer, an integer, a pointer, returning integer.
const FunctionType *FT = Callee->getFunctionType();
@ -1466,7 +1465,7 @@ struct VISIBILITY_HIDDEN FWriteOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'fputs' Optimizations
struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization {
struct FPutsOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// These optimizations require TargetData.
if (!TD) return 0;
@ -1491,7 +1490,7 @@ struct VISIBILITY_HIDDEN FPutsOpt : public LibCallOptimization {
//===---------------------------------------===//
// 'fprintf' Optimizations
struct VISIBILITY_HIDDEN FPrintFOpt : public LibCallOptimization {
struct FPrintFOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
// Require two fixed paramters as pointers and integer result.
const FunctionType *FT = Callee->getFunctionType();
@ -1553,7 +1552,7 @@ struct VISIBILITY_HIDDEN FPrintFOpt : public LibCallOptimization {
namespace {
/// This pass optimizes well known library functions from libc and libm.
///
class VISIBILITY_HIDDEN SimplifyLibCalls : public FunctionPass {
class SimplifyLibCalls : public FunctionPass {
StringMap<LibCallOptimization*> Optimizations;
// Miscellaneous LibCall Optimizations
ExitOpt Exit;

View File

@ -30,7 +30,6 @@
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/Statistic.h"
@ -46,7 +45,7 @@ TailDupThreshold("taildup-threshold",
cl::init(1), cl::Hidden);
namespace {
class VISIBILITY_HIDDEN TailDup : public FunctionPass {
class TailDup : public FunctionPass {
bool runOnFunction(Function &F);
public:
static char ID; // Pass identification, replacement for typeid

View File

@ -60,14 +60,13 @@
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
using namespace llvm;
STATISTIC(NumEliminated, "Number of tail calls removed");
STATISTIC(NumAccumAdded, "Number of accumulators introduced");
namespace {
struct VISIBILITY_HIDDEN TailCallElim : public FunctionPass {
struct TailCallElim : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
TailCallElim() : FunctionPass(&ID) {}