Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 6af1d8f

Browse files
author
Krzysztof Parzyszek
committed
Reset the TopRPTracker's position in ScheduleDAGMILive::initQueues
ScheduleDAGMI::initQueues changes the RegionBegin to the first non-debug instruction. Since it does not track register pressure, it does not affect any RP trackers. ScheduleDAGMILive inherits initQueues from ScheduleDAGMI, and it does reset the TopTPTracker in its schedule method. Any derived, target-specific scheduler will need to do it as well, but the TopRPTracker is only exposed as a "const" object to derived classes. Without the ability to modify the tracker directly, this leaves a derived scheduler with a potential of having the TopRPTracker out-of-sync with the CurrentTop. The symptom of the problem: void llvm::ScheduleDAGMILive::scheduleMI(llvm::SUnit *, bool): Assertion `TopRPTracker.getPos() == CurrentTop && "out of sync"' failed. Differential Revision: http://reviews.llvm.org/D19438 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267918 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3ba7927 commit 6af1d8f

File tree

3 files changed

+166
-5
lines changed

3 files changed

+166
-5
lines changed

include/llvm/CodeGen/MachineScheduler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ class ScheduleDAGMILive : public ScheduleDAGMI {
461461
/// bottom of the DAG region without covereing any unscheduled instruction.
462462
void buildDAGWithRegPressure();
463463

464+
/// Release ExitSU predecessors and setup scheduler queues. Re-position
465+
/// the Top RP tracker in case the region beginning has changed.
466+
void initQueues(ArrayRef<SUnit*> TopRoots, ArrayRef<SUnit*> BotRoots);
467+
464468
/// Move an instruction and update register pressure.
465469
void scheduleMI(SUnit *SU, bool IsTopNode);
466470

lib/CodeGen/MachineScheduler.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,6 @@ void ScheduleDAGMILive::schedule() {
11131113
// Initialize ready queues now that the DAG and priority data are finalized.
11141114
initQueues(TopRoots, BotRoots);
11151115

1116-
if (ShouldTrackPressure) {
1117-
assert(TopRPTracker.getPos() == RegionBegin && "bad initial Top tracker");
1118-
TopRPTracker.setPos(CurrentTop);
1119-
}
1120-
11211116
bool IsTopNode = false;
11221117
while (true) {
11231118
DEBUG(dbgs() << "** ScheduleDAGMILive::schedule picking next node\n");
@@ -1275,6 +1270,17 @@ unsigned ScheduleDAGMILive::computeCyclicCriticalPath() {
12751270
return MaxCyclicLatency;
12761271
}
12771272

1273+
/// Release ExitSU predecessors and setup scheduler queues. Re-position
1274+
/// the Top RP tracker in case the region beginning has changed.
1275+
void ScheduleDAGMILive::initQueues(ArrayRef<SUnit*> TopRoots,
1276+
ArrayRef<SUnit*> BotRoots) {
1277+
ScheduleDAGMI::initQueues(TopRoots, BotRoots);
1278+
if (ShouldTrackPressure) {
1279+
assert(TopRPTracker.getPos() == RegionBegin && "bad initial Top tracker");
1280+
TopRPTracker.setPos(CurrentTop);
1281+
}
1282+
}
1283+
12781284
/// Move an instruction and update register pressure.
12791285
void ScheduleDAGMILive::scheduleMI(SUnit *SU, bool IsTopNode) {
12801286
// Move the instruction to its new location in the instruction stream.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
; RUN: llc -march=hexagon < %s
2+
; REQUIRES: asserts
3+
4+
; Check that we no longer get this error:
5+
; void llvm::ScheduleDAGMILive::scheduleMI(llvm::SUnit *, bool):
6+
; Assertion `TopRPTracker.getPos() == CurrentTop && "out of sync"' failed.
7+
8+
target triple = "hexagon"
9+
10+
%struct.A = type { %struct.B*, %struct.B* }
11+
%struct.B = type { i8*, %struct.B*, %struct.B* }
12+
13+
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
14+
@__func__.fred = external hidden unnamed_addr constant [16 x i8], align 1
15+
@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
16+
17+
; Function Attrs: nounwind
18+
declare void @_Assert(i8*, i8*) #0
19+
20+
; Function Attrs: nounwind
21+
define void @fred(%struct.A* %pA, %struct.B* %p) #0 !dbg !6 {
22+
entry:
23+
tail call void @llvm.dbg.value(metadata %struct.A* %pA, i64 0, metadata !26, metadata !28), !dbg !29
24+
tail call void @llvm.dbg.value(metadata %struct.B* %p, i64 0, metadata !27, metadata !28), !dbg !30
25+
%cmp = icmp eq %struct.B* %p, null, !dbg !31
26+
br i1 %cmp, label %cond.false, label %cond.end, !dbg !31
27+
28+
cond.false: ; preds = %entry
29+
tail call void @_Assert(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.fred, i32 0, i32 0)) #0, !dbg !32
30+
br label %cond.end, !dbg !32
31+
32+
cond.end: ; preds = %cond.false, %entry
33+
%cmp1 = icmp eq %struct.A* %pA, null, !dbg !34
34+
br i1 %cmp1, label %cond.false3, label %cond.end4, !dbg !34
35+
36+
cond.false3: ; preds = %cond.end
37+
tail call void @_Assert(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.fred, i32 0, i32 0)) #0, !dbg !35
38+
br label %cond.end4, !dbg !35
39+
40+
cond.end4: ; preds = %cond.false3, %cond.end
41+
%p2 = getelementptr inbounds %struct.A, %struct.A* %pA, i32 0, i32 0, !dbg !36
42+
%0 = load %struct.B*, %struct.B** %p2, align 4, !dbg !38, !tbaa !39
43+
%cmp5 = icmp eq %struct.B* %0, null, !dbg !44
44+
br i1 %cmp5, label %if.then, label %if.end, !dbg !45
45+
46+
if.then: ; preds = %cond.end4
47+
%p1 = getelementptr inbounds %struct.A, %struct.A* %pA, i32 0, i32 1, !dbg !46
48+
store %struct.B* %p, %struct.B** %p1, align 4, !dbg !48, !tbaa !49
49+
store %struct.B* %p, %struct.B** %p2, align 4, !dbg !50, !tbaa !39
50+
%p4 = getelementptr inbounds %struct.B, %struct.B* %p, i32 0, i32 1, !dbg !51
51+
store %struct.B* null, %struct.B** %p4, align 4, !dbg !52, !tbaa !53
52+
%p5 = getelementptr inbounds %struct.B, %struct.B* %p, i32 0, i32 2, !dbg !55
53+
store %struct.B* null, %struct.B** %p5, align 4, !dbg !56, !tbaa !57
54+
br label %return, !dbg !58
55+
56+
if.end: ; preds = %cond.end4
57+
%1 = ptrtoint %struct.B* %0 to i32, !dbg !59
58+
%p57 = getelementptr inbounds %struct.B, %struct.B* %p, i32 0, i32 2, !dbg !60
59+
store %struct.B* null, %struct.B** %p57, align 4, !dbg !61, !tbaa !57
60+
%p49 = getelementptr inbounds %struct.B, %struct.B* %p, i32 0, i32 1, !dbg !62
61+
%2 = bitcast %struct.B** %p49 to i32*, !dbg !63
62+
store i32 %1, i32* %2, align 4, !dbg !63, !tbaa !53
63+
%p511 = getelementptr inbounds %struct.B, %struct.B* %0, i32 0, i32 2, !dbg !64
64+
store %struct.B* %p, %struct.B** %p511, align 4, !dbg !65, !tbaa !57
65+
store %struct.B* %p, %struct.B** %p2, align 4, !dbg !66, !tbaa !39
66+
br label %return, !dbg !67
67+
68+
return: ; preds = %if.end, %if.then
69+
ret void, !dbg !68
70+
}
71+
72+
; Function Attrs: nounwind readnone
73+
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
74+
75+
attributes #0 = { nounwind }
76+
attributes #1 = { nounwind readnone }
77+
78+
!llvm.dbg.cu = !{!0}
79+
!llvm.module.flags = !{!3, !4}
80+
!llvm.ident = !{!5}
81+
82+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (http://llvm.org/git/clang.git 4b380bc1db8b0c72bdbdaf0e4697b1a84100a369) (http://llvm.org/git/llvm.git 6217a62bc009d55e160dbb694f2e94a22c80809f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
83+
!1 = !DIFile(filename: "bug.c", directory: "/")
84+
!2 = !{}
85+
!3 = !{i32 2, !"Dwarf Version", i32 4}
86+
!4 = !{i32 2, !"Debug Info Version", i32 3}
87+
!5 = !{!"clang version 3.9.0 (http://llvm.org/git/clang.git 4b380bc1db8b0c72bdbdaf0e4697b1a84100a369) (http://llvm.org/git/llvm.git 6217a62bc009d55e160dbb694f2e94a22c80809f)"}
88+
!6 = distinct !DISubprogram(name: "fred", scope: !1, file: !1, line: 138, type: !7, isLocal: false, isDefinition: true, scopeLine: 139, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !25)
89+
!7 = !DISubroutineType(types: !8)
90+
!8 = !{null, !9, !15}
91+
!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, align: 32)
92+
!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "A", file: !11, line: 57, baseType: !12)
93+
!11 = !DIFile(filename: "bug.h", directory: "/")
94+
!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !11, line: 54, size: 64, align: 32, elements: !13)
95+
!13 = !{!14, !24}
96+
!14 = !DIDerivedType(tag: DW_TAG_member, name: "p2", scope: !12, file: !11, line: 55, baseType: !15, size: 32, align: 32)
97+
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 32, align: 32)
98+
!16 = !DIDerivedType(tag: DW_TAG_typedef, name: "B", file: !11, line: 50, baseType: !17)
99+
!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !11, line: 45, size: 96, align: 32, elements: !18)
100+
!18 = !{!19, !21, !23}
101+
!19 = !DIDerivedType(tag: DW_TAG_member, name: "p3", scope: !17, file: !11, line: 47, baseType: !20, size: 32, align: 32)
102+
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 32, align: 32)
103+
!21 = !DIDerivedType(tag: DW_TAG_member, name: "p4", scope: !17, file: !11, line: 48, baseType: !22, size: 32, align: 32, offset: 32)
104+
!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 32, align: 32)
105+
!23 = !DIDerivedType(tag: DW_TAG_member, name: "p5", scope: !17, file: !11, line: 49, baseType: !22, size: 32, align: 32, offset: 64)
106+
!24 = !DIDerivedType(tag: DW_TAG_member, name: "p1", scope: !12, file: !11, line: 56, baseType: !15, size: 32, align: 32, offset: 32)
107+
!25 = !{!26, !27}
108+
!26 = !DILocalVariable(name: "pA", arg: 1, scope: !6, file: !1, line: 138, type: !9)
109+
!27 = !DILocalVariable(name: "p", arg: 2, scope: !6, file: !1, line: 138, type: !15)
110+
!28 = !DIExpression()
111+
!29 = !DILocation(line: 138, column: 34, scope: !6)
112+
!30 = !DILocation(line: 138, column: 57, scope: !6)
113+
!31 = !DILocation(line: 140, column: 5, scope: !6)
114+
!32 = !DILocation(line: 140, column: 5, scope: !33)
115+
!33 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 2)
116+
!34 = !DILocation(line: 141, column: 5, scope: !6)
117+
!35 = !DILocation(line: 141, column: 5, scope: !33)
118+
!36 = !DILocation(line: 143, column: 30, scope: !37)
119+
!37 = distinct !DILexicalBlock(scope: !6, file: !1, line: 143, column: 9)
120+
!38 = !DILocation(line: 155, column: 18, scope: !6)
121+
!39 = !{!40, !41, i64 0}
122+
!40 = !{!"", !41, i64 0, !41, i64 4}
123+
!41 = !{!"any pointer", !42, i64 0}
124+
!42 = !{!"omnipotent char", !43, i64 0}
125+
!43 = !{!"Simple C/C++ TBAA"}
126+
!44 = !DILocation(line: 143, column: 14, scope: !37)
127+
!45 = !DILocation(line: 143, column: 9, scope: !6)
128+
!46 = !DILocation(line: 146, column: 26, scope: !47)
129+
!47 = distinct !DILexicalBlock(scope: !37, file: !1, line: 143, column: 41)
130+
!48 = !DILocation(line: 146, column: 36, scope: !47)
131+
!49 = !{!40, !41, i64 4}
132+
!50 = !DILocation(line: 145, column: 32, scope: !47)
133+
!51 = !DILocation(line: 147, column: 20, scope: !47)
134+
!52 = !DILocation(line: 147, column: 29, scope: !47)
135+
!53 = !{!54, !41, i64 4}
136+
!54 = !{!"B", !41, i64 0, !41, i64 4, !41, i64 8}
137+
!55 = !DILocation(line: 148, column: 20, scope: !47)
138+
!56 = !DILocation(line: 148, column: 29, scope: !47)
139+
!57 = !{!54, !41, i64 8}
140+
!58 = !DILocation(line: 149, column: 9, scope: !47)
141+
!59 = !DILocation(line: 154, column: 41, scope: !6)
142+
!60 = !DILocation(line: 153, column: 16, scope: !6)
143+
!61 = !DILocation(line: 153, column: 25, scope: !6)
144+
!62 = !DILocation(line: 154, column: 16, scope: !6)
145+
!63 = !DILocation(line: 154, column: 26, scope: !6)
146+
!64 = !DILocation(line: 155, column: 29, scope: !6)
147+
!65 = !DILocation(line: 155, column: 39, scope: !6)
148+
!66 = !DILocation(line: 156, column: 28, scope: !6)
149+
!67 = !DILocation(line: 157, column: 1, scope: !6)
150+
!68 = !DILocation(line: 157, column: 1, scope: !69)
151+
!69 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 1)

0 commit comments

Comments
 (0)