LLVM: lib/Target/WebAssembly/WebAssemblyOptimizeLiveIntervals.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

31using namespace llvm;

32

33#define DEBUG_TYPE "wasm-optimize-live-intervals"

34

35namespace {

36class WebAssemblyOptimizeLiveIntervals final : public MachineFunctionPass {

37 StringRef getPassName() const override {

38 return "WebAssembly Optimize Live Intervals";

39 }

40

41 void getAnalysisUsage(AnalysisUsage &AU) const override {

50 }

51

54 }

55

57

58public:

59 static char ID;

61};

62}

63

64char WebAssemblyOptimizeLiveIntervals::ID = 0;

66 "Optimize LiveIntervals for WebAssembly", false, false)

67

69 return new WebAssemblyOptimizeLiveIntervals();

70}

71

72bool WebAssemblyOptimizeLiveIntervals::runOnMachineFunction(

74 LLVM_DEBUG(dbgs() << "********** Optimize LiveIntervals **********\n"

75 "********** Function: "

77

79 auto &LIS = getAnalysis().getLIS();

80

81

82 MRI.leaveSSA();

83

84 assert(MRI.tracksLiveness() && "OptimizeLiveIntervals expects liveness");

85

86

88 for (unsigned I = 0, E = MRI.getNumVirtRegs(); I < E; ++I) {

90 auto &TRI = *MF.getSubtarget().getRegisterInfo();

91

92 if (MRI.reg_nodbg_empty(Reg))

93 continue;

94

95 LIS.splitSeparateComponents(LIS.getInterval(Reg), SplitLIs);

96 if (Reg == TRI.getFrameRegister(MF) && SplitLIs.size() > 0) {

97

98

99

100

101

102

103 MF.getInfo()->setFrameBaseVreg(

104 SplitLIs.back()->reg());

105 }

106 SplitLIs.clear();

107 }

108

109

110

111

112

114 if (MI.isImplicitDef() && MI.getOperand(0).isDead()) {

115 LiveInterval &LI = LIS.getInterval(MI.getOperand(0).getReg());

116 LIS.removeVRegDefAt(LI, LIS.getInstructionIndex(MI).getRegSlot());

117 LIS.RemoveMachineInstrFromMaps(MI);

118 MI.eraseFromParent();

119 }

120 }

121

122 return true;

123}

unsigned const MachineRegisterInfo * MRI

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

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

Register const TargetRegisterInfo * TRI

Promote Memory to Register

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

This file declares WebAssembly-specific per-machine-function information.

This file declares the WebAssembly-specific subclass of TargetSubtarget.

This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.

Represent the analysis usage information of a pass.

AnalysisUsage & addPreservedID(const void *ID)

AnalysisUsage & addRequired()

AnalysisUsage & addPreserved()

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

LLVM_ABI void setPreservesCFG()

This function should be called by the pass, iff they do not:

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

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

Properties which a MachineFunction may have at a given point in time.

const TargetSubtargetInfo & getSubtarget() const

getSubtarget - Return the subtarget for which this machine code is being compiled.

StringRef getName() const

getName - Return the name of the corresponding LLVM function.

MachineRegisterInfo & getRegInfo()

getRegInfo - Return information about the registers currently in use.

Ty * getInfo()

getInfo - Keep track of various per-function pieces of information for backends that would like to do...

const MachineBasicBlock & front() const

StringRef - Represent a constant reference to a string, i.e.

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 char & MachineDominatorsID

MachineDominators - This pass is a machine dominators analysis pass.

iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)

Make a range that does early increment to allow mutation of the underlying range without disrupting i...

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

FunctionPass * createWebAssemblyOptimizeLiveIntervals()

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

LLVM_ABI char & LiveVariablesID

LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...