12
12
// ===----------------------------------------------------------------------===//
13
13
14
14
#include " SPIRVDuplicatesTracker.h"
15
+ #include " SPIRVInstrInfo.h"
15
16
16
17
#define DEBUG_TYPE " build-dep-graph"
17
18
18
19
using namespace llvm ;
19
20
20
21
template <typename T>
21
22
void SPIRVGeneralDuplicatesTracker::prebuildReg2Entry (
22
- SPIRVDuplicatesTracker<T> &DT, SPIRVReg2EntryTy &Reg2Entry) {
23
+ SPIRVDuplicatesTracker<T> &DT, SPIRVReg2EntryTy &Reg2Entry,
24
+ const SPIRVInstrInfo *TII) {
23
25
for (auto &TPair : DT.getAllUses ()) {
24
26
for (auto &RegPair : TPair.second ) {
25
27
const MachineFunction *MF = RegPair.first ;
26
28
Register R = RegPair.second ;
27
29
MachineInstr *MI = MF->getRegInfo ().getUniqueVRegDef (R);
28
- if (!MI)
30
+ if (!MI || (TPair. second . getIsConst () && !TII-> isConstantInstr (*MI)) )
29
31
continue ;
30
32
Reg2Entry[&MI->getOperand (0 )] = &TPair.second ;
31
33
}
32
34
}
33
35
}
34
36
35
37
void SPIRVGeneralDuplicatesTracker::buildDepsGraph (
36
- std::vector<SPIRV::DTSortableEntry *> &Graph,
38
+ std::vector<SPIRV::DTSortableEntry *> &Graph, const SPIRVInstrInfo *TII,
37
39
MachineModuleInfo *MMI = nullptr ) {
38
40
SPIRVReg2EntryTy Reg2Entry;
39
- prebuildReg2Entry (TT, Reg2Entry);
40
- prebuildReg2Entry (CT, Reg2Entry);
41
- prebuildReg2Entry (GT, Reg2Entry);
42
- prebuildReg2Entry (FT, Reg2Entry);
43
- prebuildReg2Entry (AT, Reg2Entry);
44
- prebuildReg2Entry (MT, Reg2Entry);
45
- prebuildReg2Entry (ST, Reg2Entry);
41
+ prebuildReg2Entry (TT, Reg2Entry, TII );
42
+ prebuildReg2Entry (CT, Reg2Entry, TII );
43
+ prebuildReg2Entry (GT, Reg2Entry, TII );
44
+ prebuildReg2Entry (FT, Reg2Entry, TII );
45
+ prebuildReg2Entry (AT, Reg2Entry, TII );
46
+ prebuildReg2Entry (MT, Reg2Entry, TII );
47
+ prebuildReg2Entry (ST, Reg2Entry, TII );
46
48
47
49
for (auto &Op2E : Reg2Entry) {
48
50
SPIRV::DTSortableEntry *E = Op2E.second ;
@@ -65,20 +67,19 @@ void SPIRVGeneralDuplicatesTracker::buildDepsGraph(
65
67
if (MI->getOpcode () == SPIRV::OpConstantFunctionPointerINTEL && i == 2 )
66
68
continue ;
67
69
MachineOperand *RegOp = &VRegDef->getOperand (0 );
68
- LLVM_DEBUG ({
69
- if (Reg2Entry.count (RegOp) == 0 &&
70
- (MI->getOpcode () != SPIRV::OpVariable || i != 3 )) {
71
- dbgs () << " Unexpected pattern while building a dependency "
72
- " graph.\n Instruction: " ;
73
- MI->print (dbgs ());
74
- dbgs () << " Operand: " ;
75
- Op.print (dbgs ());
76
- dbgs () << " \n Operand definition: " ;
77
- VRegDef->print (dbgs ());
78
- }
79
- });
80
- assert ((MI->getOpcode () == SPIRV::OpVariable && i == 3 ) ||
81
- Reg2Entry.count (RegOp));
70
+ if (Reg2Entry.count (RegOp) == 0 &&
71
+ (MI->getOpcode () != SPIRV::OpVariable || i != 3 )) {
72
+ std::string DiagMsg;
73
+ raw_string_ostream OS (DiagMsg);
74
+ OS << " Unexpected pattern while building a dependency "
75
+ " graph.\n Instruction: " ;
76
+ MI->print (OS);
77
+ OS << " Operand: " ;
78
+ Op.print (OS);
79
+ OS << " \n Operand definition: " ;
80
+ VRegDef->print (OS);
81
+ report_fatal_error (DiagMsg.c_str ());
82
+ }
82
83
if (Reg2Entry.count (RegOp))
83
84
E->addDep (Reg2Entry[RegOp]);
84
85
}
0 commit comments