Hi compiler experts,
In the TensorFlow branch, we needed to synthesize some SIL code, so we used the SILLocation of an existing SILInstruction to create new ones (
In an edge case, that existing SILLocation could have its LocationKind set to ReturnKind (because that instruction, a BranchInst, is originally lowered from a return stmt as in this test case https://github.com/apple/swift/blob/9501d3c27d98dba1ad29aaf4f44af707b5e17d94/test/TensorFlow/crashers.swift#L422), and function
getLogpLex() later gets inlined into
b118507040(), but the BranchInst still has SILLocation::LocationKind set to ReturnKind).
This later triggers a SILVerifier failure here (https://github.com/apple/swift/blob/80419c711dc9dcf895f81c75cc4902d69cd83be9/lib/SIL/SILVerifier.cpp#L853).
Our short-term fix is to make sure we use
RegularKind as the
SILLocation::LocationKind value when creating new SIL instructions (https://github.com/apple/swift/pull/20141/files#diff-6c665bbcb829249dae89733089bbb9b5), but we wonder whether the fix could be incomplete and/or cause other issues (e.g. the fix includes forking
SILLocation::setLocationKind(), and we don't understand why that function does a bitwise OR instead of overwriting the original location kind): https://github.com/apple/swift/pull/20141/files#diff-b36bbbe0204e771d6f65ae248bf0b391).
We are also in general curious of what LocationKind does. Any thoughts and suggestions? Thanks.