@@ -16,12 +16,23 @@ LLVM.Module("SomeModule", ctx) do mod
16
16
cu_md = LLVM. compileunit! (dibuilder, cu)
17
17
18
18
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)
20
23
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)
21
27
22
28
entrybb = BasicBlock (fn, " entry" )
23
29
position! (builder, entrybb)
24
30
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
+
25
36
block = DILexicalBlock (file_md, 1 , 1 )
26
37
block_md = LLVM. lexicalblock! (dibuilder, file_md, block) # could also be file
27
38
debuglocation! (builder, LLVM. MetadataAsValue (LLVM. API. LLVMMetadataAsValue (ctx, block_md)))
@@ -33,11 +44,10 @@ LLVM.Module("SomeModule", ctx) do mod
33
44
34
45
fun = functions (mod)[" SomeFunction" ]
35
46
bb = entry (fun)
36
- inst = first (instructions (bb))
47
+ inst = last (instructions (bb))
37
48
@test ! isempty (metadata (inst))
38
49
inst_str = sprint (io-> Base. show (io, inst))
39
50
@test occursin (" !dbg" , inst_str)
40
- @show mod inst
41
51
42
52
@test ! isempty (metadata (inst))
43
53
mod_str = sprint (io-> Base. show (io, mod))
@@ -46,6 +56,9 @@ LLVM.Module("SomeModule", ctx) do mod
46
56
@test occursin (" !DIFile" , mod_str)
47
57
@test occursin (" !DILexicalBlock" , mod_str)
48
58
@test ! occursin (" scope: null" , mod_str)
59
+ @test occursin (" DISubprogram" , mod_str)
60
+ @test occursin (" DISubroutineType" , mod_str)
61
+ @test occursin (" DIBasicType" , mod_str)
49
62
50
63
strip_debuginfo! (mod)
51
64
@test isempty (metadata (inst))
0 commit comments