Skip to content

[RISC-V] Cannot relax auipc + jr after Machine Outliner #167381

@kvpanch

Description

@kvpanch

Consider following LLVM IR

target datalayout = "e-m:e-p:32:64-p1:32:64-i64:64-i128:128-n32:64-S64"
target triple = "riscv64-unknown--elf"

; Function Attrs: minsize
define i256 @func0() #0 {
entry:
  ret i256 0
}

; Function Attrs: minsize
define i256 @func1() #0 {
entry:
  ret i256 0
}

attributes #0 = { minsize }

Compiling it with llc -O3 test.ll -o test.s makes Machine Outliner to construct a function OUTLINED_FUNCTION_0 and add tail call to it to func0 and func1. This generates ELF file without

0000000000000000 <func0>:
       0: 00000317     	auipc	t1, 0x0
       4: 01030067     	jr	0x10(t1) <OUTLINED_FUNCTION_0>

0000000000000008 <func1>:
       8: 00000317     	auipc	t1, 0x0
       c: 00830067     	jr	0x8(t1) <OUTLINED_FUNCTION_0>

which cannot be relaxed as lld expects R_RISCV_CALL_PLT to be set.
For me it looks like something is not correct here.
One option to fix this is to use linkodronce linkage type for outlined function as comments states

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:RISC-VquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions