Skip to content

Commit 091a757

Browse files
committed
[CSStep] Allocate component scopes only if siblings didn't fail
If sibling components failed, there is no reason to establish new scope since remaining containers are not really going to be taken but fail fast instead.
1 parent c7181ee commit 091a757

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/Sema/CSStep.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ StepResult ComponentStep::take(bool prevFailed) {
253253
if (prevFailed || CS.getExpressionTooComplex(Solutions))
254254
return done(/*isSuccess=*/false);
255255

256+
// Setup active scope, only if previous component didn't fail.
257+
setupScope();
258+
256259
/// Try to figure out what this step is going to be,
257260
/// after the scope has been established.
258261
auto *disjunction = CS.selectDisjunction();

lib/Sema/CSStep.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,18 @@ class ComponentStep final : public SolverStep {
373373
OrphanedConstraint = constraint;
374374
}
375375

376-
void setup() override {
376+
StepResult take(bool prevFailed) override;
377+
StepResult resume(bool prevFailed) override;
378+
379+
// The number of disjunction constraints associated with this component.
380+
unsigned disjunctionCount() const { return NumDisjunctions; }
381+
382+
void print(llvm::raw_ostream &Out) override {
383+
Out << "ComponentStep with at #" << Index << '\n';
384+
}
385+
386+
private:
387+
void setupScope() {
377388
// If this is a single component, there is no need
378389
// to preliminary modify constraint system or log anything.
379390
if (IsSingle)
@@ -387,16 +398,6 @@ class ComponentStep final : public SolverStep {
387398
// let's return it ot the graph.
388399
CS.CG.setOrphanedConstraint(OrphanedConstraint);
389400
}
390-
391-
StepResult take(bool prevFailed) override;
392-
StepResult resume(bool prevFailed) override;
393-
394-
// The number of disjunction constraints associated with this component.
395-
unsigned disjunctionCount() const { return NumDisjunctions; }
396-
397-
void print(llvm::raw_ostream &Out) override {
398-
Out << "ComponentStep with at #" << Index << '\n';
399-
}
400401
};
401402

402403
template <typename P> class BindingStep : public SolverStep {

0 commit comments

Comments
 (0)