@@ -6601,25 +6601,27 @@ static Function *createOutlinedFunction(
6601
6601
DICompileUnit *CU = SP->getUnit ();
6602
6602
DIBuilder DB (*M, true , CU);
6603
6603
DebugLoc DL = Builder.getCurrentDebugLocation ();
6604
- // TODO: We are using nullopt for arguments at the moment. This will need
6605
- // to be updated when debug data is being generated for variables.
6606
- DISubroutineType *Ty =
6607
- DB.createSubroutineType (DB.getOrCreateTypeArray (std::nullopt));
6608
- DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagDefinition |
6609
- DISubprogram::SPFlagOptimized |
6610
- DISubprogram::SPFlagLocalToUnit;
6611
-
6612
- DISubprogram *OutlinedSP = DB.createFunction (
6613
- CU, FuncName, FuncName, SP->getFile (), DL.getLine (), Ty, DL.getLine (),
6614
- DINode::DIFlags::FlagArtificial, SPFlags);
6615
-
6616
- // Attach subprogram to the function.
6617
- Func->setSubprogram (OutlinedSP);
6618
- // Update the CurrentDebugLocation in the builder so that right scope
6619
- // is used for things inside outlined function.
6620
- Builder.SetCurrentDebugLocation (
6621
- DILocation::get (Func->getContext (), DL.getLine (), DL.getCol (),
6622
- OutlinedSP, DL.getInlinedAt ()));
6604
+ if (DL) {
6605
+ // TODO: We are using nullopt for arguments at the moment. This will
6606
+ // need to be updated when debug data is being generated for variables.
6607
+ DISubroutineType *Ty =
6608
+ DB.createSubroutineType (DB.getOrCreateTypeArray (std::nullopt));
6609
+ DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagDefinition |
6610
+ DISubprogram::SPFlagOptimized |
6611
+ DISubprogram::SPFlagLocalToUnit;
6612
+
6613
+ DISubprogram *OutlinedSP = DB.createFunction (
6614
+ CU, FuncName, FuncName, SP->getFile (), DL.getLine (), Ty,
6615
+ DL.getLine (), DINode::DIFlags::FlagArtificial, SPFlags);
6616
+
6617
+ // Attach subprogram to the function.
6618
+ Func->setSubprogram (OutlinedSP);
6619
+ // Update the CurrentDebugLocation in the builder so that right scope
6620
+ // is used for things inside outlined function.
6621
+ Builder.SetCurrentDebugLocation (
6622
+ DILocation::get (Func->getContext (), DL.getLine (), DL.getCol (),
6623
+ OutlinedSP, DL.getInlinedAt ()));
6624
+ }
6623
6625
}
6624
6626
}
6625
6627
0 commit comments