Skip to content

Commit 8816034

Browse files
committed
SILInliner: make SILInliner::Loc not an optional
It's not needed because it always has a value
1 parent 71c62c0 commit 8816034

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/SILOptimizer/Utils/SILInliner.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class SILInlineCloner
285285
/// This location wraps the call site AST node that is being inlined.
286286
/// Alternatively, it can be the SIL file location of the call site (in case
287287
/// of SIL-to-SIL transformations).
288-
Optional<SILLocation> Loc;
288+
SILLocation Loc;
289289
const SILDebugScope *CallSiteScope = nullptr;
290290
llvm::SmallDenseMap<const SILDebugScope *, const SILDebugScope *, 8>
291291
InlinedScopeCache;
@@ -338,9 +338,7 @@ class SILInlineCloner
338338
return InLoc;
339339
// Inlined location wraps the call site that is being inlined, regardless
340340
// of the input location.
341-
return Loc.has_value()
342-
? Loc.value()
343-
: MandatoryInlinedLocation();
341+
return Loc;
344342
}
345343

346344
const SILDebugScope *remapScope(const SILDebugScope *DS) {
@@ -387,6 +385,16 @@ SILInliner::inlineFullApply(FullApplySite apply,
387385
appliedArgs);
388386
}
389387

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+
390398
SILInlineCloner::SILInlineCloner(
391399
SILFunction *calleeFunction, FullApplySite apply,
392400
SILOptFunctionBuilder &funcBuilder, InlineKind inlineKind,
@@ -395,7 +403,8 @@ SILInlineCloner::SILInlineCloner(
395403
: SuperTy(*apply.getFunction(), *calleeFunction, applySubs,
396404
/*DT=*/nullptr, /*Inlining=*/true),
397405
FuncBuilder(funcBuilder), IKind(inlineKind), Apply(apply),
398-
deleter(deleter) {
406+
deleter(deleter),
407+
Loc(selectLoc(inlineKind == InlineKind::MandatoryInline, apply.getLoc())) {
399408

400409
SILFunction &F = getBuilder().getFunction();
401410
assert(apply.getFunction() && apply.getFunction() == &F
@@ -408,15 +417,6 @@ SILInlineCloner::SILInlineCloner(
408417
&& "Cannot inline Objective-C methods or C functions in mandatory "
409418
"inlining");
410419

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-
420420
auto applyScope = apply.getDebugScope();
421421
// FIXME: Turn this into an assertion instead.
422422
if (!applyScope)
@@ -436,7 +436,7 @@ SILInlineCloner::SILInlineCloner(
436436
assert(CallSiteScope->getParentFunction() == &F);
437437

438438
// Set up the coroutine-specific inliner if applicable.
439-
BeginApply = BeginApplySite::get(apply, Loc.value(), &getBuilder());
439+
BeginApply = BeginApplySite::get(apply, Loc, &getBuilder());
440440
}
441441

442442
// Clone the entire callee function into the caller function at the apply site.

0 commit comments

Comments
 (0)