Merge pull request #82798 from eeckstein/fix-let-property-lowering

LetPropertyLowering: remove redundant phis after ssa-update
This commit is contained in:
nate-chandler
2025-07-08 18:07:08 -07:00
committed by GitHub
7 changed files with 59 additions and 1 deletions

View File

@@ -371,6 +371,8 @@ struct BridgedPassContext {
BRIDGED_INLINE void SSAUpdater_addAvailableValue(BridgedBasicBlock block, BridgedValue value) const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedValue SSAUpdater_getValueAtEndOfBlock(BridgedBasicBlock block) const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedValue SSAUpdater_getValueInMiddleOfBlock(BridgedBasicBlock block) const;
BRIDGED_INLINE SwiftInt SSAUpdater_getNumInsertedPhis() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedValue SSAUpdater_getInsertedPhi(SwiftInt idx) const;
// Options

View File

@@ -555,6 +555,14 @@ BridgedValue BridgedPassContext::SSAUpdater_getValueInMiddleOfBlock(BridgedBasic
invocation->getSSAUpdater()->getValueInMiddleOfBlock(block.unbridged())};
}
SwiftInt BridgedPassContext::SSAUpdater_getNumInsertedPhis() const {
return (SwiftInt)invocation->getInsertedPhisBySSAUpdater().size();
}
BridgedValue BridgedPassContext::SSAUpdater_getInsertedPhi(SwiftInt idx) const {
return {invocation->getInsertedPhisBySSAUpdater()[idx]};
}
bool BridgedPassContext::enableStackProtection() const {
swift::SILModule *mod = invocation->getPassManager()->getModule();
return mod->getOptions().EnableStackProtection;

View File

@@ -75,6 +75,7 @@ class SwiftPassInvocation {
SILModule::SlabList allocatedSlabs;
SILSSAUpdater *ssaUpdater = nullptr;
SmallVector<SILPhiArgument *, 4> insertedPhisBySSAUpdater;
SwiftPassInvocation *nestedSwiftPassInvocation = nullptr;
@@ -178,8 +179,9 @@ public:
void initializeSSAUpdater(SILFunction *fn, SILType type,
ValueOwnershipKind ownership) {
insertedPhisBySSAUpdater.clear();
if (!ssaUpdater)
ssaUpdater = new SILSSAUpdater;
ssaUpdater = new SILSSAUpdater(&insertedPhisBySSAUpdater);
ssaUpdater->initialize(fn, type, ownership);
}
@@ -188,6 +190,8 @@ public:
return ssaUpdater;
}
ArrayRef<SILPhiArgument *> getInsertedPhisBySSAUpdater() { return insertedPhisBySSAUpdater; }
SwiftPassInvocation *initializeNestedSwiftPassInvocation(SILFunction *newFunction) {
assert(!nestedSwiftPassInvocation && "Nested Swift pass invocation already initialized");
nestedSwiftPassInvocation = new SwiftPassInvocation(passManager, transform, newFunction);