@@ -3047,10 +3047,12 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
30473047 return success ();
30483048}
30493049
3050- // / Checks if a kill location holds metadata instead of an SSA value.
3051- static bool isMetadataKillLocation (bool isKillLocation, llvm::Value *value) {
3052- if (!isKillLocation)
3050+ // / Checks if `dbgIntr` is a kill location that holds metadata instead of an SSA
3051+ // / value.
3052+ static bool isMetadataKillLocation (llvm::DbgVariableIntrinsic *dbgIntr) {
3053+ if (!dbgIntr->isKillLocation ())
30533054 return false ;
3055+ llvm::Value *value = dbgIntr->getArgOperand (0 );
30543056 auto *nodeAsVal = dyn_cast<llvm::MetadataAsValue>(value);
30553057 if (!nodeAsVal)
30563058 return false ;
@@ -3095,23 +3097,13 @@ static LogicalResult setDebugIntrinsicBuilderInsertionPoint(
30953097
30963098std::tuple<DILocalVariableAttr, DIExpressionAttr, Value>
30973099ModuleImport::processDebugOpArgumentsAndInsertionPt (
3098- Location loc, bool hasArgList, bool isKillLocation,
3100+ Location loc,
30993101 llvm::function_ref<FailureOr<Value>()> convertArgOperandToValue,
31003102 llvm::Value *address,
31013103 llvm::PointerUnion<llvm::Value *, llvm::DILocalVariable *> variable,
31023104 llvm::DIExpression *expression, DominanceInfo &domInfo) {
3103- // Drop debug intrinsics with arg lists.
3104- // TODO: Support debug intrinsics that have arg lists.
3105- if (hasArgList)
3106- return {};
3107- // Kill locations can have metadata nodes as location operand. This
3108- // cannot be converted to poison as the type cannot be reconstructed.
3109- // TODO: find a way to support this case.
3110- if (isMetadataKillLocation (isKillLocation, address))
3111- return {};
3112- // Drop debug intrinsics if the associated variable information cannot be
3113- // translated due to cyclic debug metadata.
3114- // TODO: Support cyclic debug metadata.
3105+ // Drop debug intrinsics if the associated debug information cannot be
3106+ // translated due to an unsupported construct.
31153107 DILocalVariableAttr localVarAttr = matchLocalVariableAttr (variable);
31163108 if (!localVarAttr)
31173109 return {};
@@ -3144,10 +3136,21 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
31443136 return convertMetadataValue (dbgIntr->getArgOperand (0 ));
31453137 };
31463138
3139+ // Drop debug intrinsics with an argument list.
3140+ // TODO: Support this case.
3141+ if (dbgIntr->hasArgList ())
3142+ return emitUnsupportedWarning ();
3143+
3144+ // Drop debug intrinsics with kill locations that have metadata nodes as
3145+ // location operand, which cannot be converted to poison as the type cannot be
3146+ // reconstructed.
3147+ // TODO: Support this case.
3148+ if (isMetadataKillLocation (dbgIntr))
3149+ return emitUnsupportedWarning ();
3150+
31473151 auto [localVariableAttr, locationExprAttr, locVal] =
31483152 processDebugOpArgumentsAndInsertionPt (
3149- loc, dbgIntr->hasArgList (), dbgIntr->isKillLocation (),
3150- convertArgOperandToValue, dbgIntr->getArgOperand (0 ),
3153+ loc, convertArgOperandToValue, dbgIntr->getArgOperand (0 ),
31513154 dbgIntr->getArgOperand (1 ), dbgIntr->getExpression (), domInfo);
31523155
31533156 if (!localVariableAttr)
@@ -3203,11 +3206,21 @@ LogicalResult ModuleImport::processDebugRecord(llvm::DbgRecord &debugRecord,
32033206 return failure ();
32043207 };
32053208
3209+ // Drop debug records with an argument list.
3210+ // TODO: Support this case.
3211+ if (dbgVar->hasArgList ())
3212+ return emitUnsupportedWarning ();
3213+
3214+ // Drop kill location debug records with a null address operand, which cannot
3215+ // be converted to poison as the type cannot be reconstructed.
3216+ // TODO: Support this case.
3217+ if (!dbgVar->getAddress ())
3218+ return emitUnsupportedWarning ();
3219+
32063220 auto [localVariableAttr, locationExprAttr, locVal] =
32073221 processDebugOpArgumentsAndInsertionPt (
3208- loc, dbgVar->hasArgList (), dbgVar->isKillLocation (),
3209- convertArgOperandToValue, dbgVar->getAddress (), dbgVar->getVariable (),
3210- dbgVar->getExpression (), domInfo);
3222+ loc, convertArgOperandToValue, dbgVar->getAddress (),
3223+ dbgVar->getVariable (), dbgVar->getExpression (), domInfo);
32113224
32123225 if (!localVariableAttr)
32133226 return emitUnsupportedWarning ();
0 commit comments