Issue 66184
Summary [Opt diff]undefined reference to `f2'
Labels new issue
Assignees
Reporter LRY89757
    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)
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to