Skip to content

Commit 6cce554

Browse files
committed
[DebugInfo] [AutoDiff] Strip var info for tangents
1 parent 81a1510 commit 6cce554

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/SILOptimizer/Differentiation/JVPCloner.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,16 @@ class JVPCloner::Implementation final
10001000
/// Tangent: tan[y] = alloc_stack $T.Tangent
10011001
CLONE_AND_EMIT_TANGENT(AllocStack, asi) {
10021002
auto &diffBuilder = getDifferentialBuilder();
1003+
auto varInfo = asi->getVarInfo();
1004+
if (varInfo) {
1005+
// This is a new variable, it shouldn't keep the old scope, type, etc.
1006+
varInfo->Type = {};
1007+
varInfo->DIExpr = {};
1008+
varInfo->Loc = {};
1009+
varInfo->Scope = nullptr;
1010+
}
10031011
auto *mappedAllocStackInst = diffBuilder.createAllocStack(
1004-
asi->getLoc(), getRemappedTangentType(asi->getElementType()),
1005-
asi->getVarInfo());
1012+
asi->getLoc(), getRemappedTangentType(asi->getElementType()), varInfo);
10061013
setTangentBuffer(asi->getParent(), asi, mappedAllocStackInst);
10071014
}
10081015

lib/SILOptimizer/Differentiation/PullbackCloner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ class PullbackCloner::Implementation final
665665
}
666666
adjNameStream << " (scope #" << origBB->getDebugID() << ")";
667667
dv.Name = adjName;
668+
// We have no meaningful debug location, and the type is different.
669+
dv.Scope = nullptr;
670+
dv.Loc = {};
671+
dv.Type = {};
672+
dv.DIExpr = {};
668673
return dv;
669674
}));
670675
return (insertion.first->getSecond() = newBuf);

0 commit comments

Comments
 (0)