|
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"
|
@@ -2937,11 +2938,11 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) {
|
2937 | 2938 |
|
2938 | 2939 | assert(VId <= GlobalVars.size() && "invalid GlobalVar ID");
|
2939 | 2940 | auto &globalVarOrOffset = GlobalVars[VId-1];
|
2940 |
| - if (globalVarOrOffset.isComplete()) |
2941 |
| - return globalVarOrOffset; |
| 2941 | + if (globalVarOrOffset.isFullyDeserialized()) |
| 2942 | + return globalVarOrOffset.get(); |
2942 | 2943 |
|
2943 | 2944 | BCOffsetRAII restoreOffset(SILCursor);
|
2944 |
| - if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset)) |
| 2945 | + if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset.getOffset())) |
2945 | 2946 | MF->fatal(std::move(Err));
|
2946 | 2947 | llvm::Expected<llvm::BitstreamEntry> maybeEntry =
|
2947 | 2948 | SILCursor.advance(AF_DontPopBlockAtEnd);
|
@@ -2988,7 +2989,7 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) {
|
2988 | 2989 | None,
|
2989 | 2990 | dID ? cast<VarDecl>(MF->getDecl(dID)): nullptr);
|
2990 | 2991 | v->setLet(IsLet);
|
2991 |
| - globalVarOrOffset = v; |
| 2992 | + globalVarOrOffset.set(v, true /*isFullyDeserialized*/); |
2992 | 2993 | v->setDeclaration(IsDeclaration);
|
2993 | 2994 |
|
2994 | 2995 | if (Callback)
|
@@ -3087,11 +3088,11 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) {
|
3087 | 3088 | assert(VId <= VTables.size() && "invalid VTable ID");
|
3088 | 3089 | auto &vTableOrOffset = VTables[VId-1];
|
3089 | 3090 |
|
3090 |
| - if (vTableOrOffset.isComplete()) |
3091 |
| - return vTableOrOffset; |
| 3091 | + if (vTableOrOffset.isFullyDeserialized()) |
| 3092 | + return vTableOrOffset.get(); |
3092 | 3093 |
|
3093 | 3094 | BCOffsetRAII restoreOffset(SILCursor);
|
3094 |
| - if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset)) |
| 3095 | + if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset.getOffset())) |
3095 | 3096 | MF->fatal(std::move(Err));
|
3096 | 3097 | llvm::Expected<llvm::BitstreamEntry> maybeEntry =
|
3097 | 3098 | SILCursor.advance(AF_DontPopBlockAtEnd);
|
@@ -3188,7 +3189,7 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) {
|
3188 | 3189 | SILMod, theClass,
|
3189 | 3190 | Serialized ? IsSerialized : IsNotSerialized,
|
3190 | 3191 | vtableEntries);
|
3191 |
| - vTableOrOffset = vT; |
| 3192 | + vTableOrOffset.set(vT, true /*isFullyDeserialized*/); |
3192 | 3193 |
|
3193 | 3194 | if (Callback) Callback->didDeserialize(MF->getAssociatedModule(), vT);
|
3194 | 3195 | return vT;
|
@@ -3819,3 +3820,127 @@ bool SILDeserializer::invalidateFunction(SILFunction *F) {
|
3819 | 3820 | }
|
3820 | 3821 | return false;
|
3821 | 3822 | }
|
| 3823 | + |
| 3824 | +// Invalidate all cached SILGlobalVariable. |
| 3825 | +void SILDeserializer::invalidateGlobalVariableCache() { |
| 3826 | + for (auto &entry : GlobalVars) { |
| 3827 | + if (entry.isDeserialized()) { |
| 3828 | + entry.reset(); |
| 3829 | + } |
| 3830 | + } |
| 3831 | +} |
| 3832 | + |
| 3833 | +// Invalidate a specific cached GlobalVariable. |
| 3834 | +bool SILDeserializer::invalidateGlobalVariable(SILGlobalVariable *gv) { |
| 3835 | + for (auto &entry : GlobalVars) { |
| 3836 | + if (entry.isDeserialized() && entry.get() == gv) { |
| 3837 | + entry.reset(); |
| 3838 | + return true; |
| 3839 | + } |
| 3840 | + } |
| 3841 | + |
| 3842 | + return false; |
| 3843 | +} |
| 3844 | + |
| 3845 | +// Invalidate all cached SILVTable. |
| 3846 | +void SILDeserializer::invalidateVTableCache() { |
| 3847 | + for (auto &entry : VTables) { |
| 3848 | + if (entry.isDeserialized()) { |
| 3849 | + entry.reset(); |
| 3850 | + } |
| 3851 | + } |
| 3852 | +} |
| 3853 | + |
| 3854 | +// Invalidate a specific cached SILVTable. |
| 3855 | +bool SILDeserializer::invalidateVTable(SILVTable *v) { |
| 3856 | + for (auto &entry : VTables) { |
| 3857 | + if (entry.isDeserialized() && entry.get() == v) { |
| 3858 | + entry.reset(); |
| 3859 | + return true; |
| 3860 | + } |
| 3861 | + } |
| 3862 | + |
| 3863 | + return false; |
| 3864 | +} |
| 3865 | + |
| 3866 | +// Invalidate all cached SILWitnessTable. |
| 3867 | +void SILDeserializer::invalidateWitnessTableCache() { |
| 3868 | + for (auto &entry : WitnessTables) { |
| 3869 | + if (entry.isDeserialized()) { |
| 3870 | + entry.reset(); |
| 3871 | + } |
| 3872 | + } |
| 3873 | +} |
| 3874 | + |
| 3875 | +// Invalidate a specific cached SILWitnessTable. |
| 3876 | +bool SILDeserializer::invalidateWitnessTable(SILWitnessTable *wt) { |
| 3877 | + for (auto &entry : WitnessTables) { |
| 3878 | + if (entry.isDeserialized() && entry.get() == wt) { |
| 3879 | + entry.reset(); |
| 3880 | + return true; |
| 3881 | + } |
| 3882 | + } |
| 3883 | + return false; |
| 3884 | +} |
| 3885 | + |
| 3886 | +// Invalidate all cached SILDefaultWitnessTable. |
| 3887 | +void SILDeserializer::invalidateDefaultWitnessTableCache() { |
| 3888 | + for (auto &entry : DefaultWitnessTables) { |
| 3889 | + if (entry.isDeserialized()) { |
| 3890 | + entry.reset(); |
| 3891 | + } |
| 3892 | + } |
| 3893 | +} |
| 3894 | + |
| 3895 | +// Invalidate a specific cached SILDefaultWitnessTable. |
| 3896 | +bool SILDeserializer::invalidateDefaultWitnessTable( |
| 3897 | + SILDefaultWitnessTable *wt) { |
| 3898 | + for (auto &entry : DefaultWitnessTables) { |
| 3899 | + if (entry.isDeserialized() && entry.get() == wt) { |
| 3900 | + entry.reset(); |
| 3901 | + return true; |
| 3902 | + } |
| 3903 | + } |
| 3904 | + return false; |
| 3905 | +} |
| 3906 | + |
| 3907 | +// Invalidate all cached SILProperty. |
| 3908 | +void SILDeserializer::invalidatePropertyCache() { |
| 3909 | + for (auto &entry : Properties) { |
| 3910 | + if (entry.isDeserialized()) { |
| 3911 | + entry.reset(); |
| 3912 | + } |
| 3913 | + } |
| 3914 | +} |
| 3915 | + |
| 3916 | +// Invalidate a specific cached SILProperty. |
| 3917 | +bool SILDeserializer::invalidateProperty(SILProperty *p) { |
| 3918 | + for (auto &entry : Properties) { |
| 3919 | + if (entry.isDeserialized() && entry.get() == p) { |
| 3920 | + entry.reset(); |
| 3921 | + return true; |
| 3922 | + } |
| 3923 | + } |
| 3924 | + return false; |
| 3925 | +} |
| 3926 | + |
| 3927 | +// Invalidate all cached SILDifferentiabilityWitness. |
| 3928 | +void SILDeserializer::invalidateDifferentiabilityWitnessCache() { |
| 3929 | + for (auto &entry : DifferentiabilityWitnesses) { |
| 3930 | + if (entry.isDeserialized()) { |
| 3931 | + entry.reset(); |
| 3932 | + } |
| 3933 | + } |
| 3934 | +} |
| 3935 | + |
| 3936 | +// Invalidate a specific cached SILDifferentiabilityWitness. |
| 3937 | +bool SILDeserializer::invalidateDifferentiabilityWitness( |
| 3938 | + SILDifferentiabilityWitness *w) { |
| 3939 | + for (auto &entry : DifferentiabilityWitnesses) { |
| 3940 | + if (entry.isDeserialized() && entry.get() == w) { |
| 3941 | + entry.reset(); |
| 3942 | + return true; |
| 3943 | + } |
| 3944 | + } |
| 3945 | + return false; |
| 3946 | +} |
0 commit comments