[llvm] [indvars] Missing variables at Og: (PR #69920)
Carlos Alberto Enciso via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 01:09:31 PDT 2024
================
@@ -0,0 +1,129 @@
+; RUN: opt -passes="loop(indvars)" \
+; RUN: --experimental-debuginfo-iterators=false -S -o - < %s | \
+; RUN: FileCheck --implicit-check-not="call void @llvm.dbg" \
+; RUN: --check-prefix=ALL-CHECK --check-prefix=PRE-CHECK %s
+; RUN: opt -passes="loop(indvars,loop-deletion)" \
+; RUN: --experimental-debuginfo-iterators=false -S -o - < %s | \
+; RUN: FileCheck --implicit-check-not="call void @llvm.dbg" \
+; RUN: --check-prefix=ALL-CHECK --check-prefix=POST-CHECK %s
+
+; Check what happens to a modified but otherwise unused variable in a loop
+; that gets deleted. The assignment in the loop is 'forgotten' by LLVM and
+; doesn't appear in the debugging information. This behaviour is suboptimal,
+; but we want to know if it changes
+
+; For all cases, LLDB shows
+; Var = <no location, value may have been optimized out>
+
+; 1 __attribute__((optnone)) int nop() {
+; 2 return 0;
+; 3 }
+; 4
+; 5 void bar() {
+; 6 int End = 777;
+; 7 int Index = 27;
+; 8 char Var = 1;
+; 9 for (; Index < End; ++Index) {
+; 10 if (Index == 666) {
+; 11 ++Var;
+; 12 }
+; 13 }
+; 14 nop();
+; 15 }
+
+; ALL-CHECK: entry:
+; ALL-CHECK: call void @llvm.dbg.value(metadata i32 1, metadata ![[DBG:[0-9]+]], {{.*}}
+
+; Only the 'indvars' pass is executed.
+; PRE-CHECK: for.cond:
+; PRE-CHECK: call void @llvm.dbg.value(metadata i32 %Var.0, metadata ![[DBG]], {{.*}}
+; PRE-CHECK: call void @llvm.dbg.value(metadata !DIArgList{{.*}}
+
+; PRE-CHECK: for.body:
+; PRE-CHECK: %cmp1 = icmp eq i32 %Index.0, 666
+; PRE-CHECK: %inc = add nsw i32 %Var.0, 1
+; PRE-CHECK: %spec.select = select i1 %cmp1, i32 %inc, i32 %Var.0
+; PRE-CHECK: call void @llvm.dbg.value(metadata i32 %spec.select, metadata ![[DBG]], {{.*}}
+; PRE-CHECK: br label %for.cond
+
+; PRE-CHECK: for.end:
+; PRE-CHECK-NOT: call void @llvm.dbg.value
----------------
CarlosAlbertoEnciso wrote:
Removed.
https://github.com/llvm/llvm-project/pull/69920
More information about the llvm-commits
mailing list