[llvm] [IPSCCP] Variable not visible at Og. (PR #66745)

Djordje Todorovic via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 02:26:49 PDT 2023


================
@@ -0,0 +1,184 @@
+; RUN: opt -passes=ipsccp -S -o - < %s | FileCheck %s
+
+; Global variables g_11, g_22, g_33, g_44, g_55, g_66 and g_77
+; are not visible in the debugger.
+
+;  1	int       g_1 = -4;
+;  2	float     g_2 = 4.44;
+;  3	char      g_3 = 'a';
+;  4	unsigned  g_4 = 4;
+;  5	bool      g_5 = true;
+;  6	int      *g_6 = nullptr;
+;  7	float    *g_7 = nullptr;
+;  8
+;  9	static int       g_11 = -5;
+; 10	static float     g_22 = 5.55;
+; 11	static char      g_33 = 'b';
+; 12	static unsigned  g_44 = 5;
+; 13	static bool      g_55 = true;
+; 14	static int      *g_66 = nullptr;
+; 15	static float    *g_77 = (float *)(55 + 15);
+; 16
+; 17	void bar() {
+; 18	  g_1 = g_11;
+; 19	  g_2 = g_22;
+; 20	  g_3 = g_33;
+; 21	  g_4 = g_44;
+; 22	  g_5 = g_55;
+; 23	  g_6 = g_66;
+; 24	  g_7 = g_77;
+; 25	}
+; 26
+; 27	int main() {
+; 28	  {
+; 29	    bar();
+; 30	  }
+; 31	}
+
+; CHECK: ![[G1:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG1:[0-9]+]], expr: !DIExpression(DW_OP_constu, 18446744073709551611, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG1]] = distinct !DIGlobalVariable(name: "g_11", {{.*}}
+; CHECK: ![[G2:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG2:[0-9]+]], expr: !DIExpression(DW_OP_constu, 1085381018, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG2]] = distinct !DIGlobalVariable(name: "g_22", {{.*}}
+; CHECK: ![[G3:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG3:[0-9]+]], expr: !DIExpression(DW_OP_constu, 98, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG3]] = distinct !DIGlobalVariable(name: "g_33", {{.*}}
+; CHECK: ![[G4:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG4:[0-9]+]], expr: !DIExpression(DW_OP_constu, 5, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG4]] = distinct !DIGlobalVariable(name: "g_44", {{.*}}
+; CHECK: ![[G5:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG5:[0-9]+]], expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG5]] = distinct !DIGlobalVariable(name: "g_55", {{.*}}
+; CHECK: ![[G6:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG6:[0-9]+]], expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG6]] = distinct !DIGlobalVariable(name: "g_66", {{.*}}
+; CHECK: ![[G7:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG7:[0-9]+]], expr: !DIExpression(DW_OP_constu, 70, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG7]] = distinct !DIGlobalVariable(name: "g_77", {{.*}}
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux-gnu"
+
+ at g_1 = dso_local global i32 -4, align 4, !dbg !0
+ at g_2 = dso_local global float 0x4011C28F60000000, align 4, !dbg !8
+ at g_3 = dso_local global i8 97, align 1, !dbg !10
+ at g_4 = dso_local global i32 4, align 4, !dbg !13
+ at g_5 = dso_local global i8 1, align 1, !dbg !16
+ at g_6 = dso_local global ptr null, align 8, !dbg !19
+ at g_7 = dso_local global ptr null, align 8, !dbg !23
+ at _ZL4g_11 = internal global i32 -5, align 4, !dbg !25
+ at _ZL4g_22 = internal global float 0x4016333340000000, align 4, !dbg !27
+ at _ZL4g_33 = internal global i8 98, align 1, !dbg !29
+ at _ZL4g_44 = internal global i32 5, align 4, !dbg !31
+ at _ZL4g_55 = internal global i8 1, align 1, !dbg !33
+ at _ZL4g_66 = internal global ptr null, align 8, !dbg !35
+ at _ZL4g_77 = internal global ptr inttoptr (i64 70 to ptr), align 8, !dbg !37
+
+define dso_local void @_Z3barv() !dbg !46 {
+entry:
+  %0 = load i32, ptr @_ZL4g_11, align 4, !dbg !49, !tbaa !50
----------------
djtodoro wrote:

I believe that you could use only one `!dbg` for all the instructions in the function and get rid of all the others.

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


More information about the llvm-commits mailing list