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

1

2

3

4

5

6

7

8

9

10

11

12

13

19using namespace llvm;

20

21#define DEBUG_TYPE "wasm-optimize-returned"

22

23namespace {

24class OptimizeReturned final : public FunctionPass,

26 StringRef getPassName() const override {

27 return "WebAssembly Optimize Returned";

28 }

29

30 void getAnalysisUsage(AnalysisUsage &AU) const override {

35 }

36

38

40

41public:

42 static char ID;

44

45 void visitCallBase(CallBase &CB);

46};

47}

48

49char OptimizeReturned::ID = 0;

51 "Optimize calls with \"returned\" attributes for WebAssembly",

52 false, false)

53

55 return new OptimizeReturned();

56}

57

58void OptimizeReturned::visitCallBase(CallBase &CB) {

59 for (unsigned I = 0, E = CB.arg_size(); I < E; ++I)

62

64 continue;

65

68 return I->isLifetimeStartOrEnd() && DT->dominates(&CB, U);

69 });

70 }

71}

72

73bool OptimizeReturned::runOnFunction(Function &F) {

74 LLVM_DEBUG(dbgs() << "********** Optimize returned Attributes **********\n"

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

76 << F.getName() << '\n');

77

78 DT = &getAnalysis().getDomTree();

80 return true;

81}

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

static bool runOnFunction(Function &F, bool PostInlining)

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

void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> op)

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 & 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:

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const

Determine whether the argument or parameter has the given attribute.

Value * getArgOperand(unsigned i) const

unsigned arg_size() const

Legacy analysis pass which computes a DominatorTree.

Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.

LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const

Return true if the (end of the) basic block BB dominates the use U.

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

Base class for instruction visitors.

virtual void getAnalysisUsage(AnalysisUsage &) const

getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...

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

LLVM_ABI void replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)

Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...

unsigned ID

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

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr Value

LLVM_ABI raw_ostream & dbgs()

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

FunctionPass * createWebAssemblyOptimizeReturned()

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.