[llvm] [DebugInfo][IndVarSimplify] fix missing debug location updates (PR #91443)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 06:27:47 PDT 2024


================
@@ -0,0 +1,65 @@
+; RUN: opt < %s -passes=indvars -S | FileCheck %s
+
+; This testcase checks the preservation of debug locations of newly created 
+; phi, sitofp, add and icmp instructions in IndVarSimplify Pass.
+
+define void @test1() !dbg !5 {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[BB:%.*]], !dbg
+; CHECK:  bb:
+; CHECK:    [[IV_INT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[DOTINT:%.*]], [[BB]] ], !dbg
+; CHECK:    [[INDVAR_CONV:%.*]] = sitofp i32 [[IV_INT]] to double, !dbg
+; CHECK:    [[DOTINT]] = add nuw nsw i32 [[IV_INT]], 1, !dbg
+; CHECK:    [[TMP1:%.*]] = icmp ult i32 [[DOTINT]], 10000, !dbg
----------------
OCHyams wrote:

Oops I never submitted my other comment.

IMO we should check the debug locations too, i.e., capture the !dbg number and check the contents. Something like this for each inst:

```
; CHECK: [[IV_INT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[DOTINT:%.*]], [[BB]] ], !dbg ![[dbg:[0-9+]]
...

; CHECK ![[dbg]] = !DILocation(line: 2,
```

https://github.com/llvm/llvm-project/pull/91443


More information about the llvm-commits mailing list