Skip to content

Commit 176efde

Browse files
committed
IRGen: Redo fill ops
Instead of recording the current offset in the template, just collect the fill ops into a vector and emit them at the generic argument offset stored in the MetadataLayout. For now this is NFC, but this allows the template to omit entries for generic arguments entirely once some more machinery is in place.
1 parent c19478a commit 176efde

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,8 +2758,6 @@ namespace {
27582758
struct FillOp {
27592759
CanType Type;
27602760
Optional<ProtocolConformanceRef> Conformance;
2761-
Size ToOffset;
2762-
bool IsRelative;
27632761
};
27642762

27652763
SmallVector<FillOp, 8> FillOps;
@@ -2836,7 +2834,10 @@ namespace {
28362834
// fill indexes are word-indexed.
28372835
Address metadataWords(IGF.Builder.CreateBitCast(metadataValue, IGM.Int8PtrPtrTy),
28382836
IGM.getPointerAlignment());
2839-
2837+
2838+
auto genericReqtOffset = IGM.getMetadataLayout(Target)
2839+
.getGenericRequirementsOffset(IGF);
2840+
28402841
for (auto &fillOp : FillOps) {
28412842
llvm::Value *value;
28422843
if (fillOp.Conformance) {
@@ -2846,20 +2847,12 @@ namespace {
28462847
}
28472848

28482849
auto dest = createPointerSizedGEP(IGF, metadataWords,
2849-
fillOp.ToOffset - AddressPoint);
2850+
genericReqtOffset.getStatic());
2851+
genericReqtOffset = genericReqtOffset.offsetBy(
2852+
IGF, IGM.getPointerSize());
28502853

2851-
// A far relative indirectable pointer.
2852-
if (fillOp.IsRelative) {
2853-
dest = IGF.Builder.CreateElementBitCast(dest,
2854-
IGM.FarRelativeAddressTy);
2855-
IGF.emitStoreOfRelativeIndirectablePointer(value, dest,
2856-
/*isFar*/ true);
2857-
2858-
// A direct pointer.
2859-
} else {
2860-
value = IGF.Builder.CreateBitCast(value, IGM.Int8PtrTy);
2861-
IGF.Builder.CreateStore(value, dest);
2862-
}
2854+
value = IGF.Builder.CreateBitCast(value, IGM.Int8PtrTy);
2855+
IGF.Builder.CreateStore(value, dest);
28632856
}
28642857

28652858
// Initialize the instantiated dependent value witness table, if we have
@@ -2894,12 +2887,6 @@ namespace {
28942887
return f;
28952888
}
28962889

2897-
void addFillOp(CanType type, Optional<ProtocolConformanceRef> conf,
2898-
bool isRelative) {
2899-
FillOps.push_back({type, conf, getNextOffsetFromTemplateHeader(),
2900-
isRelative });
2901-
}
2902-
29032890
public:
29042891
void createMetadataAccessFunction() {
29052892
(void) getGenericTypeMetadataAccessFunction(IGM, Target, ForDefinition);
@@ -2981,14 +2968,14 @@ namespace {
29812968

29822969
template <class... T>
29832970
void addGenericArgument(CanType type, T &&...args) {
2984-
addFillOp(type, None, /*relative*/ false);
2971+
FillOps.push_back({type, None});
29852972
super::addGenericArgument(type, std::forward<T>(args)...);
29862973
}
29872974

29882975
template <class... T>
29892976
void addGenericWitnessTable(CanType type, ProtocolConformanceRef conf,
29902977
T &&...args) {
2991-
addFillOp(type, conf, /*relative*/ false);
2978+
FillOps.push_back({type, conf});
29922979
super::addGenericWitnessTable(type, conf, std::forward<T>(args)...);
29932980
}
29942981

0 commit comments

Comments
 (0)