LLVM: lib/Target/BPF/BPFIRPeephole.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

22

23#define DEBUG_TYPE "bpf-ir-peephole"

24

25using namespace llvm;

26

27namespace {

28

29static bool BPFIRPeepholeImpl(Function &F) {

30 LLVM_DEBUG(dbgs() << "******** BPF IR Peephole ********\n");

31

34 for (auto &BB : F) {

35 for (auto &I : BB) {

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53 if (ToErase) {

55 ToErase = nullptr;

56 }

57

59 if (II->getIntrinsicID() != Intrinsic::stacksave)

60 continue;

61 if (II->hasOneUser())

62 continue;

67 Inst->eraseFromParent();

68 ToErase = &I;

69 continue;

70 }

71

73 if (!LD->hasOneUser())

74 continue;

76 if (II)

77 continue;

78 if (II->getIntrinsicID() != Intrinsic::stackrestore)

79 continue;

83 II->eraseFromParent();

84 ToErase = &I;

85 }

86 }

87 }

88

90}

91}

92

This header defines various interfaces for pass management in LLVM.

uint64_t IntrinsicInst * II

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)

Definition BPFIRPeephole.cpp:93

LLVM_ABI InstListType::iterator eraseFromParent()

This method unlinks 'this' from the containing basic block and deletes it.

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

static PreservedAnalyses none()

Convenience factory function for the empty preserved set.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

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

LLVM_ABI raw_ostream & dbgs()

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

decltype(auto) cast(const From &Val)

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

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.