Skip to content

Commit 1d6c7c5

Browse files
author
Joe Shajrawi
authored
Merge pull request #12953 from shajrawi/copyaddr_outline_part2_v3
Code size: copy_addr outline - Support Archetypes
2 parents 012cc4a + f6781de commit 1d6c7c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1052
-664
lines changed

docs/ABI/Mangling.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ Globals
8383
global ::= type 'We' // Outlined Consume Function Type
8484
global ::= type 'Wr' // Outlined Retain Function Type
8585
global ::= type 'Ws' // Outlined Release Function Type
86-
global ::= type 'Wb' // Outlined InitializeWithTake Function Type
87-
global ::= type 'Wc' // Outlined InitializeWithCopy Function Type
88-
global ::= type 'Wd' // Outlined AssignWithTake Function Type
89-
global ::= type 'Wf' // Outlined AssignWithCopy Function Type
86+
global ::= type 'Wb' INDEX // Outlined InitializeWithTake Function Type
87+
global ::= type 'Wc' INDEX // Outlined InitializeWithCopy Function Type
88+
global ::= type 'Wd' INDEX // Outlined AssignWithTake Function Type
89+
global ::= type 'Wf' INDEX // Outlined AssignWithCopy Function Type
9090

9191
assoc_type_path ::= identifier '_' identifier*
9292

lib/Demangling/Demangler.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,20 +1692,24 @@ NodePointer Demangler::demangleWitness() {
16921692
popNode(Node::Kind::Type));
16931693
}
16941694
case 'b': {
1695-
return createWithChild(Node::Kind::OutlinedInitializeWithTake,
1696-
popNode(Node::Kind::Type));
1695+
NodePointer IndexChild = demangleIndexAsNode();
1696+
return createWithChildren(Node::Kind::OutlinedInitializeWithTake,
1697+
popNode(Node::Kind::Type), IndexChild);
16971698
}
16981699
case 'c': {
1699-
return createWithChild(Node::Kind::OutlinedInitializeWithCopy,
1700-
popNode(Node::Kind::Type));
1700+
NodePointer IndexChild = demangleIndexAsNode();
1701+
return createWithChildren(Node::Kind::OutlinedInitializeWithCopy,
1702+
popNode(Node::Kind::Type), IndexChild);
17011703
}
17021704
case 'd': {
1703-
return createWithChild(Node::Kind::OutlinedAssignWithTake,
1704-
popNode(Node::Kind::Type));
1705+
NodePointer IndexChild = demangleIndexAsNode();
1706+
return createWithChildren(Node::Kind::OutlinedAssignWithTake,
1707+
popNode(Node::Kind::Type), IndexChild);
17051708
}
17061709
case 'f': {
1707-
return createWithChild(Node::Kind::OutlinedAssignWithCopy,
1708-
popNode(Node::Kind::Type));
1710+
NodePointer IndexChild = demangleIndexAsNode();
1711+
return createWithChildren(Node::Kind::OutlinedAssignWithCopy,
1712+
popNode(Node::Kind::Type), IndexChild);
17091713
}
17101714

17111715
default:

lib/Demangling/Remangler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,23 +1755,27 @@ void Remangler::mangleOutlinedRelease(Node *node) {
17551755
}
17561756

17571757
void Remangler::mangleOutlinedInitializeWithTake(Node *node) {
1758-
mangleSingleChildNode(node);
1758+
mangleChildNode(node, 0);
17591759
Buffer << "Wb";
1760+
mangleChildNode(node, 1);
17601761
}
17611762

17621763
void Remangler::mangleOutlinedInitializeWithCopy(Node *node) {
1763-
mangleSingleChildNode(node);
1764+
mangleChildNode(node, 0);
17641765
Buffer << "Wc";
1766+
mangleChildNode(node, 1);
17651767
}
17661768

17671769
void Remangler::mangleOutlinedAssignWithTake(Node *node) {
1768-
mangleSingleChildNode(node);
1770+
mangleChildNode(node, 0);
17691771
Buffer << "Wd";
1772+
mangleChildNode(node, 1);
17701773
}
17711774

17721775
void Remangler::mangleOutlinedAssignWithCopy(Node *node) {
1773-
mangleSingleChildNode(node);
1776+
mangleChildNode(node, 0);
17741777
Buffer << "Wf";
1778+
mangleChildNode(node, 1);
17751779
}
17761780

17771781
void Remangler::mangleOutlinedVariable(Node *node) {

lib/IRGen/CallEmission.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ class CallEmission {
7373
}
7474

7575
/// Set the arguments to the function from an explosion.
76-
void setArgs(Explosion &arg, WitnessMetadata *witnessMetadata = nullptr);
77-
76+
void setArgs(Explosion &arg, bool isOutlined,
77+
WitnessMetadata *witnessMetadata = nullptr);
78+
7879
void addAttribute(unsigned Index, llvm::Attribute::AttrKind Attr);
7980

80-
void emitToMemory(Address addr, const LoadableTypeInfo &substResultTI);
81-
void emitToExplosion(Explosion &out);
81+
void emitToMemory(Address addr, const LoadableTypeInfo &substResultTI,
82+
bool isOutlined);
83+
void emitToExplosion(Explosion &out, bool isOutlined);
8284
};
8385

8486

lib/IRGen/FixedTypeInfo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class FixedTypeInfo : public TypeInfo {
8383

8484
// We can give these reasonable default implementations.
8585

86-
void initializeWithTake(IRGenFunction &IGF, Address destAddr,
87-
Address srcAddr, SILType T) const override;
86+
void initializeWithTake(IRGenFunction &IGF, Address destAddr, Address srcAddr,
87+
SILType T, bool isOutlined) const override;
8888

8989
llvm::Value *getSize(IRGenFunction &IGF, SILType T) const override;
9090
llvm::Value *getAlignmentMask(IRGenFunction &IGF, SILType T) const override;
@@ -228,6 +228,13 @@ class FixedTypeInfo : public TypeInfo {
228228
llvm::Value *vwtable,
229229
SILType T) const override {}
230230

231+
void collectArchetypeMetadata(
232+
IRGenFunction &IGF,
233+
llvm::MapVector<CanType, llvm::Value *> &typeToMetadataVec,
234+
SILType T) const override {
235+
return;
236+
}
237+
231238
llvm::Value *getEnumTagSinglePayload(IRGenFunction &IGF,
232239
llvm::Value *numEmptyCases,
233240
Address enumAddr,

lib/IRGen/GenArchetype.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ class OpaqueArchetypeTypeInfo
9191
static const OpaqueArchetypeTypeInfo *create(llvm::Type *type) {
9292
return new OpaqueArchetypeTypeInfo(type);
9393
}
94+
95+
void collectArchetypeMetadata(
96+
IRGenFunction &IGF,
97+
llvm::MapVector<CanType, llvm::Value *> &typeToMetadataVec,
98+
SILType T) const override {
99+
auto canType = T.getSwiftRValueType();
100+
if (typeToMetadataVec.find(canType) != typeToMetadataVec.end()) {
101+
return;
102+
}
103+
auto *metadata = IGF.emitTypeMetadataRef(canType);
104+
assert(metadata && "Expected Type Metadata Ref");
105+
typeToMetadataVec.insert(std::make_pair(canType, metadata));
106+
}
94107
};
95108

96109
/// A type implementation for a class archetype, that is, an archetype

0 commit comments

Comments
 (0)