-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DebugInfo][LSR] Fix assertion failure salvaging IV with offset > 64 bits wide #110979
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-transforms Author: Orlando Cazalet-Hyams (OCHyams) ChangesFixes #110494 Full diff: https://github.com/llvm/llvm-project/pull/110979.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 3ca3818938fd26..1ad63cb5bf4563 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6869,6 +6869,8 @@ static bool SalvageDVI(llvm::Loop *L, ScalarEvolution &SE,
SE.computeConstantDifference(DVIRec.SCEVs[i], SCEVInductionVar)) {
if (Offset->getSignificantBits() <= 64)
SalvageExpr->createOffsetExpr(Offset->getSExtValue(), LSRInductionVar);
+ else
+ return false;
} else if (!SalvageExpr->createIterCountExpr(DVIRec.SCEVs[i], IterCountExpr,
SE))
return false;
diff --git a/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-large-width.ll b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-large-width.ll
new file mode 100644
index 00000000000000..dcd17cae59f4d7
--- /dev/null
+++ b/llvm/test/Transforms/LoopStrengthReduce/debuginfo-scev-salvage-large-width.ll
@@ -0,0 +1,40 @@
+; RUN: opt -S -loop-reduce %s | FileCheck %s
+
+;; We (currently?) can't salvage an IV if the offset is wider than 64 bits.
+;; Check we poison it instead.
+
+; CHECK: #dbg_value(i[[#]] poison, ![[#]], !DIExpression(), ![[#]])
+
+define i16 @main() {
+entry:
+ br label %for.cond29
+
+for.cond29: ; preds = %for.body32, %entry
+ %il_1000.0 = phi i128 [ 0, %entry ], [ %inc72, %for.body32 ]
+ %l_995.0 = phi i128 [ 4704496199548239085565, %entry ], [ %inc70, %for.body32 ]
+ #dbg_value(i128 %l_995.0, !4, !DIExpression(), !9)
+ %cmp30 = icmp slt i128 %il_1000.0, 0
+ br i1 %cmp30, label %for.body32, label %for.cond.cleanup31
+
+for.cond.cleanup31: ; preds = %for.cond29
+ ret i16 0
+
+for.body32: ; preds = %for.cond29
+ %inc70 = add i128 %l_995.0, 1
+ %inc72 = add i128 %il_1000.0, 1
+ br label %for.cond29
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+
+!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)
+!1 = !DIFile(filename: "foo.c", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !DILocalVariable(name: "l_995", scope: !5, file: !1, line: 414, type: !7)
+!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)
+!6 = !DISubroutineType(types: !2)
+!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint128_t", file: !1, baseType: !8)
+!8 = !DIBasicType(name: "unsigned __int128", size: 128, encoding: DW_ATE_unsigned)
+!9 = !DILocation(line: 0, scope: !5)
|
jmorse
approved these changes
Oct 3, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! I've verified that this patch solves the problem I saw. |
xgupta
pushed a commit
to xgupta/llvm-project
that referenced
this pull request
Oct 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #110494