@@ -186,11 +186,16 @@ void CodeGenCPU::Init(const std::string& module_name, LLVMTarget* llvm_target, b
186186llvm::DISubprogram* CodeGenCPU::CreateDebugFunction (const PrimFunc& f) {
187187#if TVM_LLVM_VERSION >= 50
188188 llvm::SmallVector<llvm::Metadata*, 4 > paramTys;
189+
190+ paramTys.push_back (GetDebugType (f->ret_type ));
191+ for (const auto & param : f->params ) {
192+ paramTys.push_back (GetDebugType (GetType (param)));
193+ }
194+
189195 auto * DIFunctionTy = dbg_info_->di_builder_ ->createSubroutineType (
190196 dbg_info_->di_builder_ ->getOrCreateTypeArray (paramTys));
191197
192- // TODO(driazati): add the right argument info to the function
193- bool local_to_unit = false ;
198+ bool local_to_unit = llvm::GlobalVariable::isLocalLinkage (llvm::GlobalValue::InternalLinkage);
194199
195200#if TVM_LLVM_VERSION >= 80
196201 auto SPFlags = llvm::DISubprogram::toSPFlags (local_to_unit, /* IsDefinition=*/ true ,
@@ -207,14 +212,15 @@ llvm::DISubprogram* CodeGenCPU::CreateDebugFunction(const PrimFunc& f) {
207212 /* Flags=*/ llvm::DINode::FlagPrototyped, /* isOptimized=*/ true );
208213#endif
209214 return DIFunction;
215+ #else
216+ return nullptr ;
210217#endif
211218}
212219
213220void CodeGenCPU::AddFunction (const PrimFunc& f) {
214221#if TVM_LLVM_VERSION >= 50
215222 di_subprogram_ = CreateDebugFunction (f);
216223#endif
217-
218224 EmitDebugLocation (f->span );
219225 CodeGenLLVM::AddFunction (f);
220226 if (f_tvm_register_system_symbol_ != nullptr ) {
@@ -272,6 +278,9 @@ void CodeGenCPU::AddDebugInformation(PrimFunc f_tir, llvm::Function* f_llvm) {
272278#endif
273279}
274280
281+ llvm::DIType* CodeGenCPU::GetDebugType (const Type& ty_tir) {
282+ return GetDebugType (ty_tir, GetLLVMType (ty_tir));
283+ }
275284llvm::DIType* CodeGenCPU::GetDebugType (const Type& ty_tir, llvm::Type* ty_llvm) {
276285 if (ty_llvm == t_void_) {
277286 return nullptr ;
@@ -952,7 +961,6 @@ llvm::Value* CodeGenCPU::CreateCallPacked(const CallNode* op, bool use_string_lo
952961}
953962
954963llvm::Value* CodeGenCPU::CreateCallTracePacked (const CallNode* op) {
955- EmitDebugLocation (op);
956964 ICHECK_EQ (op->args .size (), 6U );
957965 PackedCall pc = MakeCallPackedLowered (op->args , op->dtype , op->args [3 ].as <IntImmNode>()->value ,
958966 op->args [4 ].as <IntImmNode>()->value , true );
@@ -1388,7 +1396,6 @@ void CodeGenCPU::AddStartupFunction() {
13881396}
13891397
13901398llvm::Value* CodeGenCPU::CreateIntrinsic (const CallNode* op) {
1391- EmitDebugLocation (op);
13921399 if (op->op .same_as (builtin::tvm_call_packed_lowered ())) {
13931400 return CreateCallPacked (op, true /* use_string_lookup */ );
13941401 } else if (op->op .same_as (builtin::tvm_call_trace_packed_lowered ())) {
0 commit comments