|
28 | 28 | #include "swift/SIL/SILBuilder.h"
|
29 | 29 | #include "swift/SIL/SILDebugScope.h"
|
30 | 30 | #include "swift/SIL/SILModule.h"
|
| 31 | +#include "swift/SIL/SILProperty.h" |
31 | 32 | #include "swift/SIL/SILUndef.h"
|
32 | 33 |
|
33 | 34 | #include "llvm/ADT/Statistic.h"
|
@@ -2954,11 +2955,11 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) {
|
2954 | 2955 |
|
2955 | 2956 | assert(VId <= GlobalVars.size() && "invalid GlobalVar ID");
|
2956 | 2957 | auto &globalVarOrOffset = GlobalVars[VId-1];
|
2957 |
| - if (globalVarOrOffset.isComplete()) |
2958 |
| - return globalVarOrOffset; |
| 2958 | + if (globalVarOrOffset.isFullyDeserialized()) |
| 2959 | + return globalVarOrOffset.get(); |
2959 | 2960 |
|
2960 | 2961 | BCOffsetRAII restoreOffset(SILCursor);
|
2961 |
| - if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset)) |
| 2962 | + if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset.getOffset())) |
2962 | 2963 | MF->fatal(std::move(Err));
|
2963 | 2964 | llvm::Expected<llvm::BitstreamEntry> maybeEntry =
|
2964 | 2965 | SILCursor.advance(AF_DontPopBlockAtEnd);
|
@@ -3005,7 +3006,7 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) {
|
3005 | 3006 | None,
|
3006 | 3007 | dID ? cast<VarDecl>(MF->getDecl(dID)): nullptr);
|
3007 | 3008 | v->setLet(IsLet);
|
3008 |
| - globalVarOrOffset = v; |
| 3009 | + globalVarOrOffset.set(v, true /*isFullyDeserialized*/); |
3009 | 3010 | v->setDeclaration(IsDeclaration);
|
3010 | 3011 |
|
3011 | 3012 | if (Callback)
|
@@ -3104,11 +3105,11 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) {
|
3104 | 3105 | assert(VId <= VTables.size() && "invalid VTable ID");
|
3105 | 3106 | auto &vTableOrOffset = VTables[VId-1];
|
3106 | 3107 |
|
3107 |
| - if (vTableOrOffset.isComplete()) |
3108 |
| - return vTableOrOffset; |
| 3108 | + if (vTableOrOffset.isFullyDeserialized()) |
| 3109 | + return vTableOrOffset.get(); |
3109 | 3110 |
|
3110 | 3111 | BCOffsetRAII restoreOffset(SILCursor);
|
3111 |
| - if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset)) |
| 3112 | + if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset.getOffset())) |
3112 | 3113 | MF->fatal(std::move(Err));
|
3113 | 3114 | llvm::Expected<llvm::BitstreamEntry> maybeEntry =
|
3114 | 3115 | SILCursor.advance(AF_DontPopBlockAtEnd);
|
@@ -3205,7 +3206,7 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) {
|
3205 | 3206 | SILMod, theClass,
|
3206 | 3207 | Serialized ? IsSerialized : IsNotSerialized,
|
3207 | 3208 | vtableEntries);
|
3208 |
| - vTableOrOffset = vT; |
| 3209 | + vTableOrOffset.set(vT, true /*isFullyDeserialized*/); |
3209 | 3210 |
|
3210 | 3211 | if (Callback) Callback->didDeserialize(MF->getAssociatedModule(), vT);
|
3211 | 3212 | return vT;
|
@@ -3839,3 +3840,127 @@ bool SILDeserializer::invalidateFunction(SILFunction *F) {
|
3839 | 3840 | }
|
3840 | 3841 | return false;
|
3841 | 3842 | }
|
| 3843 | + |
| 3844 | +// Invalidate all cached SILGlobalVariable. |
| 3845 | +void SILDeserializer::invalidateGlobalVariableCache() { |
| 3846 | + for (auto &entry : GlobalVars) { |
| 3847 | + if (entry.isDeserialized()) { |
| 3848 | + entry.reset(); |
| 3849 | + } |
| 3850 | + } |
| 3851 | +} |
| 3852 | + |
| 3853 | +// Invalidate a specific cached GlobalVariable. |
| 3854 | +bool SILDeserializer::invalidateGlobalVariable(SILGlobalVariable *gv) { |
| 3855 | + for (auto &entry : GlobalVars) { |
| 3856 | + if (entry.isDeserialized() && entry.get() == gv) { |
| 3857 | + entry.reset(); |
| 3858 | + return true; |
| 3859 | + } |
| 3860 | + } |
| 3861 | + |
| 3862 | + return false; |
| 3863 | +} |
| 3864 | + |
| 3865 | +// Invalidate all cached SILVTable. |
| 3866 | +void SILDeserializer::invalidateVTableCache() { |
| 3867 | + for (auto &entry : VTables) { |
| 3868 | + if (entry.isDeserialized()) { |
| 3869 | + entry.reset(); |
| 3870 | + } |
| 3871 | + } |
| 3872 | +} |
| 3873 | + |
| 3874 | +// Invalidate a specific cached SILVTable. |
| 3875 | +bool SILDeserializer::invalidateVTable(SILVTable *v) { |
| 3876 | + for (auto &entry : VTables) { |
| 3877 | + if (entry.isDeserialized() && entry.get() == v) { |
| 3878 | + entry.reset(); |
| 3879 | + return true; |
| 3880 | + } |
| 3881 | + } |
| 3882 | + |
| 3883 | + return false; |
| 3884 | +} |
| 3885 | + |
| 3886 | +// Invalidate all cached SILWitnessTable. |
| 3887 | +void SILDeserializer::invalidateWitnessTableCache() { |
| 3888 | + for (auto &entry : WitnessTables) { |
| 3889 | + if (entry.isDeserialized()) { |
| 3890 | + entry.reset(); |
| 3891 | + } |
| 3892 | + } |
| 3893 | +} |
| 3894 | + |
| 3895 | +// Invalidate a specific cached SILWitnessTable. |
| 3896 | +bool SILDeserializer::invalidateWitnessTable(SILWitnessTable *wt) { |
| 3897 | + for (auto &entry : WitnessTables) { |
| 3898 | + if (entry.isDeserialized() && entry.get() == wt) { |
| 3899 | + entry.reset(); |
| 3900 | + return true; |
| 3901 | + } |
| 3902 | + } |
| 3903 | + return false; |
| 3904 | +} |
| 3905 | + |
| 3906 | +// Invalidate all cached SILDefaultWitnessTable. |
| 3907 | +void SILDeserializer::invalidateDefaultWitnessTableCache() { |
| 3908 | + for (auto &entry : DefaultWitnessTables) { |
| 3909 | + if (entry.isDeserialized()) { |
| 3910 | + entry.reset(); |
| 3911 | + } |
| 3912 | + } |
| 3913 | +} |
| 3914 | + |
| 3915 | +// Invalidate a specific cached SILDefaultWitnessTable. |
| 3916 | +bool SILDeserializer::invalidateDefaultWitnessTable( |
| 3917 | + SILDefaultWitnessTable *wt) { |
| 3918 | + for (auto &entry : DefaultWitnessTables) { |
| 3919 | + if (entry.isDeserialized() && entry.get() == wt) { |
| 3920 | + entry.reset(); |
| 3921 | + return true; |
| 3922 | + } |
| 3923 | + } |
| 3924 | + return false; |
| 3925 | +} |
| 3926 | + |
| 3927 | +// Invalidate all cached SILProperty. |
| 3928 | +void SILDeserializer::invalidatePropertyCache() { |
| 3929 | + for (auto &entry : Properties) { |
| 3930 | + if (entry.isDeserialized()) { |
| 3931 | + entry.reset(); |
| 3932 | + } |
| 3933 | + } |
| 3934 | +} |
| 3935 | + |
| 3936 | +// Invalidate a specific cached SILProperty. |
| 3937 | +bool SILDeserializer::invalidateProperty(SILProperty *p) { |
| 3938 | + for (auto &entry : Properties) { |
| 3939 | + if (entry.isDeserialized() && entry.get() == p) { |
| 3940 | + entry.reset(); |
| 3941 | + return true; |
| 3942 | + } |
| 3943 | + } |
| 3944 | + return false; |
| 3945 | +} |
| 3946 | + |
| 3947 | +// Invalidate all cached SILDifferentiabilityWitness. |
| 3948 | +void SILDeserializer::invalidateDifferentiabilityWitnessCache() { |
| 3949 | + for (auto &entry : DifferentiabilityWitnesses) { |
| 3950 | + if (entry.isDeserialized()) { |
| 3951 | + entry.reset(); |
| 3952 | + } |
| 3953 | + } |
| 3954 | +} |
| 3955 | + |
| 3956 | +// Invalidate a specific cached SILDifferentiabilityWitness. |
| 3957 | +bool SILDeserializer::invalidateDifferentiabilityWitness( |
| 3958 | + SILDifferentiabilityWitness *w) { |
| 3959 | + for (auto &entry : DifferentiabilityWitnesses) { |
| 3960 | + if (entry.isDeserialized() && entry.get() == w) { |
| 3961 | + entry.reset(); |
| 3962 | + return true; |
| 3963 | + } |
| 3964 | + } |
| 3965 | + return false; |
| 3966 | +} |
0 commit comments