@@ -1185,10 +1185,13 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
11851185 // processed by coro::salvageDebugInfo() by the Cloner. However, convert
11861186 // it to a dbg.declare to make sure future passes don't have to deal
11871187 // with a dbg.coroframe_entry.
1188+ auto *VAM = ValueAsMetadata::get (CurrentReload);
1189+ Type *Ty = VAM->getValue ()->getType ();
11881190 DbgVariableRecord *NewDVR = new DbgVariableRecord (
11891191 ValueAsMetadata::get (CurrentReload), DDI->getVariable (),
11901192 DDI->getExpression (), DDI->getDebugLoc (),
1191- DbgVariableRecord::LocationType::Declare);
1193+ Ty->isPointerTy () ? DbgVariableRecord::LocationType::Declare
1194+ : DbgVariableRecord::LocationType::Value);
11921195 Builder.GetInsertPoint ()->getParent ()->insertDbgRecordBefore (
11931196 NewDVR, Builder.GetInsertPoint ());
11941197 // This dbg.coroframe_entry is for the main function entry point. It
@@ -2060,8 +2063,16 @@ void coro::salvageDebugInfo(
20602063 // If there is a dbg.coroframe_entry being reinserted, insert it as a
20612064 // dbg.declare instead, so that subsequent passes don't have to deal with
20622065 // a dbg.coroframe_entry.
2063- if (DVR.getType () == DbgVariableRecord::LocationType::CoroFrameEntry)
2064- DVR.Type = DbgVariableRecord::LocationType::Declare;
2066+ if (DVR.getType () == DbgVariableRecord::LocationType::CoroFrameEntry) {
2067+ auto *MD = DVR.getRawLocation ();
2068+ if (auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
2069+ Type *Ty = VAM->getValue ()->getType ();
2070+ if (Ty->isPointerTy ())
2071+ DVR.Type = DbgVariableRecord::LocationType::Declare;
2072+ else
2073+ DVR.Type = DbgVariableRecord::LocationType::Value;
2074+ }
2075+ }
20652076 (*InsertPt)->getParent ()->insertDbgRecordBefore (&DVR, *InsertPt);
20662077 }
20672078 }
0 commit comments