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
26 changes: 26 additions & 0 deletions src/target/llvm/codegen_llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,32 @@ void CodeGenLLVM::AddDebugInformation(llvm::Value* llvm_value, const Var& tir_va

auto* di_loc = llvm::DILocation::get(*llvm_target_->GetContext(), 0, 0, di_subprogram_);

#if TVM_LLVM_VERSION >= 150
// LLVM 15+ requires dbg_declare to reference pointer or integer types only.
Comment thread
MasterJH5574 marked this conversation as resolved.
// For non-pointer types (floats, vectors), use dbg_value instead to track
// the SSA value directly rather than a memory location.
if (!llvm_value->getType()->isPointerTy()) {
if (insert_before) {
// LLVM 20+ changed insertDbgValueIntrinsic to take BasicBlock::iterator
// instead of Instruction* for the insertion point.
#if TVM_LLVM_VERSION >= 200
dbg_info_->di_builder_->insertDbgValueIntrinsic(
llvm_value, local_var, dbg_info_->di_builder_->createExpression(), llvm::DebugLoc(di_loc),
llvm::BasicBlock::iterator(insert_before));
#else
dbg_info_->di_builder_->insertDbgValueIntrinsic(llvm_value, local_var,
dbg_info_->di_builder_->createExpression(),
llvm::DebugLoc(di_loc), insert_before);
#endif
} else {
dbg_info_->di_builder_->insertDbgValueIntrinsic(
llvm_value, local_var, dbg_info_->di_builder_->createExpression(), llvm::DebugLoc(di_loc),
builder_->GetInsertBlock());
}
return;
}
#endif

if (insert_before) {
#if TVM_LLVM_VERSION >= 200
dbg_info_->di_builder_->insertDeclare(
Expand Down
5 changes: 4 additions & 1 deletion tests/python/codegen/test_gpu_codegen_allreduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import tvm
import tvm_ffi
import tvm.testing
import numpy as np
from tvm.script import tir as T
Expand Down Expand Up @@ -96,7 +97,9 @@ def optional_metal_compile_callback(define_metal_compile_callback):

@tvm.register_global_func(name, override=True)
def compile_metal(src, target):
return tvm.contrib.xcode.compile_metal(src, sdk="macosx")
from tvm.contrib.xcode import compile_metal # pylint: disable=import-outside-toplevel

return compile_metal(src, sdk="macosx")

yield

Expand Down
2 changes: 1 addition & 1 deletion tests/python/codegen/test_target_codegen_metal.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def compile_metal(src, target):

mod = tvm.IRModule({"main": func})

f = tvm.compile(mod, target="metal")
f = tvm.tir.build(mod, target="metal")
src: str = f.imports[0].inspect_source()
occurrences = src.count("struct func_kernel_args_t")
assert occurrences == 1, occurrences
Expand Down
Loading