mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AutoDiff] Bump-pointer allocate pullback structs in loops. (#34886)
In derivatives of loops, no longer allocate boxes for indirect case payloads. Instead, use a custom pullback context in the runtime which contains a bump-pointer allocator. When a function contains a differentiated loop, the closure context is a `Builtin.NativeObject`, which contains a `swift::AutoDiffLinearMapContext` and a tail-allocated top-level linear map struct (which represents the linear map struct that was previously directly partial-applied into the pullback). In branching trace enums, the payloads of previously indirect cases will be allocated by `swift::AutoDiffLinearMapContext::allocate` and stored as a `Builtin.RawPointer`.
This commit is contained in:
@@ -1677,7 +1677,7 @@ private:
|
||||
} // end anonymous namespace
|
||||
|
||||
namespace {
|
||||
static bool isTopLevelContext(const DeclContext *DC) {
|
||||
static bool isTopLevelSubcontext(const DeclContext *DC) {
|
||||
for (; DC && DC->isLocalContext(); DC = DC->getParent()) {
|
||||
switch (DC->getContextKind()) {
|
||||
case DeclContextKind::TopLevelCodeDecl:
|
||||
@@ -2139,7 +2139,7 @@ public:
|
||||
if (CurrDeclContext && D->getModuleContext() == CurrModule) {
|
||||
// Treat global variables from the same source file as local when
|
||||
// completing at top-level.
|
||||
if (isa<VarDecl>(D) && isTopLevelContext(CurrDeclContext) &&
|
||||
if (isa<VarDecl>(D) && isTopLevelSubcontext(CurrDeclContext) &&
|
||||
D->getDeclContext()->getParentSourceFile() ==
|
||||
CurrDeclContext->getParentSourceFile()) {
|
||||
return SemanticContextKind::Local;
|
||||
|
||||
Reference in New Issue
Block a user