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

    <tr>
        <th>Summary</th>
        <td>
            [Opt diff]undefined reference to `f2'
        </td>
    </tr>

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

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

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

<pre>
    the file before opt can be compiled but can't be linked, , but after `opt -O3`, it can be compiled and linked successfully.

```llvm
; Simplify the CFG of this function without touching the content of loops.
; This only deletes unreachable blocks; preheader/header update is left
; to `cleanup<simplifyCFG>`.
;
; ModuleID = 'example'

target triple = "x86_64-unknown-unknown"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

define i32 @f1 (i32  %a, i32 %b) {
entry:
  br label %cond_block

cond_block:
  %cond = icmp slt i32 %a, 0
  br i1 %cond, label %then_block, label %else_block

then_block:
  br label %cond_block

else_block:
  %a1 = add i32 %a, 1
  br label %cond_block

unreachable_block:              ; This block is intentionally unreachable
  ret i32 %b
}

declare i32 @f2 (i32, i32)

define i32 @main() {
entry:
  %a = call i32 @f1(i32 0, i32 1)
  %b = call i32 @f2(i32 %a, i32 2)
  ret i32 %b
}
```

error:
```
/usr/bin/ld: /home/runyu/projects/JIT-parser/bug_analysis/LoopFusePass_oneshot_0_2.py_LoopFusePass_oneshot_0_no_source_prompt3/exe_before_opt.o: in function `main':
LoopFusePass_oneshot_0_2.py.ll:(.text+0x25): undefined reference to `f2'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVVuPozYU_jXOy1EiMITLQx6yk7LaaqutuvvSJ2TMIbhjbOTLTPLvKxMykI522koEiM_9nI_vMGvFWSEeyP4T2Z82zLtem8PXP_4synyfbxrdXg-uR-iERGiw0wZBjw44U9Ag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