Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/crystal/codegen/codegen.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,7 @@ module Crystal
printf_args = {printf_args, [] of LLVM::Value} if printf_args.is_a?(String)
printf_args = {printf_args[0], [] of LLVM::Value} if printf_args.is_a?({String})
msg, args = printf_args
printf("<block: #{insert_block.name || "???"} @ #{Crystal.relative_filename(file)}:#{line}> #{msg}\n", args)
printf("<function=#{insert_block.parent.try(&.name) || "???"} block=#{insert_block.name || "???"} source=#{Crystal.relative_filename(file)}:#{line}> #{msg}\n", args)
end

# :ditto:
Expand Down
5 changes: 5 additions & 0 deletions src/llvm/basic_block.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ struct LLVM::BasicBlock
block_name = LibLLVM.get_basic_block_name(self)
block_name ? String.new(block_name) : nil
end

def parent : Function?
parent_func = LibLLVM.get_basic_block_parent(self)
parent_func ? Function.new(parent_func) : nil
end
end
1 change: 1 addition & 0 deletions src/llvm/lib_llvm/core.cr
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ lib LibLLVM
{% end %}

fun get_basic_block_name = LLVMGetBasicBlockName(bb : BasicBlockRef) : Char*
fun get_basic_block_parent = LLVMGetBasicBlockParent(bb : BasicBlockRef) : ValueRef
fun get_first_basic_block = LLVMGetFirstBasicBlock(fn : ValueRef) : BasicBlockRef
fun get_next_basic_block = LLVMGetNextBasicBlock(bb : BasicBlockRef) : BasicBlockRef
fun append_basic_block_in_context = LLVMAppendBasicBlockInContext(c : ContextRef, fn : ValueRef, name : Char*) : BasicBlockRef
Expand Down