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

    <tr>
        <th>Summary</th>
        <td>
            bugpoint deletes second argument to `@llvm.stackprotector` and crashes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    ```llvm
; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackprotector(ptr, ptr) #11

; Function Attrs: noreturn nounwind sspstrong
define dso_local void @main() {
Entry:
  %StackGuardSlot = alloca ptr, align 8
  %StackGuard = load volatile ptr, ptr addrspace(257) inttoptr (i32 40 to ptr addrspace(257)), align 8
  call void @llvm.stackprotector(ptr %StackGuard, ptr %StackGuardSlot)
  ret void
}
```

```sh-session
$ ../zig-bootstrap/out/host/bin/bugpoint --version
LLVM (http://llvm.org/):
  LLVM version 15.0.3
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: haswell
$ ../zig-bootstrap/out/host/bin/bugpoint -run-llc a.ll
Read input file      : 'a.ll'
*** All input ok
Initializing execution environment: Found llc: /home/vexu/Documents/zig/zig-bootstrap/out/host/bin/llc
Running the code generator to test for a crash: <llc>
Generating reference output from raw program: <llc><llc><CC><program>
Reference output is: bugpoint.reference.out-8ac89f8

*** Checking the code generator...
<llc><CC><program>
*** Output matches: Debugging miscompilation!
Checking to see if '' compiles correctly: <llc><CC><program> yup.
*** Optimized program matches reference output!  No problem detected...
bugpoint can't help you with your problem!
*** Debugging code generator crash!

*** Attempting to reduce the number of function attributes in the testcase
<llc>
Checking for crash with changing conditionals to always jump to true: Entry: <llc>
Checking for crash with changing conditionals to always jump to false: Entry: <llc>
Checking for crash with only these blocks: Entry: <llc>
Checking for crash with CFG simplifying: Entry: <llc>
Checking for crash with only 3 instructions: <llc>

*** Attempting to reduce testcase by deleting instructions: Simplification Level #1
Checking instruction:   %StackGuardSlot = alloca ptr, align 8llvm.stackprotector parameter #2 must resolve to an alloca.
  call void @llvm.stackprotector(ptr %StackGuard, ptr null)
/home/vexu/Documents/zig/zig-bootstrap/out/host/bin/opt: bugpoint-input-cb3a27a.bc: error: input module is broken!
Instruction removal failed.  Sorry. :(  Please report a bug!
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVt1v2zYQ_2vsl4MFW45s-cEPqV13Bbq1WLC-FpR4kthQpMAPJ-5fvyMl2YmTrV07QzAp8Xj3u-8rND9tJ6t5_0h5bCfz_WR-O1m-gYNXpRNawa1zxk6Wt6B0yaQsWHlP28og0mJPqqTFqwehODwIKQ06b1TPh2MpmUE4asFhchMlJNYRh85oh6XTZpLmnaP_HcRlA5N0uVgMMP4VTC_oItzazjqjVT3KroRC4FZ_kQH4GUTLhCKpUdb6TU_8VjlzIrb9GxCI7C7AfOeZ4XdSO5gs90DaEycY8DIpagX5q1ciudSMk1TJnJAIFy2BcW5sx0okGGm2DkiEck6HM_oklinczMHpfyCOzwv5wTffN_RzmCOgF-oGEQNfMnNkOzhjvR82Y9Q8c9X40TYzi9aSx4aD9AaSZJIevol6VmjtyFOso3ftSdah0TYsRXDMofB1p8keMJsd0Vx4fPjw-fdgnsa5LrgqPdATFdWmjm-bJx6M1MN9WGTJPFmORx87J1rxDTkUXkiejN_3WDEvHThmanQhyB7z1ZfVzcyre6Uf1EwK5R9ntfLjjd8IN-w-_RVoG2YfUMpf0dd4kiFLYMnI50-kEBKq8w6qEETxF6RN0nWkStejwOGBWwqD_oa-78_eK-EERcs3oWrARyx9TCVUR0Hp0qKKuhI0SiIS37MnjC2F3OGIj56WvS59oLS9Tj-mWWDWq-GVCsJdg1BqjlCjQsMoKkOUOyQrVrRnUBpmmwhguYtQ3vYM3vX0gYfBCg2qEoEkRsMY3YJhD0ChXhvWPr_-ZLPb9euZ7u1o5CuOIlaY0S_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