Skip to content

Commit 7506872

Browse files
authored
[DebugInfo][LSR] Fix assertion failure salvaging IV with offset > 64 bits wide (llvm#110979)
Fixes llvm#110494
1 parent 1ba19d6 commit 7506872

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6870,6 +6870,8 @@ static bool SalvageDVI(llvm::Loop *L, ScalarEvolution &SE,
68706870
SE.computeConstantDifference(DVIRec.SCEVs[i], SCEVInductionVar)) {
68716871
if (Offset->getSignificantBits() <= 64)
68726872
SalvageExpr->createOffsetExpr(Offset->getSExtValue(), LSRInductionVar);
6873+
else
6874+
return false;
68736875
} else if (!SalvageExpr->createIterCountExpr(DVIRec.SCEVs[i], IterCountExpr,
68746876
SE))
68756877
return false;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; RUN: opt -S -loop-reduce %s | FileCheck %s
2+
3+
;; We (currently?) can't salvage an IV if the offset is wider than 64 bits.
4+
;; Check we poison it instead.
5+
6+
; CHECK: #dbg_value(i[[#]] poison, ![[#]], !DIExpression(), ![[#]])
7+
8+
define i16 @main() {
9+
entry:
10+
br label %for.cond29
11+
12+
for.cond29: ; preds = %for.body32, %entry
13+
%il_1000.0 = phi i128 [ 0, %entry ], [ %inc72, %for.body32 ]
14+
%l_995.0 = phi i128 [ 4704496199548239085565, %entry ], [ %inc70, %for.body32 ]
15+
#dbg_value(i128 %l_995.0, !4, !DIExpression(), !9)
16+
%cmp30 = icmp slt i128 %il_1000.0, 0
17+
br i1 %cmp30, label %for.body32, label %for.cond.cleanup31
18+
19+
for.cond.cleanup31: ; preds = %for.cond29
20+
ret i16 0
21+
22+
for.body32: ; preds = %for.cond29
23+
%inc70 = add i128 %l_995.0, 1
24+
%inc72 = add i128 %il_1000.0, 1
25+
br label %for.cond29
26+
}
27+
28+
!llvm.dbg.cu = !{!0}
29+
!llvm.module.flags = !{!3}
30+
31+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, globals: !2, splitDebugInlining: false, nameTableKind: None)
32+
!1 = !DIFile(filename: "foo.c", directory: "/tmp")
33+
!2 = !{}
34+
!3 = !{i32 2, !"Debug Info Version", i32 3}
35+
!4 = !DILocalVariable(name: "l_995", scope: !5, file: !1, line: 414, type: !7)
36+
!5 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 397, type: !6, scopeLine: 398, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
37+
!6 = !DISubroutineType(types: !2)
38+
!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint128_t", file: !1, baseType: !8)
39+
!8 = !DIBasicType(name: "unsigned __int128", size: 128, encoding: DW_ATE_unsigned)
40+
!9 = !DILocation(line: 0, scope: !5)

0 commit comments

Comments
 (0)