Skip to content

Commit e092157

Browse files
committed
Merging r245862:
------------------------------------------------------------------------ r245862 | wschmidt | 2015-08-24 15:27:27 -0400 (Mon, 24 Aug 2015) | 8 lines [PPC64LE] Fix PR24546 - Swap optimization and debug values This patch fixes PR24546, which demonstrates a segfault during the VSX swap removal pass. The problem is that debug value instructions were not excluded from the list of instructions to be analyzed for webs of related computation. I've added the test case from the PR as a crash test in test/CodeGen/PowerPC. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@252850 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent aa717db commit e092157

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

lib/Target/PowerPC/PPCVSXSwapRemoval.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ bool PPCVSXSwapRemoval::gatherVectorInstructions() {
240240
for (MachineBasicBlock &MBB : *MF) {
241241
for (MachineInstr &MI : MBB) {
242242

243+
if (MI.isDebugValue())
244+
continue;
245+
243246
bool RelevantInstr = false;
244247
bool Partial = false;
245248

test/CodeGen/PowerPC/pr24546.ll

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu < %s
2+
3+
; Verify that we no longer crash in VSX swap removal when debug values
4+
; are in the code stream.
5+
6+
@php_intpow10.powers = external unnamed_addr constant [23 x double], align 8
7+
8+
; Function Attrs: nounwind
9+
define double @_php_math_round(double %value, i32 signext %places, i32 signext %mode) #0 {
10+
entry:
11+
br i1 undef, label %if.then, label %if.else, !dbg !32
12+
13+
if.then: ; preds = %entry
14+
%conv = sitofp i32 undef to double, !dbg !34
15+
br i1 undef, label %if.then.i, label %if.end.i, !dbg !36
16+
17+
if.then.i: ; preds = %if.then
18+
%call.i = tail call double @pow(double 1.000000e+01, double undef) #3, !dbg !39
19+
br label %php_intpow10.exit, !dbg !41
20+
21+
if.end.i: ; preds = %if.then
22+
%0 = load double, double* undef, align 8, !dbg !42, !tbaa !43
23+
br label %php_intpow10.exit, !dbg !47
24+
25+
php_intpow10.exit: ; preds = %if.end.i, %if.then.i
26+
%retval.0.i = phi double [ %call.i, %if.then.i ], [ %0, %if.end.i ], !dbg !48
27+
tail call void @llvm.dbg.value(metadata double %retval.0.i, i64 0, metadata !15, metadata !49), !dbg !50
28+
%div = fdiv double %conv, %retval.0.i, !dbg !51
29+
br label %if.end.15, !dbg !52
30+
31+
if.else: ; preds = %entry
32+
%mul = fmul double %value, undef, !dbg !53
33+
br label %if.end.15
34+
35+
if.end.15: ; preds = %if.else, %php_intpow10.exit
36+
%tmp_value.1 = phi double [ %div, %php_intpow10.exit ], [ %mul, %if.else ]
37+
ret double %tmp_value.1, !dbg !57
38+
}
39+
40+
declare signext i32 @php_intlog10abs(...) #1
41+
42+
declare signext i32 @php_round_helper(...) #1
43+
44+
; Function Attrs: nounwind
45+
declare double @pow(double, double) #0
46+
47+
; Function Attrs: nounwind readnone
48+
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
49+
50+
attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+power8-vector,+vsx,-qpx" "unsafe-fp-math"="false" "use-soft-float"="false" }
51+
attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+power8-vector,+vsx,-qpx" "unsafe-fp-math"="false" "use-soft-float"="false" }
52+
attributes #2 = { nounwind readnone }
53+
attributes #3 = { nounwind }
54+
55+
!llvm.dbg.cu = !{!0}
56+
!llvm.module.flags = !{!29, !30}
57+
!llvm.ident = !{!31}
58+
59+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (git://github.com/llvm-mirror/clang.git e0848b6353721eb1b278a5bbea257bbf6316251e) (git://github.com/llvm-mirror/llvm.git 8724a428dfd5e78d7865bb01783708e83f9ed128)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !5, globals: !23)
60+
!1 = !DIFile(filename: "testcase.i", directory: "/tmp/glibc.build")
61+
!2 = !{}
62+
!3 = !{!4}
63+
!4 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float)
64+
!5 = !{!6, !18}
65+
!6 = !DISubprogram(name: "_php_math_round", scope: !1, file: !1, line: 15, type: !7, isLocal: false, isDefinition: true, scopeLine: 16, flags: DIFlagPrototyped, isOptimized: true, function: double (double, i32, i32)* @_php_math_round, variables: !10)
66+
!7 = !DISubroutineType(types: !8)
67+
!8 = !{!4, !4, !9, !9}
68+
!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
69+
!10 = !{!11, !12, !13, !14, !15, !16, !17}
70+
!11 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "value", arg: 1, scope: !6, file: !1, line: 15, type: !4)
71+
!12 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "places", arg: 2, scope: !6, file: !1, line: 15, type: !9)
72+
!13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "mode", arg: 3, scope: !6, file: !1, line: 15, type: !9)
73+
!14 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "f1", scope: !6, file: !1, line: 17, type: !4)
74+
!15 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "f2", scope: !6, file: !1, line: 17, type: !4)
75+
!16 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "tmp_value", scope: !6, file: !1, line: 18, type: !4)
76+
!17 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "precision_places", scope: !6, file: !1, line: 19, type: !9)
77+
!18 = !DISubprogram(name: "php_intpow10", scope: !1, file: !1, line: 1, type: !19, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, variables: !21)
78+
!19 = !DISubroutineType(types: !20)
79+
!20 = !{!4, !9}
80+
!21 = !{!22}
81+
!22 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "power", arg: 1, scope: !18, file: !1, line: 1, type: !9)
82+
!23 = !{!24}
83+
!24 = !DIGlobalVariable(name: "powers", scope: !18, file: !1, line: 3, type: !25, isLocal: true, isDefinition: true, variable: [23 x double]* @php_intpow10.powers)
84+
!25 = !DICompositeType(tag: DW_TAG_array_type, baseType: !26, size: 1472, align: 64, elements: !27)
85+
!26 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !4)
86+
!27 = !{!28}
87+
!28 = !DISubrange(count: 23)
88+
!29 = !{i32 2, !"Dwarf Version", i32 4}
89+
!30 = !{i32 2, !"Debug Info Version", i32 3}
90+
!31 = !{!"clang version 3.8.0 (git://github.com/llvm-mirror/clang.git e0848b6353721eb1b278a5bbea257bbf6316251e) (git://github.com/llvm-mirror/llvm.git 8724a428dfd5e78d7865bb01783708e83f9ed128)"}
91+
!32 = !DILocation(line: 21, column: 32, scope: !33)
92+
!33 = distinct !DILexicalBlock(scope: !6, file: !1, line: 21, column: 6)
93+
!34 = !DILocation(line: 22, column: 15, scope: !35)
94+
!35 = distinct !DILexicalBlock(scope: !33, file: !1, line: 21, column: 67)
95+
!36 = !DILocation(line: 8, column: 16, scope: !37, inlinedAt: !38)
96+
!37 = distinct !DILexicalBlock(scope: !18, file: !1, line: 8, column: 6)
97+
!38 = distinct !DILocation(line: 23, column: 8, scope: !35)
98+
!39 = !DILocation(line: 9, column: 10, scope: !40, inlinedAt: !38)
99+
!40 = distinct !DILexicalBlock(scope: !37, file: !1, line: 8, column: 31)
100+
!41 = !DILocation(line: 9, column: 3, scope: !40, inlinedAt: !38)
101+
!42 = !DILocation(line: 11, column: 9, scope: !18, inlinedAt: !38)
102+
!43 = !{!44, !44, i64 0}
103+
!44 = !{!"double", !45, i64 0}
104+
!45 = !{!"omnipotent char", !46, i64 0}
105+
!46 = !{!"Simple C/C++ TBAA"}
106+
!47 = !DILocation(line: 11, column: 2, scope: !18, inlinedAt: !38)
107+
!48 = !DILocation(line: 23, column: 8, scope: !35)
108+
!49 = !DIExpression()
109+
!50 = !DILocation(line: 17, column: 13, scope: !6)
110+
!51 = !DILocation(line: 24, column: 25, scope: !35)
111+
!52 = !DILocation(line: 25, column: 2, scope: !35)
112+
!53 = !DILocation(line: 27, column: 22, scope: !54)
113+
!54 = distinct !DILexicalBlock(scope: !55, file: !1, line: 26, column: 20)
114+
!55 = distinct !DILexicalBlock(scope: !56, file: !1, line: 26, column: 7)
115+
!56 = distinct !DILexicalBlock(scope: !33, file: !1, line: 25, column: 9)
116+
!57 = !DILocation(line: 32, column: 2, scope: !6)

0 commit comments

Comments
 (0)