LLVM: lib/Transforms/Scalar/Reg2Mem.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

33#include

34using namespace llvm;

35

36#define DEBUG_TYPE "reg2mem"

37

38STATISTIC(NumRegsDemoted, "Number of registers demoted");

39STATISTIC(NumPhisDemoted, "Number of phi-nodes demoted");

40

43 return false;

44

46 for (const User *U : Inst.users()) {

49 return true;

50 }

51 return false;

52}

53

55

58 "Entry block to function must not have predecessors!");

59

60

61

62

65

69

70

71

72 std::list<Instruction*> WorkList;

75 WorkList.push_front(&I);

76

77

78 NumRegsDemoted += WorkList.size();

81

82 WorkList.clear();

83

84

86 for (auto &Phi : BB.phis())

87 WorkList.push_front(&Phi);

88

89

90 NumPhisDemoted += WorkList.size();

93

94 return true;

95}

96

109

110namespace {

111

112class RegToMemWrapperPass : public FunctionPass {

113public:

114 static char ID;

115

117

118 void getAnalysisUsage(AnalysisUsage &AU) const override {

120

123

126 }

127

129 DominatorTree *DT = &getAnalysis().getDomTree();

130 LoopInfo *LI = &getAnalysis().getLoopInfo();

131

135 }

136};

137}

138

143

144char RegToMemWrapperPass::ID = 0;

145

147 return new RegToMemWrapperPass();

148}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

Expand Atomic instructions

static bool runOnFunction(Function &F, bool PostInlining)

This file provides various utilities for inspecting and working with the control flow graph in LLVM I...

This header defines various interfaces for pass management in LLVM.

static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))

#define INITIALIZE_PASS_DEPENDENCY(depName)

#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)

#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)

static bool valueEscapes(const Instruction &Inst)

Definition Reg2Mem.cpp:41

static bool runPass(Function &F)

Definition Reg2Mem.cpp:54

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...

#define STATISTIC(VARNAME, DESC)

PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)

Get the result of an analysis pass for a given IR unit.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

AnalysisUsage & addPreserved()

Add the specified Pass class to the set of analyses preserved by this pass.

void setPreservesAll()

Set by analyses that do not transform their input at all.

LLVM Basic Block Representation.

iterator begin()

Instruction iterator methods.

InstListType::iterator iterator

Instruction iterators...

This class represents a no-op cast from one type to another.

This is the base class for all instructions that perform data casts.

static LLVM_ABI Constant * getNullValue(Type *Ty)

Constructor to create a '0' constant of arbitrary type.

Analysis pass which computes a DominatorTree.

Legacy analysis pass which computes a DominatorTree.

FunctionPass class - This class is used to implement most global optimizations.

Analysis pass that exposes the LoopInfo for a function.

The legacy pass manager's analysis pass to compute loop information.

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

PreservedAnalyses & preserve()

Mark an analysis as preserved.

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

Definition Reg2Mem.cpp:97

static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)

bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const

Return true if it makes sense to take the size of this type.

Type * getType() const

All values are typed, get the type of this value.

iterator_range< user_iterator > users()

const ParentTy * getParent() const

self_iterator getIterator()

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI FunctionPass * createRegToMemWrapperPass()

Definition Reg2Mem.cpp:146

LLVM_ABI AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, std::optional< BasicBlock::iterator > AllocaPoint=std::nullopt)

This function takes a virtual register computed by an Instruction and replaces it with a slot in the ...

LLVM_ABI AllocaInst * DemotePHIToStack(PHINode *P, std::optional< BasicBlock::iterator > AllocaPoint=std::nullopt)

This function takes a virtual register computed by a phi node and replaces it with a slot in the stac...

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

bool pred_empty(const BasicBlock *BB)

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

Option class for critical edge splitting.