<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116924>116924</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            return out of __finally crashes compiler (Instruction referencing instruction not embedded in a basic block)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jaykrell
      </td>
    </tr>
</table>

<pre>
    Works fine with Visual C++.

```
int main()
{
    int a = 10;
    __try {
        a = 20;
 *(volatile char*)0;
        a = 30;
    }
    __finally
    {
 // Next line is not needed.
        //a = _abnormal_termination() ? 40 : 50;
        
        //goto A;
        
        return a;
    }

A:
    return a;
}

/*
1.c(16,9): warning: jump out of __finally block has undefined behavior [-Wjump-seh-finally]
 return a;
        ^
Instruction referencing instruction not embedded in a basic block!
  %a = call ptr @llvm.localrecover(ptr @main, ptr %frame_pointer, i32 0)
  <badref> = load i32, ptr %a, align 4
in function ?fin$0@0@main@@
fatal error: error in backend: Broken function found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
    0. Program arguments: ...
    1. <eof> parser at end of file
    2. Code generation
    3. Running pass 'Function Pass Manager' on module '1.c'.
    4. Running pass 'Module Verifier' on function '@"?fin$0@0@main@@"'
    clang-cl: error: clang frontend command failed with exit code 70 (use -v to see invocation)
*/
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVd-PozYQ_mucl9EiMLAkDzwk2Y1UqVedetLd42qwB-KLsZFtcrf_fWUgv7qnVqoaRWBmPs_Y33xjo_eqM0Q1K3esfFnhGI7W1d_x_eRI61Vj5Xv9zbqTh1YZgh8qHOGr8iNq2DO-Y3yXsPSFpdvl-Zwu_-lTmQA9KsP4mvHNAql28wAAIAIQWP4CWcryO8fbW3Dv8ICNv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