Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/AArch64/AArch64PreLegalizerCombiner.cpp
Line
Count
Source (jump to first uncovered line)
1
//=== lib/CodeGen/GlobalISel/AArch64PreLegalizerCombiner.cpp --------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This pass does combining of machine instructions at the generic MI level,
10
// before the legalizer.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "AArch64TargetMachine.h"
15
#include "llvm/CodeGen/GlobalISel/Combiner.h"
16
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
17
#include "llvm/CodeGen/GlobalISel/CombinerInfo.h"
18
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
19
#include "llvm/CodeGen/MachineFunctionPass.h"
20
#include "llvm/CodeGen/TargetPassConfig.h"
21
#include "llvm/Support/Debug.h"
22
23
#define DEBUG_TYPE "aarch64-prelegalizer-combiner"
24
25
using namespace llvm;
26
using namespace MIPatternMatch;
27
28
namespace {
29
class AArch64PreLegalizerCombinerInfo : public CombinerInfo {
30
public:
31
  AArch64PreLegalizerCombinerInfo()
32
      : CombinerInfo(/*AllowIllegalOps*/ true, /*ShouldLegalizeIllegal*/ false,
33
235k
                     /*LegalizerInfo*/ nullptr) {}
34
  virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
35
                       MachineIRBuilder &B) const override;
36
};
37
38
bool AArch64PreLegalizerCombinerInfo::combine(GISelChangeObserver &Observer,
39
                                              MachineInstr &MI,
40
41.4M
                                              MachineIRBuilder &B) const {
41
41.4M
  CombinerHelper Helper(Observer, B);
42
41.4M
43
41.4M
  switch (MI.getOpcode()) {
44
41.4M
  default:
45
29.0M
    return false;
46
41.4M
  case TargetOpcode::COPY:
47
8.65M
    return Helper.tryCombineCopy(MI);
48
41.4M
  case TargetOpcode::G_BR:
49
1.17M
    return Helper.tryCombineBr(MI);
50
41.4M
  case TargetOpcode::G_LOAD:
51
2.53M
  case TargetOpcode::G_SEXTLOAD:
52
2.53M
  case TargetOpcode::G_ZEXTLOAD:
53
2.53M
    return Helper.tryCombineExtendingLoads(MI);
54
0
  }
55
0
56
0
  return false;
57
0
}
58
59
// Pass boilerplate
60
// ================
61
62
class AArch64PreLegalizerCombiner : public MachineFunctionPass {
63
public:
64
  static char ID;
65
66
  AArch64PreLegalizerCombiner();
67
68
242k
  StringRef getPassName() const override { return "AArch64PreLegalizerCombiner"; }
69
70
  bool runOnMachineFunction(MachineFunction &MF) override;
71
72
  void getAnalysisUsage(AnalysisUsage &AU) const override;
73
};
74
}
75
76
6.75k
void AArch64PreLegalizerCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
77
6.75k
  AU.addRequired<TargetPassConfig>();
78
6.75k
  AU.setPreservesCFG();
79
6.75k
  getSelectionDAGFallbackAnalysisUsage(AU);
80
6.75k
  MachineFunctionPass::getAnalysisUsage(AU);
81
6.75k
}
82
83
6.79k
AArch64PreLegalizerCombiner::AArch64PreLegalizerCombiner() : MachineFunctionPass(ID) {
84
6.79k
  initializeAArch64PreLegalizerCombinerPass(*PassRegistry::getPassRegistry());
85
6.79k
}
86
87
235k
bool AArch64PreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) {
88
235k
  if (MF.getProperties().hasProperty(
89
235k
          MachineFunctionProperties::Property::FailedISel))
90
171
    return false;
91
235k
  auto *TPC = &getAnalysis<TargetPassConfig>();
92
235k
  AArch64PreLegalizerCombinerInfo PCInfo;
93
235k
  Combiner C(PCInfo, TPC);
94
235k
  return C.combineMachineInstrs(MF, /*CSEInfo*/ nullptr);
95
235k
}
96
97
char AArch64PreLegalizerCombiner::ID = 0;
98
101k
INITIALIZE_PASS_BEGIN(AArch64PreLegalizerCombiner, DEBUG_TYPE,
99
101k
                      "Combine AArch64 machine instrs before legalization",
100
101k
                      false, false)
101
101k
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
102
101k
INITIALIZE_PASS_END(AArch64PreLegalizerCombiner, DEBUG_TYPE,
103
                    "Combine AArch64 machine instrs before legalization", false,
104
                    false)
105
106
107
namespace llvm {
108
6.78k
FunctionPass *createAArch64PreLegalizeCombiner() {
109
6.78k
  return new AArch64PreLegalizerCombiner();
110
6.78k
}
111
} // end namespace llvm