@@ -16,12 +16,23 @@ LLVM.Module("SomeModule", ctx) do mod
1616 cu_md = LLVM. compileunit! (dibuilder, cu)
1717
1818 Builder (ctx) do builder
19- ft = LLVM. FunctionType (LLVM. VoidType (ctx), [LLVM. Int32Type (ctx)])
19+ ft = LLVM. FunctionType (LLVM. VoidType (ctx), [LLVM. Int64Type (ctx)])
20+ rt_md = LLVM. basictype! (dibuilder, " Nothing" , 0 , 0 )
21+ param_md = LLVM. basictype! (dibuilder, " Int64" , sizeof (Int64), 0 )
22+ dift_md = LLVM. subroutinetype! (dibuilder, file_md, rt_md, param_md)
2023 fn = LLVM. Function (mod, " SomeFunction" , ft)
24+ difn = DISubprogram (LLVM. name (fn), " linkage" , file_md, 3 , dift_md, true , true , 5 , LLVM. API. LLVMDIFlagPublic, false )
25+ difn_md = LLVM. subprogram! (dibuilder, difn)
26+ LLVM. set_subprogram! (fn, difn_md)
2127
2228 entrybb = BasicBlock (fn, " entry" )
2329 position! (builder, entrybb)
2430
31+ ptr = inttoptr! (builder, parameters (fn)[1 ], LLVM. PointerType (LLVM. Int64Type (ctx)))
32+ ptr_md = LLVM. pointertype! (dibuilder, param_md, sizeof (Ptr{Int64}), LLVM. addrspace (llvmtype (ptr)), 0 , " MyPtr" )
33+ # TODO : LLVM.dbg_declare!(builder, mod, ptr, ptr_md)
34+ val = ptrtoint! (builder, ptr, LLVM. Int64Type (ctx))
35+
2536 block = DILexicalBlock (file_md, 1 , 1 )
2637 block_md = LLVM. lexicalblock! (dibuilder, file_md, block) # could also be file
2738 debuglocation! (builder, LLVM. MetadataAsValue (LLVM. API. LLVMMetadataAsValue (ctx, block_md)))
@@ -33,11 +44,10 @@ LLVM.Module("SomeModule", ctx) do mod
3344
3445 fun = functions (mod)[" SomeFunction" ]
3546 bb = entry (fun)
36- inst = first (instructions (bb))
47+ inst = last (instructions (bb))
3748 @test ! isempty (metadata (inst))
3849 inst_str = sprint (io-> Base. show (io, inst))
3950 @test occursin (" !dbg" , inst_str)
40- @show mod inst
4151
4252 @test ! isempty (metadata (inst))
4353 mod_str = sprint (io-> Base. show (io, mod))
@@ -46,6 +56,9 @@ LLVM.Module("SomeModule", ctx) do mod
4656 @test occursin (" !DIFile" , mod_str)
4757 @test occursin (" !DILexicalBlock" , mod_str)
4858 @test ! occursin (" scope: null" , mod_str)
59+ @test occursin (" DISubprogram" , mod_str)
60+ @test occursin (" DISubroutineType" , mod_str)
61+ @test occursin (" DIBasicType" , mod_str)
4962
5063 strip_debuginfo! (mod)
5164 @test isempty (metadata (inst))
0 commit comments