[llvm] [ArgumentPromotion] Emit DW_OP_LLVM_implicit_pointer for promoted pointer args (PR #187642)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 08:50:32 PDT 2026
yonghong-song wrote:
@phyBrackets Thanks for working on this!
I tried the following example,
```
$ cat foo.c
struct t {int a; int b;};
__attribute__((noinline)) static int foo(struct t *p) { return p->b + 5; }
int bar(int a, int b) { struct t x = {a, b}; return foo(&x); }
```
and compile with
```
clang -O3 -g -c foo.c -mllvm -print-after-all
```
Now we don't have the following
```
; *** IR Dump After ArgumentPromotionPass on (foo) ***
; Function Attrs: noinline nounwind uwtable
define internal fastcc range(i32 -2147483643, -2147483648) i32 @foo(i32 %0) unnamed_addr #2 !dbg !13 {
#dbg_value(i32 %0, !23, !DIExpression(DW_OP_LLVM_implicit_pointer), !24)
%2 = add nsw i32 %0, 5, !dbg !25
ret i32 %2, !dbg !26
}
!23 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !21, file: !1, line: 1, baseType: !16, size: 32)
!24 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !21, file: !1, line: 1, baseType: !16, size: 32, offset: 32)
```
Could you explain what does the following mean?
```
#dbg_value(i32 %0, !23, !DIExpression(DW_OP_LLVM_implicit_pointer), !24)
```
and how it relates to 'p->b'?
And `llvm-dwarfdump foo.o`
```
...
0x00000061: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000000010)
DW_AT_high_pc (0x0000000000000014)
DW_AT_frame_base (DW_OP_reg7 RSP)
DW_AT_call_all_calls (true)
DW_AT_name ("foo")
DW_AT_decl_file ("/home/yhs/tests/sig-change-pahole/prom/foo.c")
DW_AT_decl_line (2)
DW_AT_prototyped (true)
DW_AT_calling_convention (DW_CC_nocall)
DW_AT_type (0x00000084 "int")
0x00000071: DW_TAG_formal_parameter
DW_AT_location (DW_OP_implicit_pointer 0x0 +0)
DW_AT_name ("p")
DW_AT_decl_file ("/home/yhs/tests/sig-change-pahole/prom/foo.c")
DW_AT_decl_line (2)
DW_AT_type (0x000000a0 "t *")
0x00000080: NULL
...
```
I am not sure how the above dwarf can relate to `p->b`.
Did I miss anything?
https://github.com/llvm/llvm-project/pull/187642
More information about the llvm-commits
mailing list