LLVM  3.7.0
SIFixControlFlowLiveIntervals.cpp
Go to the documentation of this file.
1 //===-- SIFixControlFlowLiveIntervals.cpp - Fix CF live intervals ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// \brief Spilling of EXEC masks used for control flow messes up control flow
12 /// lowering, so mark all live intervals associated with CF instructions as
13 /// non-spillable.
14 ///
15 //===----------------------------------------------------------------------===//
16 
17 #include "AMDGPU.h"
18 #include "SIInstrInfo.h"
19 #include "SIRegisterInfo.h"
25 #include "llvm/Support/Debug.h"
28 
29 using namespace llvm;
30 
31 #define DEBUG_TYPE "si-fix-cf-live-intervals"
32 
33 namespace {
34 
35 class SIFixControlFlowLiveIntervals : public MachineFunctionPass {
36 public:
37  static char ID;
38 
39 public:
40  SIFixControlFlowLiveIntervals() : MachineFunctionPass(ID) {
42  }
43 
44  bool runOnMachineFunction(MachineFunction &MF) override;
45 
46  const char *getPassName() const override {
47  return "SI Fix CF Live Intervals";
48  }
49 
50  void getAnalysisUsage(AnalysisUsage &AU) const override {
52  AU.setPreservesAll();
54  }
55 };
56 
57 } // End anonymous namespace.
58 
59 INITIALIZE_PASS_BEGIN(SIFixControlFlowLiveIntervals, DEBUG_TYPE,
60  "SI Fix CF Live Intervals", false, false)
62 INITIALIZE_PASS_END(SIFixControlFlowLiveIntervals, DEBUG_TYPE,
63  "SI Fix CF Live Intervals", false, false)
64 
65 char SIFixControlFlowLiveIntervals::ID = 0;
66 
67 char &llvm::SIFixControlFlowLiveIntervalsID = SIFixControlFlowLiveIntervals::ID;
68 
70  return new SIFixControlFlowLiveIntervals();
71 }
72 
73 bool SIFixControlFlowLiveIntervals::runOnMachineFunction(MachineFunction &MF) {
74  LiveIntervals *LIS = &getAnalysis<LiveIntervals>();
75 
76  for (const MachineBasicBlock &MBB : MF) {
77  for (const MachineInstr &MI : MBB) {
78  switch (MI.getOpcode()) {
79  case AMDGPU::SI_IF:
80  case AMDGPU::SI_ELSE:
81  case AMDGPU::SI_BREAK:
82  case AMDGPU::SI_IF_BREAK:
83  case AMDGPU::SI_ELSE_BREAK:
84  case AMDGPU::SI_END_CF: {
85  unsigned Reg = MI.getOperand(0).getReg();
86  LIS->getInterval(Reg).markNotSpillable();
87  break;
88  }
89  default:
90  break;
91  }
92  }
93  }
94 
95  return false;
96 }
Interface definition for SIRegisterInfo.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:70
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:75
Reg
All possible values of the reg field in the ModR/M byte.
char & SIFixControlFlowLiveIntervalsID
SI Fix CF Live false
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
INITIALIZE_PASS_BEGIN(SIFixControlFlowLiveIntervals, DEBUG_TYPE,"SI Fix CF Live Intervals", false, false) INITIALIZE_PASS_END(SIFixControlFlowLiveIntervals
SI Fix CF Live Intervals
void markNotSpillable()
markNotSpillable - Mark interval as not spillable
Definition: LiveInterval.h:721
LiveInterval & getInterval(unsigned Reg)
void setPreservesAll()
Set by analyses that do not transform their input at all.
Representation of each machine instruction.
Definition: MachineInstr.h:51
Interface definition for SIInstrInfo.
void initializeSIFixControlFlowLiveIntervalsPass(PassRegistry &)
FunctionPass * createSIFixControlFlowLiveIntervalsPass()