Skip to content

Commit 5e73426

Browse files
committed
runtime: add runtime functions for stack promotion of buffers.
These functions are usually lowered away, but can remain if SIL optimizations run but not llvm optimizations. This is only a workaround. I hope that I can remove the functions soon when we have a better support for buffers in SIL.
1 parent a6aedec commit 5e73426

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

stdlib/public/runtime/HeapObject.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ extern "C" HeapObject* swift_bufferAllocate(
104104
return swift::swift_allocObject(bufferType, size, alignMask);
105105
}
106106

107+
/// \brief Another entrypoint for swift_bufferAllocate.
108+
/// It is generated by the compiler in some corner cases, e.g. if an serialized
109+
/// optimzed module is imported into a non-optimized main module.
110+
/// TODO: This is only a workaround. Remove this function as soon as we can
111+
/// get rid of the llvm SwiftStackPromotion pass.
112+
extern "C" HeapObject* swift_bufferAllocateOnStack(
113+
HeapMetadata const* bufferType, size_t size, size_t alignMask) {
114+
return swift::swift_allocObject(bufferType, size, alignMask);
115+
}
116+
117+
/// \brief Called at the end of the lifetime of an object returned by
118+
/// swift_bufferAllocateOnStack.
119+
/// It is generated by the compiler in some corner cases, e.g. if an serialized
120+
/// optimzed module is imported into a non-optimized main module.
121+
/// TODO: This is only a workaround. Remove this function as soon as we can
122+
/// get rid of the llvm SwiftStackPromotion pass.
123+
extern "C" void swift_bufferDeallocateFromStack(HeapObject *) {
124+
}
125+
107126
extern "C" intptr_t swift_bufferHeaderSize() { return sizeof(HeapObject); }
108127

109128
/// A do-nothing destructor for POD metadata.

0 commit comments

Comments
 (0)