LLVM: lib/Target/ARM/ARMOptimizeBarriersPass.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

14using namespace llvm;

15

16#define DEBUG_TYPE "double barriers"

17

18STATISTIC(NumDMBsRemoved, "Number of DMBs removed");

19

20namespace {

22public:

23 static char ID;

25

26 bool runOnMachineFunction(MachineFunction &Fn) override;

27

28 MachineFunctionProperties getRequiredProperties() const override {

29 return MachineFunctionProperties().setNoVRegs();

30 }

31

32 StringRef getPassName() const override { return "optimise barriers pass"; }

33};

34char ARMOptimizeBarriersPass::ID = 0;

35}

36

37

38

39

41 return !(MI->mayLoad() ||

42 MI->mayStore() ||

43 MI->hasUnmodeledSideEffects() ||

44 MI->isCall() ||

45 MI->isReturn());

46}

47

48bool ARMOptimizeBarriersPass::runOnMachineFunction(MachineFunction &MF) {

50 return false;

51

52

53 std::vector<MachineInstr *> ToRemove;

54

55

56 int64_t DMBType = -1;

57

58

59

60 for (auto &MBB : MF) {

61

62

63 bool IsRemovableNextDMB = false;

64 for (auto &MI : MBB) {

65 if (MI.getOpcode() == ARM::DMB) {

66 if (IsRemovableNextDMB) {

67

68

69 if (MI.getOperand(0).getImm() == DMBType) {

71 } else {

72

73

74 DMBType = MI.getOperand(0).getImm();

75 }

76 } else {

77

78 IsRemovableNextDMB = true;

79 DMBType = MI.getOperand(0).getImm();

80 }

82

83

84 IsRemovableNextDMB = false;

85 }

86 }

87 }

89

91 MI->eraseFromParent();

92 ++NumDMBsRemoved;

94 }

95

97}

98

99

100

101

103 return new ARMOptimizeBarriersPass();

104}

ReachingDefInfo InstSet & ToRemove

static bool CanMovePastDMB(const MachineInstr *MI)

Definition ARMOptimizeBarriersPass.cpp:40

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

#define STATISTIC(VARNAME, DESC)

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

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

Function & getFunction()

Return the LLVM function that this machine code represents.

Representation of each machine instruction.

unsigned ID

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

This is an optimization pass for GlobalISel generic memory operations.

FunctionPass * createARMOptimizeBarriersPass()

createARMOptimizeBarriersPass - Returns an instance of the remove double barriers pass.

Definition ARMOptimizeBarriersPass.cpp:102