@@ -354,7 +354,7 @@ ModuleImport::ModuleImport(ModuleOp mlirModule,
354
354
mlirModule(mlirModule), llvmModule(std::move(llvmModule)),
355
355
iface(mlirModule->getContext ()),
356
356
typeTranslator(*mlirModule->getContext ()),
357
- debugImporter(std::make_unique<DebugImporter>(mlirModule-> getContext () )) {
357
+ debugImporter(std::make_unique<DebugImporter>(mlirModule)) {
358
358
builder.setInsertionPointToStart (mlirModule.getBody ());
359
359
}
360
360
@@ -636,13 +636,13 @@ LogicalResult ModuleImport::convertGlobals() {
636
636
globalVar.getName () == getGlobalDtorsVarName ()) {
637
637
if (failed (convertGlobalCtorsAndDtors (&globalVar))) {
638
638
return emitError (mlirModule.getLoc ())
639
- << " unhandled global variable " << diag (globalVar);
639
+ << " unhandled global variable: " << diag (globalVar);
640
640
}
641
641
continue ;
642
642
}
643
643
if (failed (convertGlobal (&globalVar))) {
644
644
return emitError (mlirModule.getLoc ())
645
- << " unhandled global variable " << diag (globalVar);
645
+ << " unhandled global variable: " << diag (globalVar);
646
646
}
647
647
}
648
648
return success ();
@@ -664,7 +664,9 @@ void ModuleImport::setNonDebugMetadataAttrs(llvm::Instruction *inst,
664
664
continue ;
665
665
if (failed (iface.setMetadataAttrs (builder, kind, node, op, *this ))) {
666
666
Location loc = debugImporter->translateLoc (inst->getDebugLoc ());
667
- emitWarning (loc) << " unhandled metadata (" << kind << " ) " << diag (*inst);
667
+ emitWarning (loc) << " unhandled metadata: "
668
+ << diagMD (node, llvmModule.get ()) << " on "
669
+ << diag (*inst);
668
670
}
669
671
}
670
672
}
@@ -967,8 +969,7 @@ ModuleImport::getConstantsToConvert(llvm::Constant *constant) {
967
969
}
968
970
969
971
FailureOr<Value> ModuleImport::convertConstant (llvm::Constant *constant) {
970
- // Constants have no location attached.
971
- Location loc = UnknownLoc::get (context);
972
+ Location loc = mlirModule.getLoc ();
972
973
973
974
// Convert constants that can be represented as attributes.
974
975
if (Attribute attr = getConstantAsAttr (constant)) {
@@ -1062,7 +1063,7 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
1062
1063
return root;
1063
1064
}
1064
1065
1065
- return emitError (loc) << " unhandled constant " << diag (*constant);
1066
+ return emitError (loc) << " unhandled constant: " << diag (*constant);
1066
1067
}
1067
1068
1068
1069
FailureOr<Value> ModuleImport::convertConstantExpr (llvm::Constant *constant) {
@@ -1107,10 +1108,10 @@ FailureOr<Value> ModuleImport::convertValue(llvm::Value *value) {
1107
1108
if (auto *constant = dyn_cast<llvm::Constant>(value))
1108
1109
return convertConstantExpr (constant);
1109
1110
1110
- Location loc = UnknownLoc::get (context );
1111
+ Location loc = mlirModule. getLoc ( );
1111
1112
if (auto *inst = dyn_cast<llvm::Instruction>(value))
1112
1113
loc = translateLoc (inst->getDebugLoc ());
1113
- return emitError (loc) << " unhandled value " << diag (*value);
1114
+ return emitError (loc) << " unhandled value: " << diag (*value);
1114
1115
}
1115
1116
1116
1117
FailureOr<SmallVector<Value>>
@@ -1187,7 +1188,7 @@ LogicalResult ModuleImport::convertIntrinsic(llvm::CallInst *inst) {
1187
1188
return success ();
1188
1189
1189
1190
Location loc = translateLoc (inst->getDebugLoc ());
1190
- return emitError (loc) << " unhandled intrinsic " << diag (*inst);
1191
+ return emitError (loc) << " unhandled intrinsic: " << diag (*inst);
1191
1192
}
1192
1193
1193
1194
LogicalResult ModuleImport::convertInstruction (llvm::Instruction *inst) {
@@ -1364,7 +1365,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
1364
1365
if (succeeded (convertInstructionImpl (builder, inst, *this )))
1365
1366
return success ();
1366
1367
1367
- return emitError (loc) << " unhandled instruction " << diag (*inst);
1368
+ return emitError (loc) << " unhandled instruction: " << diag (*inst);
1368
1369
}
1369
1370
1370
1371
LogicalResult ModuleImport::processInstruction (llvm::Instruction *inst) {
@@ -1432,7 +1433,7 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
1432
1433
builder.setInsertionPoint (mlirModule.getBody (), mlirModule.getBody ()->end ());
1433
1434
1434
1435
LLVMFuncOp funcOp = builder.create <LLVMFuncOp>(
1435
- UnknownLoc::get (context ), func->getName (), functionType,
1436
+ mlirModule. getLoc ( ), func->getName (), functionType,
1436
1437
convertLinkageFromLLVM (func->getLinkage ()), dsoLocal, cconv);
1437
1438
1438
1439
// Set the function debug information if available.
@@ -1471,8 +1472,7 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
1471
1472
if (FlatSymbolRefAttr personality = getPersonalityAsAttr (func))
1472
1473
funcOp.setPersonalityAttr (personality);
1473
1474
else if (func->hasPersonalityFn ())
1474
- emitWarning (UnknownLoc::get (context),
1475
- " could not deduce personality, skipping it" );
1475
+ emitWarning (funcOp.getLoc (), " could not deduce personality, skipping it" );
1476
1476
1477
1477
if (func->hasGC ())
1478
1478
funcOp.setGarbageCollector (StringRef (func->getGC ()));
@@ -1487,8 +1487,9 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
1487
1487
if (!iface.isConvertibleMetadata (kind))
1488
1488
continue ;
1489
1489
if (failed (iface.setMetadataAttrs (builder, kind, node, funcOp, *this ))) {
1490
- emitWarning (funcOp->getLoc ())
1491
- << " unhandled function metadata (" << kind << " ) " << diag (*func);
1490
+ emitWarning (funcOp.getLoc ())
1491
+ << " unhandled function metadata: " << diagMD (node, llvmModule.get ())
1492
+ << " on " << diag (*func);
1492
1493
}
1493
1494
}
1494
1495
@@ -1536,7 +1537,7 @@ LogicalResult ModuleImport::processBasicBlock(llvm::BasicBlock *bb,
1536
1537
setNonDebugMetadataAttrs (&inst, op);
1537
1538
} else if (inst.getOpcode () != llvm::Instruction::PHI) {
1538
1539
Location loc = debugImporter->translateLoc (inst.getDebugLoc ());
1539
- emitWarning (loc) << " dropped instruction " << diag (inst);
1540
+ emitWarning (loc) << " dropped instruction: " << diag (inst);
1540
1541
}
1541
1542
}
1542
1543
return success ();
0 commit comments