llvm.org GIT mirror llvm / 6bb5006
Fix nondeterminism introduced in r353954 DenseMap iteration order is not guaranteed, use MapVector instead. Fix provided by srhines. Differential Revision: https://reviews.llvm.org/D59807 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356988 91177308-0d34-0410-b5e6-96231b3b80d8 Yi Kong 1 year, 8 months ago
3 changed file(s) with 52 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
13491349 void SelectionDAGBuilder::resolveOrClearDbgInfo() {
13501350 // Try to fixup any remaining dangling debug info -- and drop it if we can't.
13511351 for (auto &Pair : DanglingDebugInfoMap)
1352 for (auto &DDI : Pair.getSecond())
1352 for (auto &DDI : Pair.second)
13531353 salvageUnresolvedDbgValue(DDI);
13541354 clearDanglingDebugInfo();
13551355 }
1616 #include "llvm/ADT/APInt.h"
1717 #include "llvm/ADT/ArrayRef.h"
1818 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/MapVector.h"
1920 #include "llvm/ADT/SmallVector.h"
2021 #include "llvm/Analysis/AliasAnalysis.h"
2122 #include "llvm/CodeGen/ISDOpcodes.h"
120121
121122 /// Keeps track of dbg_values for which we have not yet seen the referent.
122123 /// We defer handling these until we do see it.
123 DenseMap DanglingDebugInfoMap;
124 MapVector DanglingDebugInfoMap;
124125
125126 public:
126127 /// Loads are not emitted to the program immediately. We bunch them up and
0 ; RUN: llc -O2 -o %t1.o < %s
1 ; RUN: llc -O2 -o %t2.o < %s
2 ; RUN: llc -O2 -o %t3.o < %s
3 ; RUN: llc -O2 -o %t4.o < %s
4 ; RUN: llc -O2 -o %t5.o < %s
5 ; RUN: cmp %t1.o %t2.o
6 ; RUN: cmp %t1.o %t3.o
7 ; RUN: cmp %t1.o %t4.o
8 ; RUN: cmp %t1.o %t5.o
9
10 ; Regression test for nondeterminism introduced in https://reviews.llvm.org/D57694
11
12 define void @test(i32 %x) !dbg !4 {
13 entry:
14 call void @llvm.dbg.value(metadata void (i32)* @f1, metadata !6, metadata !DIExpression()), !dbg !8
15 call void @llvm.dbg.value(metadata void (i32)* @f2, metadata !7, metadata !DIExpression()), !dbg !8
16 %cmp = icmp eq i32 %x, 0, !dbg !8
17 br i1 %cmp, label %cleanup, label %if.end
18
19 if.end:
20 %tobool = icmp eq i32 0, 0
21 %a = select i1 %tobool, void (i32)* @f1, void (i32)* null, !dbg !8
22 %b = select i1 %tobool, void (i32)* @f2, void (i32)* null, !dbg !8
23 call void %a(i32 %x)
24 call void %b(i32 %x)
25 unreachable
26
27 cleanup:
28 ret void
29 }
30
31 declare void @f1(i32)
32 declare void @f2(i32)
33
34 declare void @llvm.dbg.value(metadata, metadata, metadata)
35
36 !llvm.dbg.cu = !{!0}
37 !llvm.module.flags = !{!3}
38
39 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", runtimeVersion: 0, emissionKind: FullDebug)
40 !1 = !DIFile(filename: "test.cc", directory: "")
41 !2 = !{}
42 !3 = !{i32 2, !"Debug Info Version", i32 3}
43 !4 = distinct !DISubprogram(name: "test", scope: !1, file: !1, type: !5, unit: !0)
44 !5 = !DISubroutineType(types: !2)
45 !6 = !DILocalVariable(name: "a", scope: !4, file: !1, type: !9)
46 !7 = !DILocalVariable(name: "b", scope: !4, file: !1, type: !9)
47 !8 = !DILocation(scope: !4)
48 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)