Skip to content

Commit 1c6fd98

Browse files
committed
[SelectionDAG] Do not salvage with vector node
rG2eb7cbf987f21 added this code, which results in crash for vector nodes. This patch solves it by skipping for the vector nodes. Thanks Steve for helping reducing the test case. Co-authored-by: Steve Merritt <[email protected]> Reviewed By: goldstein.w.n Differential Revision: https://reviews.llvm.org/D152492
1 parent 995a26d commit 1c6fd98

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10473,8 +10473,7 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) {
1047310473
case ISD::ADD:
1047410474
SDValue N0 = N.getOperand(0);
1047510475
SDValue N1 = N.getOperand(1);
10476-
if (!isConstantIntBuildVectorOrConstantInt(N0) &&
10477-
isConstantIntBuildVectorOrConstantInt(N1)) {
10476+
if (!isa<ConstantSDNode>(N0) && isa<ConstantSDNode>(N1)) {
1047810477
uint64_t Offset = N.getConstantOperandVal(1);
1047910478

1048010479
// Rewrite an ADD constant node into a DIExpression. Since we are
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=avx512bw,avx512vl -o - %s
2+
3+
;; Check this won't result in crash.
4+
define <8 x i32> @foo(ptr %0, <8 x i32> %1, i8 %2, i8 %3) {
5+
%5 = call <8 x i32> @llvm.smax.v8i32(<8 x i32> %1, <8 x i32> zeroinitializer)
6+
%6 = add nsw <8 x i32> %1, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
7+
call void @llvm.dbg.value(metadata <8 x i32> %6, metadata !4, metadata !DIExpression()), !dbg !15
8+
%7 = bitcast i8 %2 to <8 x i1>
9+
%8 = select <8 x i1> %7, <8 x i32> %6, <8 x i32> %5
10+
%9 = call <8 x i32> @llvm.smax.v8i32(<8 x i32> %8, <8 x i32> zeroinitializer)
11+
%10 = bitcast i8 %3 to <8 x i1>
12+
%11 = select <8 x i1> %10, <8 x i32> %9, <8 x i32> <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
13+
ret <8 x i32> %11
14+
}
15+
16+
declare <8 x i32> @llvm.smax.v8i32(<8 x i32>, <8 x i32>)
17+
declare void @llvm.dbg.value(metadata, metadata, metadata)
18+
19+
!llvm.dbg.cu = !{!0}
20+
!llvm.module.flags = !{!3}
21+
22+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 16.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
23+
!1 = !DIFile(filename: "a.cpp", directory: "/")
24+
!2 = !{}
25+
!3 = !{i32 2, !"Debug Info Version", i32 3}
26+
!4 = !DILocalVariable(name: "a", arg: 2, scope: !5, file: !1, line: 12, type: !11)
27+
!5 = distinct !DISubprogram(name: "foo", scope: !6, file: !1, line: 12, type: !7, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !9, retainedNodes: !10)
28+
!6 = !DINamespace(name: "ns1", scope: null)
29+
!7 = !DISubroutineType(types: !8)
30+
!8 = !{null}
31+
!9 = !DISubprogram(name: "foo", scope: !6, file: !1, line: 132, type: !7, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
32+
!10 = !{!4}
33+
!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 256, flags: DIFlagVector, elements: !13)
34+
!12 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)
35+
!13 = !{!14}
36+
!14 = !DISubrange(count: 4)
37+
!15 = !DILocation(line: 0, scope: !5, inlinedAt: !16)
38+
!16 = !DILocation(line: 18, scope: !17)
39+
!17 = distinct !DISubprogram(name: "foo", scope: null, file: !1, type: !7, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)

0 commit comments

Comments
 (0)