Skip to content

[DebugInfo][GVNSink] Fix #77415: GVNSink fails to optimize LLVM IR with debug info #77602

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

Merged
merged 5 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/test/Transforms/GVNSink/sink-ignore-dbg-intrinsics.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
; RUN: opt < %s -passes=gvn-sink -S | FileCheck %s

; Test that GVNSink correctly performs the sink optimization in the presence of debug information

; Function Attrs: noinline nounwind uwtable
define dso_local i32 @fun(i32 noundef %a, i32 noundef %b) #0 !dbg !10 {
entry:
Expand All @@ -25,9 +27,9 @@ if.else: ; preds = %entry
br label %if.end

; CHECK-LABEL: if.end:
; CHECK: [[SINK:%.*.sink]] = phi i32 [ %a, %if.then ], [ %b, %if.else ]
; CHECK: %add = add nsw i32 [[SINK]], 1
; CHECK: %xor = xor i32 %add, 1
; CHECK: [[SINK:%.*sink]] = phi i32 [ {{.*}} ], [ {{.*}} ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should have a fixed order here.
maybe swap the PHI operands and see if that passed the check.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or better use the llvm-project/llvm/utils/update_test_checks.py to update the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Now the incoming blocks has a fixed order.

; CHECK: [[ADD:%.*]] = add nsw i32 [[SINK]], 1
; CHECK: [[XOR:%.*]] = xor i32 [[ADD]], 1
if.end: ; preds = %if.else, %if.then
%ret.0 = phi i32 [ %xor, %if.then ], [ %xor2, %if.else ], !dbg !35
tail call void @llvm.dbg.value(metadata i32 %ret.0, metadata !27, metadata !DIExpression()), !dbg !16
Expand Down
Loading