Does llvm-gcc emit column # info?

Hi,

I tried llvm-gcc -g -O0 on several cases, but the column field of meta data always shows zero in created ll code.

Does llvm-gcc emit column # info ? Or I should add some option?

Thanks in advance.

Sheng.

Hi Sheng,

I tried llvm-gcc -g -O0 on several cases, but the column field of meta
data always shows zero in created ll code.

Does llvm-gcc emit column # info ? Or I should add some option?

as far as I knowm, llvm-gcc doesn't emit column info because it is based on
gcc-4.2 which has no support for column info. I think gcc-4.5 has column
info, so the dragonegg plugin (http://dragonegg.llvm.org) could in theory
output column info, though it doesn't right now.

Ciao,

Duncan.

Hi Duncan,

But in the doc “Source Level Debugging with LLVM”, it shows that llvm 2.6 could get column number. There’s an example in the doc as following:

http://llvm.org/docs/SourceLevelDebugging.html

  1. void foo() {
  2. int X = 21;
  3. int Y = 22;
  4. {
  5. int Z = 23;
  6. Z = X;
  7. }
  8. X = Y;
  9. }

Compiled to LLVM, this function would be represented like this:

define void @foo() nounwind ssp {
entry:
%X = alloca i32, align 4 ; <i32*> [#uses=4]
%Y = alloca i32, align 4 ; <i32*> [#uses=4]
%Z = alloca i32, align 4 ; <i32*> [#uses=3]
%0 = bitcast i32* %X to { }* ; <{ }> [#uses=1]
call void @llvm.dbg.declare({ }
%0, metadata !0), !dbg !7
store i32 21, i32* %X, !dbg !8
%1 = bitcast i32* %Y to { }* ; <{ }> [#uses=1]
call void @llvm.dbg.declare({ }
%1, metadata !9), !dbg !10
store i32 22, i32* %Y, !dbg !11
%2 = bitcast i32* %Z to { }* ; <{ }> [#uses=1]
call void @llvm.dbg.declare({ }
%2, metadata !12), !dbg !14
store i32 23, i32* %Z, !dbg !15
%tmp = load i32* %X, !dbg !16 ; [#uses=1]
%tmp1 = load i32* %Y, !dbg !16 ; [#uses=1]
%add = add nsw i32 %tmp, %tmp1, !dbg !16 ; [#uses=1]
store i32 %add, i32* %Z, !dbg !16
%tmp2 = load i32* %Y, !dbg !17 ; [#uses=1]
store i32 %tmp2, i32* %X, !dbg !17
ret void, !dbg !18
}

declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone

!0 = metadata !{i32 459008, metadata !1, metadata !“X”,
metadata !3, i32 2, metadata !6}; [ DW_TAG_auto_variable ]
!1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ]
!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !“foo”, metadata !“foo”,
metadata !“foo”, metadata !3, i32 1, metadata !4,
i1 false, i1 true}; [DW_TAG_subprogram ]
!3 = metadata !{i32 458769, i32 0, i32 12, metadata !“foo.c”,
metadata !"/private/tmp", metadata !“clang 1.1”, i1 true,
i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ]
!4 = metadata !{i32 458773, metadata !3, metadata !"", null, i32 0, i64 0, i64 0,
i64 0, i32 0, null, metadata !5, i32 0}; [DW_TAG_subroutine_type ]
!5 = metadata !{null}
!6 = metadata !{i32 458788, metadata !3, metadata !“int”, metadata !3, i32 0,
i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ]
!7 = metadata !{i32 2, i32 7, metadata !1, null}
!8 = metadata !{i32 2, i32 3, metadata !1, null}
!9 = metadata !{i32 459008, metadata !1, metadata !“Y”, metadata !3, i32 3,
metadata !6}; [ DW_TAG_auto_variable ]
!10 = metadata !{i32 3, i32 7, metadata !1, null}
!11 = metadata !{i32 3, i32 3, metadata !1, null}
!12 = metadata !{i32 459008, metadata !13, metadata !“Z”, metadata !3, i32 5,
metadata !6}; [ DW_TAG_auto_variable ]
!13 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ]
!14 = metadata !{i32 5, i32 9, metadata !13, null}
!15 = metadata !{i32 5, i32 5, metadata !13, null}
!16 = metadata !{i32 6, i32 5, metadata !13, null}
!17 = metadata !{i32 8, i32 3, metadata !1, null}
!18 = metadata !{i32 9, i32 1, metadata !2, null}

We tried the exactly same C code, but in our’s ll file, all coulmn field are 0. I suspect that we missed some options. Please advise. Thanks. Here’s how we compiled and our ll file:

llvm-gcc -O0 -g -emit-llvm -c t.c -S -o t.ll

define void @main() nounwind {
entry:
%X = alloca i32 ; <i32*> [#uses=3]
%Y = alloca i32 ; <i32*> [#uses=2]
%Z = alloca i32 ; <i32*> [#uses=2]
%“alloca point” = bitcast i32 0 to i32 ; [#uses=0]
call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !0), !dbg !7
call void @llvm.dbg.declare(metadata !{i32* %Y}, metadata !8), !dbg !7
store i32 21, i32* %X, align 4, !dbg !9
store i32 22, i32* %Y, align 4, !dbg !10
call void @llvm.dbg.declare(metadata !{i32* %Z}, metadata !11), !dbg !13
store i32 23, i32* %Z, align 4, !dbg !14
%0 = load i32* %X, align 4, !dbg !15 ; [#uses=1]
store i32 %0, i32* %Z, align 4, !dbg !15
%1 = load i32* %Y, align 4, !dbg !16 ; [#uses=1]
store i32 %1, i32* %X, align 4, !dbg !16
br label %return, !dbg !17

return: ; preds = %entry
ret void, !dbg !17
}

declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone

!0 = metadata !{i32 459008, metadata !1, metadata !“X”, metadata !3, i32 2, metadata !6} ; [ DW_TAG_auto_variable ]
!1 = metadata !{i32 458763, metadata !2, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !“main”, metadata !“main”, metadata !“main”, metadata !3, i32 1, metadata !4, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
!3 = metadata !{i32 458769, i32 0, i32 1, metadata !“t.c”, metadata !"/home/kecheng/llvm_test/xyz/", metadata !“4.2.1 (Based on Apple Inc. build 5658) (LLVM build)”, i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
!4 = metadata !{i32 458773, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !5, i32 0, null} ; [ DW_TAG_subroutine_type ]
!5 = metadata !{null}
!6 = metadata !{i32 458788, metadata !3, metadata !“int”, metadata !3, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
!7 = metadata !{i32 1, i32 0, metadata !1, null}
!8 = metadata !{i32 459008, metadata !1, metadata !“Y”, metadata !3, i32 3, metadata !6} ; [ DW_TAG_auto_variable ]
!9 = metadata !{i32 2, i32 0, metadata !1, null}
!10 = metadata !{i32 3, i32 0, metadata !1, null}
!11 = metadata !{i32 459008, metadata !12, metadata !“Z”, metadata !3, i32 5, metadata !6} ; [ DW_TAG_auto_variable ]
!12 = metadata !{i32 458763, metadata !1, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
!13 = metadata !{i32 3, i32 0, metadata !12, null}
!14 = metadata !{i32 5, i32 0, metadata !12, null}
!15 = metadata !{i32 6, i32 0, metadata !12, null}
!16 = metadata !{i32 8, i32 0, metadata !1, null}
!17 = metadata !{i32 9, i32 0, metadata !1, null}

Hi Kecheng,

But in the doc "Source Level Debugging with LLVM", it shows that llvm
2.6 could get column number. There's an example in the doc as following:
http://llvm.org/docs/SourceLevelDebugging.html

you are confusing what LLVM supports, and what a particular LLVM frontend
(llvm-gcc) produces. LLVM supports column numbers, but llvm-gcc does not
generate them. I think clang does however. Note that the document you cite
does not say that llvm-gcc produces the example output.

Ciao,

Duncan.

Hi Kecheng,

But in the doc "Source Level Debugging with LLVM", it shows that llvm
2.6 could get column number. There's an example in the doc as following:
http://llvm.org/docs/SourceLevelDebugging.html

you are confusing what LLVM supports, and what a particular LLVM frontend
(llvm-gcc) produces. LLVM supports column numbers, but llvm-gcc does not
generate them. I think clang does however.

Yes, clang generates column number. I used clang to generate quoted LLVM IR.

However, as Duncan says, LLVM IR supports column number and the
documented sited above describes how it is done in LLVM IR.