[LLVMdev] metadata linking bug or by design

Devang Patel dpatel at apple.com
Thu Aug 4 10:22:53 PDT 2011


On Aug 4, 2011, at 8:21 AM, Xi Wang wrote:

> Hi,
> 
> It seems that current linker "drops" updated llvm::Value * references
> in metadata.  Here goes an example.  We have a two-line source file
> a.c:
> 
> static int x;
> void foo() { x = 1; }
> 
> and a similar b.c:
> 
> static int x;
> void bar() { x = 1; }
> 
> They both have an internal variable x; one of them will be renamed (to
> x1) during linking.
> 
> clang -emit-llvm -c -g a.c
> clang -emit-llvm -c -g b.c
> llvm-link -o t.bc a.o b.o
> 
> Before linking we can see the following lines in both bitcode files
> from a.c and b.c, where the last element of !5 refers to the internal
> variable x.
> 
> !llvm.dbg.sp = !{!1}
> !5 = metadata !{i32 655412, i32 0, metadata !0, metadata !"x",
> metadata !"x", metadata !"", metadata !2, i32 1, metadata !6, i32 1,
> i32 1, i32* @x} ; [ DW_TAG_variable ]
> 
> However after linking the last element of !11 becomes null.  I was
> expecting that it would refer to the renamed x1.
> 
> !llvm.dbg.gv = !{!9, !11}
> !9 = metadata !{i32 655412, i32 0, metadata !0, metadata !"x",
> metadata !"x", metadata !"", metadata !3, i32 1, metadata !10, i32 1,
> i32 1, i32* @x} ; [ DW_TAG_variable ]
> !11 = metadata !{i32 655412, i32 0, metadata !1, metadata !"x",
> metadata !"x", metadata !"", metadata !7, i32 1, metadata !12, i32 1,
> i32 1, null} ; [ DW_TAG_variable ]
> 
> Is it intentional or a bug?  Thanks.

It's a bug, probably a regression. Please file a bugzilla report.
Thanks,
-
Devang



More information about the llvm-dev mailing list