swift
8cee0577 - [WIP] [AutoDiff] Fix AllocStack SILDebugVariable assertion failure.

Commit
6 years ago
[WIP] [AutoDiff] Fix AllocStack SILDebugVariable assertion failure. https://github.com/apple/swift/pull/27238 tightened debug info requirements, adding assertions to AllocStack and AllocBox constructors. This caused assertion failures for the differentiation transform, which does not provide SILDebugVariable when building AllocStack during differential/pullback generation: ``` Assertion failed: ((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) && "location is a VarDecl, but SILDebugVariable is empty"), function createAllocStack, file /Users/danielzheng/swift-merge/swift/include/swift/SIL/SILBuilder.h, line 407. Stack dump: ... 1. Swift version 5.1-dev (LLVM c5340df2d1, Swift 7bc4a06c32) 2. While running pass #56204 SILModuleTransform "Differentiation". swift::SILBuilder::createAllocStack(...) (anonymous namespace)::PullbackEmitter::getAdjointBuffer(...) ``` There are a few potential fixes: - Use `RegularLocation::getAutoGeneratedLocation()` so that the assertion does not trigger. This needs to be done for all `createAllocStack` invocations in Differentiation.cpp. - Find a way to provide the correct SILDebugVariable. This seems hard because SILDebugVariable is constructed during SILGen and has a particular "ArgNo" field that seems hard to compute. This is an initial minimal test to see if tensorflow/swift-apis compilation will pass. More changes are needed for a robust final fix: - Update all `createAllocStack` calls, including those in differential generation. - Add apple/swift tests.
Author
Committer
Parents
Loading