Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8114] [TensorFlow] Compilation without -O causes SIL verification failure #50646

Closed
dan-zheng opened this issue Jun 26, 2018 · 3 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-8114
Radar None
Original Reporter @dan-zheng
Type Bug
Status Resolved
Resolution Cannot Reproduce
Additional Detail from JIRA
Votes 0
Component/s Swift for TensorFlow
Labels Bug
Assignee @dan-zheng
Priority Medium

md5: b3e27e2b5b69e3d8b4bc35357bf221ee

relates to:

  • SR-14298 [AutoDiff] SIL verification failed: non-contiguous lexical scope at -Onone

Issue Description:

After syncing with master (5/2), compiling any program with Tensor code without `-O` causes a SIL verification error:

// crash.swift
import TensorFlow
let t = Tensor(1)
$ swift crash2.swift
SIL verification failed: Basic block contains a non-contiguous lexical scope at -Onone: DS == LastSeenScope
Verifying instruction:
     %18 = struct $Int32 (%17 : $Builtin.Int32)   // user: %20
->   return %18 : $Int32                          // id: %20
In function:
// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  alloc_global @$S6crash21x10TensorFlow0B0VySdGvp // id: %2
  %3 = global_addr @$S6crash21x10TensorFlow0B0VySdGvp : $*Tensor<Double> // user: %19
  %4 = float_literal $Builtin.FPIEEE64, 0x3FF0000000000000 // 1 // user: %5
  %5 = builtin "__tfop_tfc.scalarToTensor,$in"(%4 : $Builtin.FPIEEE64) : $TensorHandle<Double> // users: %16, %15, %10, %8, %9
  %6 = alloc_stack $Tensor<Double>                // users: %7, %11, %14
  %7 = struct_element_addr %6 : $*Tensor<Double>, #Tensor.handle // user: %8
  store %5 to %7 : $*TensorHandle<Double>         // id: %8
  %9 = struct $Tensor<Double> (%5 : $TensorHandle<Double>) // user: %19
  strong_retain %5 : $TensorHandle<Double>        // id: %10
  %11 = load %6 : $*Tensor<Double>                // user: %12
  %12 = struct_extract %11 : $Tensor<Double>, #Tensor.handle // user: %13
  strong_release %12 : $TensorHandle<Double>      // id: %13
  dealloc_stack %6 : $*Tensor<Double>             // id: %14
  strong_retain %5 : $TensorHandle<Double>        // id: %15
  strong_release %5 : $TensorHandle<Double>       // id: %16
  %17 = integer_literal $Builtin.Int32, 0         // user: %18
  %18 = struct $Int32 (%17 : $Builtin.Int32)      // user: %20
  store %9 to %3 : $*Tensor<Double>               // id: %19
  return %18 : $Int32                             // id: %20
} // end sil function 'main'

0  swift                    0x000000010a16a4e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010a16abf6 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff6485cf5a _sigtramp + 26
3  libsystem_platform.dylib 0x000000010f0d0688 _sigtramp + 2860988232
4  libsystem_c.dylib        0x00007fff64687312 abort + 127
5  swift                    0x00000001076d2bfa (anonymous namespace)::SILVerifier::_require(bool, llvm::Twine const&, std::__1::function<void ()> const&) + 490
6  swift                    0x00000001076d734c (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 2348
7  swift                    0x00000001076d4ec7 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 8903
8  swift                    0x00000001076d1fec swift::SILModule::verify() const + 236
9  swift                    0x000000010693184f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13007
10 swift                    0x000000010692d576 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3318
11 swift                    0x00000001068e9ffd main + 2317

Prior to the 5/2 downstream, running just swift crash.swift worked.

This crash is replicable with the 6/25 pre-built packages.

@dan-zheng
Copy link
Collaborator Author

Fixed in #17797 by skipping debug scope verification for instructions with inlined call sites. Eventually, verifyDebugScopeHoles should verify inline call sites as well to ensure that the inliner handles scopes correctly.

@dan-zheng
Copy link
Collaborator Author

Reopening this issue: relaxing the debug scope verification rules didn't fix all cases.

Here's another crasher:

// crash.swift
import TensorFlow
func test() {
  print(Tensor(1))
}
$ swift crash.swift
SIL verification failed: Basic block contains a non-contiguous lexical scope at -Onone: DS == LastSeenScope

Full crash dump here.

@dan-zheng
Copy link
Collaborator Author

Cannot reproduce as of current tensorflow branch HEAD.
1664a80

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. swift for tensorflow
Projects
None yet
Development

No branches or pull requests

1 participant