Cindy Rubio González
2011-Aug-16 23:07 UTC
[LLVMdev] Missing metadata for volatile variables
Hi everyone, I am using the dragonegg plugin to produce bitcode for the following small C program: int main() { 1: int x = -5; 2: x = 6; 3: return 0; } The assignments on lines 1 and 2 are removed even when no optimization flags are specified. I tried making variable "x" volatile, which prevents the assignments from being removed, however I am no longer able to recover the original name of the variable "x". Below is the bitcode generated. It seems like the metadata does not mention "x" anywhere. Am I missing something? Thank you, Cindy ======== ; ModuleID = 'post/tests/test1/source.c' target datalayout "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32" target triple = "i386-pc-linux-gnu" module asm "\09.ident\09\22GCC: (GNU) 4.5.2 LLVM: exported\22" %int = type i32 define i32 @main() nounwind { entry: %memtmp = alloca i32 %memtmp1 = alloca i32 %"alloca point" = bitcast i32 0 to i32 %"ssa point" = bitcast i32 0 to i32 br label %"2", !dbg !6 "2": ; preds = %entry call void @llvm.dbg.declare(metadata !{i32* %memtmp}, metadata !7), !dbg !9 volatile store i32 -5, i32* %memtmp, align 4, !dbg !9 volatile store i32 6, i32* %memtmp, align 4, !dbg !10 store i32 0, i32* %memtmp1, align 1, !dbg !11 br label %return, !dbg !11 return: ; preds = %"2" %retval = load i32* %memtmp1, !dbg !11 ret i32 %retval, !dbg !11 } declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone !llvm.dbg.sp = !{!0} !0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, null} ; [ DW_TAG_subprogram ] !1 = metadata !{i32 589865, metadata !"source.c", metadata !"/afs/cs.wisc.edu/u/c/r/crubio/trunk/post/tests/test1", metadata !2} ; [ DW_TAG_file_type ] !2 = metadata !{i32 589841, i32 0, i32 1, metadata !"source.c", metadata !"post/tests/test1", metadata !"4.5.2", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] !3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] !4 = metadata !{metadata !5} !5 = metadata !{i32 589860, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] !6 = metadata !{i32 1, i32 0, metadata !0, null} !7 = metadata !{i32 590080, metadata !0, metadata !"memtmp", metadata !1, i32 2, metadata !8, i32 0} ; [ DW_TAG_auto_variable ] !8 = metadata !{i32 589877, metadata !1, metadata !"", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ DW_TAG_volatile_type ] !9 = metadata !{i32 2, i32 0, metadata !0, null} !10 = metadata !{i32 3, i32 0, metadata !0, null} !11 = metadata !{i32 4, i32 0, metadata !0, null} ========
Hi Cindy,> I am using the dragonegg plugin to produce bitcode for the following > small C program: > > int main() { > 1: int x = -5; > 2: x = 6; > 3: return 0; > } > > The assignments on lines 1 and 2 are removed even when no optimization > flags are specified.as the value of x is never used the compiler doesn't bother outputting it as you noticed. I tried making variable "x" volatile, which> prevents the assignments from being removed, however I am no longer > able to recover the original name of the variable "x". Below is the > bitcode generated. It seems like the metadata does not mention "x" > anywhere. Am I missing something?Unfortunately dragonegg doesn't currently output *any* debug info for variables. This would probably be easy enough to fix but no one got around to it yet. Please feel free to open a bug report. Ciao, Duncan.> > Thank you, > Cindy > > > ========> > ; ModuleID = 'post/tests/test1/source.c' > target datalayout > "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32" > target triple = "i386-pc-linux-gnu" > > module asm "\09.ident\09\22GCC: (GNU) 4.5.2 LLVM: exported\22" > > %int = type i32 > > define i32 @main() nounwind { > entry: > %memtmp = alloca i32 > %memtmp1 = alloca i32 > %"alloca point" = bitcast i32 0 to i32 > %"ssa point" = bitcast i32 0 to i32 > br label %"2", !dbg !6 > > "2": ; preds = %entry > call void @llvm.dbg.declare(metadata !{i32* %memtmp}, metadata !7), !dbg !9 > volatile store i32 -5, i32* %memtmp, align 4, !dbg !9 > volatile store i32 6, i32* %memtmp, align 4, !dbg !10 > store i32 0, i32* %memtmp1, align 1, !dbg !11 > br label %return, !dbg !11 > > return: ; preds = %"2" > %retval = load i32* %memtmp1, !dbg !11 > ret i32 %retval, !dbg !11 > } > > declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone > > !llvm.dbg.sp = !{!0} > > !0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", > metadata !"main", metadata !"main", metadata !1, i32 1, metadata !3, > i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, null} ; [ > DW_TAG_subprogram ] > !1 = metadata !{i32 589865, metadata !"source.c", metadata > !"/afs/cs.wisc.edu/u/c/r/crubio/trunk/post/tests/test1", metadata !2} > ; [ DW_TAG_file_type ] > !2 = metadata !{i32 589841, i32 0, i32 1, metadata !"source.c", > metadata !"post/tests/test1", metadata !"4.5.2", i1 true, i1 false, > metadata !"", i32 0} ; [ DW_TAG_compile_unit ] > !3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, > i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ > DW_TAG_subroutine_type ] > !4 = metadata !{metadata !5} > !5 = metadata !{i32 589860, metadata !1, metadata !"int", metadata !1, > i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] > !6 = metadata !{i32 1, i32 0, metadata !0, null} > !7 = metadata !{i32 590080, metadata !0, metadata !"memtmp", metadata > !1, i32 2, metadata !8, i32 0} ; [ DW_TAG_auto_variable ] > !8 = metadata !{i32 589877, metadata !1, metadata !"", metadata !1, > i32 0, i64 32, i64 32, i64 0, i32 0, metadata !5} ; [ > DW_TAG_volatile_type ] > !9 = metadata !{i32 2, i32 0, metadata !0, null} > !10 = metadata !{i32 3, i32 0, metadata !0, null} > !11 = metadata !{i32 4, i32 0, metadata !0, null} > > =======> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev