Skip to content

Commit 4dc0801

Browse files
author
Joe Shajrawi
committed
IRGen Mandatory Module Pass: Pass large loadable types by address instead of by value
1 parent 0d0cac3 commit 4dc0801

File tree

17 files changed

+1946
-102
lines changed

17 files changed

+1946
-102
lines changed

include/swift/IRGen/IRGenSILPasses.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
namespace swift {
1414

15-
class SILFunctionTransform;
15+
class SILTransform;
1616

1717
namespace irgen {
1818

1919
/// Create a pass to hoist alloc_stack instructions with non-fixed size.
20-
SILFunctionTransform *createAllocStackHoisting();
20+
SILTransform *createAllocStackHoisting();
21+
SILTransform *createLoadableByAddress();
2122

2223
} // end namespace irgen
2324
} // end namespace swift

include/swift/SIL/SILFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ class SILFunction
239239
/// or return instructions; you need to do that yourself
240240
/// if you care.
241241
///
242-
/// This is a hack and should be removed!
242+
/// This routine does not update all the references in the module
243+
/// You have to do that yourself
243244
void rewriteLoweredTypeUnsafe(CanSILFunctionType newType) {
244-
assert(canBeDeleted());
245245
LoweredType = newType;
246246
}
247247

include/swift/SILOptimizer/PassManager/PassManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SILPassManager {
9999

100100

101101
/// The IRGen SIL passes. These have to be dynamically added by IRGen.
102-
llvm::DenseMap<unsigned, SILFunctionTransform *> IRGenPasses;
102+
llvm::DenseMap<unsigned, SILTransform *> IRGenPasses;
103103

104104
public:
105105
/// C'tor. It creates and registers all analysis passes, which are defined
@@ -247,7 +247,7 @@ class SILPassManager {
247247
}
248248
}
249249

250-
void registerIRGenPass(PassKind Kind, SILFunctionTransform *Transform) {
250+
void registerIRGenPass(PassKind Kind, SILTransform *Transform) {
251251
assert(IRGenPasses.find(unsigned(Kind)) == IRGenPasses.end() &&
252252
"Pass already registered");
253253
assert(

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ PASS(ReleaseHoisting, "release-hoisting",
222222
"SIL release Hoisting")
223223
PASS(LateReleaseHoisting, "late-release-hoisting",
224224
"Late SIL release Hoisting Preserving Epilogues")
225+
IRGEN_PASS(LoadableByAddress, "loadable-address",
226+
"SIL Loadable type by-address lowering.")
225227
PASS(RemovePins, "remove-pins",
226228
"Remove SIL pin/unpin pairs")
227229
PASS(SideEffectsDumper, "side-effects-dump",

include/swift/SILOptimizer/PassManager/Transforms.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ namespace swift {
6666
/// Inject the pass manager running this pass.
6767
void injectPassManager(SILPassManager *PMM) { PM = PMM; }
6868

69+
irgen::IRGenModule *getIRGenModule() {
70+
auto *Mod = PM->getIRGenModule();
71+
assert(Mod && "Expecting a valid module");
72+
return Mod;
73+
}
74+
6975
/// Get the name of the transform.
7076
llvm::StringRef getName() { return PassKindName(getPassKind()); }
7177

@@ -116,12 +122,6 @@ namespace swift {
116122
protected:
117123
SILFunction *getFunction() { return F; }
118124

119-
irgen::IRGenModule *getIRGenModule() {
120-
auto *Mod = PM->getIRGenModule();
121-
assert(Mod && "Expecting a valid module");
122-
return Mod;
123-
}
124-
125125
void invalidateAnalysis(SILAnalysis::InvalidationKind K) {
126126
PM->invalidateAnalysis(F, K);
127127
}

lib/IRGen/AllocStackHoisting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,6 @@ class AllocStackHoisting : public SILFunctionTransform {
427427
};
428428
} // end anonymous namespace
429429

430-
SILFunctionTransform *irgen::createAllocStackHoisting() {
430+
SILTransform *irgen::createAllocStackHoisting() {
431431
return new AllocStackHoisting();
432432
}

lib/IRGen/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ add_swift_library(swiftIRGen STATIC
3838
IRGenModule.cpp
3939
IRGenSIL.cpp
4040
Linking.cpp
41+
LoadableByAddress.cpp
4142
LocalTypeData.cpp
4243
StructLayout.cpp
4344
SwiftTargetInfo.cpp

0 commit comments

Comments
 (0)