Skip to content

Commit e38da06

Browse files
committed
Stash debugging changes
1 parent 2ac715c commit e38da06

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

lib/IRGen/AllocStackHoisting.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ void HoistAllocStack::hoist() {
421421
/// Try to hoist generic alloc_stack instructions to the entry block.
422422
/// Returns true if the function was changed.
423423
bool HoistAllocStack::run() {
424+
llvm::errs() << "Running hoist alloc stack on: " << F->getName() << "\n";
425+
424426
collectHoistableInstructions();
425427

426428
// Nothing to hoist?
@@ -441,6 +443,7 @@ class AllocStackHoisting : public SILFunctionTransform {
441443
if (Changed) {
442444
PM->invalidateAnalysis(F, SILAnalysis::InvalidationKind::Instructions);
443445
}
446+
llvm::errs() << "Completed alloc stack hoisting pass.\n";
444447
}
445448
};
446449
} // end anonymous namespace

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ void SILPassManager::runPassOnFunction(unsigned TransIdx, SILFunction *F) {
407407
Mod->registerDeleteNotificationHandler(SFT);
408408
if (breakBeforeRunning(F->getName(), SFT))
409409
LLVM_BUILTIN_DEBUGTRAP;
410+
llvm::errs() << "Running SIL pass: " << SFT->getID() << "\n";
411+
llvm::errs() << "Function named: " << F->getName() << "\n";
412+
F->getLocation().dump(F->getModule().getSourceManager());
413+
llvm::errs() << "***** \n";
414+
410415
SFT->run();
411416
assert(analysesUnlocked() && "Expected all analyses to be unlocked!");
412417
Mod->removeDeleteNotificationHandler(SFT);

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ struct ConcreteArgumentCopy {
791791
assert(!paramInfo.isIndirectMutating()
792792
&& "A mutated opened existential value can't be replaced");
793793

794+
if (!paramInfo.isConsumed())
795+
return None;
796+
794797
SILValue origArg = apply.getArgument(argIdx);
795798
// FIXME_opaque: With SIL opaque values, a formally indirect argument may be
796799
// passed as a SIL object. In this case, generate a copy_value for the new
@@ -821,6 +824,7 @@ struct ConcreteArgumentCopy {
821824
} else {
822825
// Otherwise, we probably got the value from the source of a store
823826
// instruction so, create a store into the temporary argument.
827+
B.createStrongRetain(loc, CEI.ConcreteValue, B.getDefaultAtomicity());
824828
B.createStore(loc, CEI.ConcreteValue, ASI,
825829
StoreOwnershipQualifier::Unqualified);
826830
}
@@ -856,6 +860,11 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
856860
const llvm::SmallDenseMap<unsigned, ConcreteOpenedExistentialInfo> &COAIs,
857861
SILBuilderContext &BuilderCtx) {
858862

863+
// Bail on try_apply.
864+
// TODO: support try_apply.
865+
if (isa<TryApplyInst>(Apply))
866+
return nullptr;
867+
859868
// Ensure that the callee is polymorphic.
860869
assert(Apply.getOrigCalleeType()->isPolymorphic());
861870

@@ -898,6 +907,8 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
898907
if (argSub) {
899908
concreteArgCopies.push_back(*argSub);
900909
NewArgs.push_back(argSub->tempArg);
910+
} else {
911+
NewArgs.clear();
901912
}
902913
} else {
903914
// Otherwise, we can just use the value itself.
@@ -936,15 +947,9 @@ SILInstruction *SILCombiner::createApplyWithConcreteType(
936947
}
937948
// Now create the new apply instruction.
938949
SILBuilderWithScope ApplyBuilder(Apply.getInstruction(), BuilderCtx);
939-
FullApplySite NewApply;
940-
if (auto *TAI = dyn_cast<TryApplyInst>(Apply))
941-
NewApply = ApplyBuilder.createTryApply(
942-
Apply.getLoc(), Apply.getCallee(), NewCallSubs, NewArgs,
943-
TAI->getNormalBB(), TAI->getErrorBB());
944-
else
945-
NewApply = ApplyBuilder.createApply(
946-
Apply.getLoc(), Apply.getCallee(), NewCallSubs, NewArgs,
947-
cast<ApplyInst>(Apply)->isNonThrowing());
950+
FullApplySite NewApply = ApplyBuilder.createApply(
951+
Apply.getLoc(), Apply.getCallee(), NewCallSubs, NewArgs,
952+
cast<ApplyInst>(Apply)->isNonThrowing());
948953

949954
if (auto NewAI = dyn_cast<ApplyInst>(NewApply))
950955
replaceInstUsesWith(*cast<ApplyInst>(Apply.getInstruction()), NewAI);

lib/Sema/TypeChecker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,14 @@ swift::handleSILGenericParams(GenericParamList *genericParams,
559559
auto genericParams = nestedList[i];
560560
genericParams->setDepth(i);
561561
}
562-
562+
llvm::errs() << "Checking generic sig...";
563563
auto sig =
564564
TypeChecker::checkGenericSignature(nestedList.back(), DC,
565565
/*parentSig=*/nullptr,
566566
/*allowConcreteGenericParams=*/true);
567-
return (sig ? sig->getGenericEnvironment() : nullptr);
567+
auto out = (sig ? sig->getGenericEnvironment() : nullptr);
568+
llvm::errs() << "done.\n";
569+
return out;
568570
}
569571

570572
void swift::typeCheckPatternBinding(PatternBindingDecl *PBD,

0 commit comments

Comments
 (0)