; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 ; RUN: llc -mtriple=riscv32-apple-none-macho < %s -verify-machineinstrs | FileCheck %s --check-prefixes=COMMON,DEFAULT ; RUN: llc -mtriple=riscv32-apple-none-macho < %s -relocation-model=static -verify-machineinstrs | FileCheck %s --check-prefixes=COMMON,STATIC define void @simple() nounwind { ; COMMON-LABEL: simple: ; COMMON: ; %bb.0: ; COMMON-NEXT: ret ret void } define void @call() nounwind { ; COMMON-LABEL: call: ; COMMON: ; %bb.0: ; COMMON-NEXT: addi sp, sp, -16 ; COMMON-NEXT: sw ra, 12(sp) ; 4-byte Folded Spill ; COMMON-NEXT: call _tail_call ; COMMON-NEXT: lw ra, 12(sp) ; 4-byte Folded Reload ; COMMON-NEXT: addi sp, sp, 16 ; COMMON-NEXT: ret call void @tail_call() ret void } define void @tail_call() nounwind { ; COMMON-LABEL: tail_call: ; COMMON: ; %bb.0: ; COMMON-NEXT: tail _call tail call void @call() ret void } @var = global i32 0 define ptr @direct_global() nounwind { ; DEFAULT-LABEL: direct_global: ; DEFAULT: ; %bb.0: ; DEFAULT-NEXT: Lpcrel_hi0: ; DEFAULT-NEXT: auipc a0, %pcrel_hi(_var) ; DEFAULT-NEXT: addi a0, a0, %pcrel_lo(Lpcrel_hi0) ; DEFAULT-NEXT: ret ; ; STATIC-LABEL: direct_global: ; STATIC: ; %bb.0: ; STATIC-NEXT: lui a0, %hi(_var) ; STATIC-NEXT: addi a0, a0, %lo(_var) ; STATIC-NEXT: ret ret ptr @var } ;; No GOTs in static CodeGen. @var2 = external global i32 define ptr @got_global() nounwind { ; DEFAULT-LABEL: got_global: ; DEFAULT: ; %bb.0: ; DEFAULT-NEXT: Lpcrel_hi1: ; DEFAULT-NEXT: auipc a0, %got_pcrel_hi(_var2) ; DEFAULT-NEXT: lw a0, %pcrel_lo(Lpcrel_hi1)(a0) ; DEFAULT-NEXT: ret ; ; STATIC-LABEL: got_global: ; STATIC: ; %bb.0: ; STATIC-NEXT: lui a0, %hi(_var2) ; STATIC-NEXT: addi a0, a0, %lo(_var2) ; STATIC-NEXT: ret ret ptr @var2 } @anon = private unnamed_addr constant i32 42 define ptr @unnamed_const() nounwind { ; DEFAULT-LABEL: unnamed_const: ; DEFAULT: ; %bb.0: ; DEFAULT-NEXT: Lpcrel_hi2: ; DEFAULT-NEXT: auipc a0, %pcrel_hi(l_anon) ; DEFAULT-NEXT: addi a0, a0, %pcrel_lo(Lpcrel_hi2) ; DEFAULT-NEXT: ret ; ; STATIC-LABEL: unnamed_const: ; STATIC: ; %bb.0: ; STATIC-NEXT: lui a0, %hi(l_anon) ; STATIC-NEXT: addi a0, a0, %lo(l_anon) ; STATIC-NEXT: ret ret ptr @anon } ; UTC_ARGS: --disable ; COMMON-LABEL: l_anon: ; COMMON-NEXT: .word 42 ; COMMON-LABEL: .section __DATA,__data ; COMMON-LABEL: _addend: ; COMMON-NEXT: .word _simple+42 @addend = global i32 add(i32 ptrtoint(ptr @simple to i32), i32 42) ; COMMON-LABEL: _sub: ; COMMON-NEXT: .word _simple-_call @sub = global i32 sub(i32 ptrtoint(ptr @simple to i32), i32 ptrtoint(ptr @call to i32))