Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.cpp
Line
Count
Source
1
//===-- SIFixVGPRCopies.cpp - Fix VGPR Copies after regalloc --------------===//
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
/// \file
10
/// Add implicit use of exec to vector register copies.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#include "AMDGPU.h"
15
#include "AMDGPUSubtarget.h"
16
#include "SIInstrInfo.h"
17
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
18
#include "llvm/CodeGen/MachineFunctionPass.h"
19
20
using namespace llvm;
21
22
#define DEBUG_TYPE "si-fix-vgpr-copies"
23
24
namespace {
25
26
class SIFixVGPRCopies : public MachineFunctionPass {
27
public:
28
  static char ID;
29
30
public:
31
2.44k
  SIFixVGPRCopies() : MachineFunctionPass(ID) {
32
2.44k
    initializeSIFixVGPRCopiesPass(*PassRegistry::getPassRegistry());
33
2.44k
  }
34
35
  bool runOnMachineFunction(MachineFunction &MF) override;
36
37
27.8k
  StringRef getPassName() const override { return "SI Fix VGPR copies"; }
38
};
39
40
} // End anonymous namespace.
41
42
INITIALIZE_PASS(SIFixVGPRCopies, DEBUG_TYPE, "SI Fix VGPR copies", false, false)
43
44
char SIFixVGPRCopies::ID = 0;
45
46
char &llvm::SIFixVGPRCopiesID = SIFixVGPRCopies::ID;
47
48
25.4k
bool SIFixVGPRCopies::runOnMachineFunction(MachineFunction &MF) {
49
25.4k
  const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
50
25.4k
  const SIRegisterInfo *TRI = ST.getRegisterInfo();
51
25.4k
  const SIInstrInfo *TII = ST.getInstrInfo();
52
25.4k
  bool Changed = false;
53
25.4k
54
29.1k
  for (MachineBasicBlock &MBB : MF) {
55
355k
    for (MachineInstr &MI : MBB) {
56
355k
      switch (MI.getOpcode()) {
57
355k
      case AMDGPU::COPY:
58
67.2k
        if (TII->isVGPRCopy(MI) && 
!MI.readsRegister(AMDGPU::EXEC, TRI)46.1k
) {
59
46.1k
          MI.addOperand(MF,
60
46.1k
                        MachineOperand::CreateReg(AMDGPU::EXEC, false, true));
61
46.1k
          LLVM_DEBUG(dbgs() << "Add exec use to " << MI);
62
46.1k
          Changed = true;
63
46.1k
        }
64
67.2k
        break;
65
355k
      default:
66
288k
        break;
67
355k
      }
68
355k
    }
69
29.1k
  }
70
25.4k
71
25.4k
  return Changed;
72
25.4k
}