llvm.org GIT mirror llvm / ce540c1
Merging r243057: ------------------------------------------------------------------------ r243057 | spatel | 2015-07-23 15:56:53 -0700 (Thu, 23 Jul 2015) | 16 lines fix crash in machine trace metrics due to processing dbg_value instructions (PR24199) The test in PR24199 ( https://llvm.org/bugs/show_bug.cgi?id=24199 ) crashes because machine trace metrics was not ignoring dbg_value instructions when calculating data dependencies. The machine-combiner pass asks machine trace metrics to calculate an instruction trace, does some reassociations, and calls MachineInstr::eraseFromParentAndMarkDBGValuesForRemoval() along with MachineTraceMetrics::invalidate(). The dbg_value instructions have their operands invalidated, but the instructions are not expected to be deleted. On a subsequent loop iteration of the machine-combiner pass, machine trace metrics would be called again and die while accessing the invalid debug instructions. Differential Revision: http://reviews.llvm.org/D11423 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@243662 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 years ago
2 changed file(s) with 66 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
623623 static bool getDataDeps(const MachineInstr *UseMI,
624624 SmallVectorImpl &Deps,
625625 const MachineRegisterInfo *MRI) {
626 // Debug values should not be included in any calculations.
627 if (UseMI->isDebugValue())
628 return false;
629
626630 bool HasPhysRegs = false;
627631 for (MachineInstr::const_mop_iterator I = UseMI->operands_begin(),
628632 E = UseMI->operands_end(); I != E; ++I) {
0 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=sse -enable-unsafe-fp-math < %s | FileCheck %s
1
2 ; The debug info in this test case was causing a crash because machine trace metrics
3 ; did not correctly ignore debug instructions. The check lines ensure that the
4 ; machine-combiner pass has run, reassociated the add operands, and therefore
5 ; used machine trace metrics.
6
7 define void @PR24199() {
8 ; CHECK-LABEL: PR24199:
9 ; CHECK: addss %xmm1, %xmm0
10 ; CHECK: addss %xmm2, %xmm0
11
12 entry:
13 %i = alloca %struct.A, align 8
14 %tobool = icmp ne i32 undef, 0
15 br i1 undef, label %if.end, label %if.then
16
17 if.then:
18 br label %if.end
19
20 if.end:
21 %h = phi float [ 0.0, %if.then ], [ 4.0, %entry ]
22 call void @foo(%struct.A* nonnull undef)
23 tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
24 tail call void @llvm.dbg.value(metadata float %h, i64 0, metadata !5, metadata !4), !dbg !6
25 %n0 = load float, float* undef, align 4
26 %mul = fmul fast float %n0, %h
27 %add = fadd fast float %mul, 1.0
28 tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
29 tail call void @llvm.dbg.value(metadata float %add, i64 0, metadata !5, metadata !4), !dbg !6
30 %add.i = fadd fast float %add, %n0
31 store float %add.i, float* undef, align 4
32 %n1 = bitcast %struct.A* %i to i8*
33 call void @llvm.lifetime.start(i64 16, i8* %n1)
34 %n2 = load <2 x float>, <2 x float>* undef, align 8
35 %conv = uitofp i1 %tobool to float
36 %bitcast = extractelement <2 x float> %n2, i32 0
37 %factor = fmul fast float %bitcast, 2.0
38 %add3 = fadd fast float %factor, %conv
39 call void @bar(float %add3)
40 ret void
41 }
42
43 %struct.A = type { float, float }
44
45 declare void @bar(float)
46 declare void @foo(%struct.A*)
47 declare void @llvm.lifetime.start(i64, i8* nocapture)
48 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
49
50 !llvm.dbg.cu = !{!0}
51 !llvm.module.flags = !{!2}
52
53 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: 1)
54 !1 = !DIFile(filename: "24199.cpp", directory: "/bin")
55 !2 = !{i32 2, !"Debug Info Version", i32 3}
56 !3 = !DISubprogram(linkageName: "foo", file: !1, line: 18, isLocal: false, isDefinition: true, scopeLine: 18, function: void (%struct.A*)* @foo)
57 !4 = !DIExpression()
58 !5 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
59 !6 = !DILocation(line: 0, scope: !3)
60
61