@@ -285,7 +285,7 @@ class SILInlineCloner
285
285
// / This location wraps the call site AST node that is being inlined.
286
286
// / Alternatively, it can be the SIL file location of the call site (in case
287
287
// / of SIL-to-SIL transformations).
288
- Optional< SILLocation> Loc;
288
+ SILLocation Loc;
289
289
const SILDebugScope *CallSiteScope = nullptr ;
290
290
llvm::SmallDenseMap<const SILDebugScope *, const SILDebugScope *, 8 >
291
291
InlinedScopeCache;
@@ -338,9 +338,7 @@ class SILInlineCloner
338
338
return InLoc;
339
339
// Inlined location wraps the call site that is being inlined, regardless
340
340
// of the input location.
341
- return Loc.has_value ()
342
- ? Loc.value ()
343
- : MandatoryInlinedLocation ();
341
+ return Loc;
344
342
}
345
343
346
344
const SILDebugScope *remapScope (const SILDebugScope *DS) {
@@ -387,6 +385,16 @@ SILInliner::inlineFullApply(FullApplySite apply,
387
385
appliedArgs);
388
386
}
389
387
388
+ static SILLocation selectLoc (bool mandatory, SILLocation orig) {
389
+ // Compute the SILLocation which should be used by all the inlined
390
+ // instructions.
391
+ if (mandatory)
392
+ return MandatoryInlinedLocation (orig);
393
+ else {
394
+ return InlinedLocation (orig);
395
+ }
396
+ }
397
+
390
398
SILInlineCloner::SILInlineCloner (
391
399
SILFunction *calleeFunction, FullApplySite apply,
392
400
SILOptFunctionBuilder &funcBuilder, InlineKind inlineKind,
@@ -395,7 +403,8 @@ SILInlineCloner::SILInlineCloner(
395
403
: SuperTy(*apply.getFunction(), *calleeFunction, applySubs,
396
404
/* DT=*/ nullptr, /* Inlining=*/ true),
397
405
FuncBuilder(funcBuilder), IKind(inlineKind), Apply(apply),
398
- deleter(deleter) {
406
+ deleter(deleter),
407
+ Loc(selectLoc(inlineKind == InlineKind::MandatoryInline, apply.getLoc())) {
399
408
400
409
SILFunction &F = getBuilder ().getFunction ();
401
410
assert (apply.getFunction () && apply.getFunction () == &F
@@ -408,15 +417,6 @@ SILInlineCloner::SILInlineCloner(
408
417
&& " Cannot inline Objective-C methods or C functions in mandatory "
409
418
" inlining" );
410
419
411
- // Compute the SILLocation which should be used by all the inlined
412
- // instructions.
413
- if (IKind == InlineKind::PerformanceInline)
414
- Loc = InlinedLocation (apply.getLoc ());
415
- else {
416
- assert (IKind == InlineKind::MandatoryInline && " Unknown InlineKind." );
417
- Loc = MandatoryInlinedLocation (apply.getLoc ());
418
- }
419
-
420
420
auto applyScope = apply.getDebugScope ();
421
421
// FIXME: Turn this into an assertion instead.
422
422
if (!applyScope)
@@ -436,7 +436,7 @@ SILInlineCloner::SILInlineCloner(
436
436
assert (CallSiteScope->getParentFunction () == &F);
437
437
438
438
// Set up the coroutine-specific inliner if applicable.
439
- BeginApply = BeginApplySite::get (apply, Loc. value () , &getBuilder ());
439
+ BeginApply = BeginApplySite::get (apply, Loc, &getBuilder ());
440
440
}
441
441
442
442
// Clone the entire callee function into the caller function at the apply site.
0 commit comments