llvm-project/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll
Amy Kwan 25d709e72c
[SystemZ] Emit external aliases for indirect function descriptors in the ADA section (#183443)
This is the last of the three patches aimed to support indirect symbol
handling for the SystemZ backend.

An external alias is emitted for indirect function descriptors within
the ADA section, rather than a temporary alias, while also setting all
of the appropriate symbol attributes that are needed for the HLASM
streamer to emit the correct XATTR and ALIAS instructions for the
indirect symbols.

Moreover, this patch updates the
`CodeGen/SystemZ/zos-ada-relocations.ll` test as the ADA section is
currently the only user of indirect symbols on z/OS.

Depends on https://github.com/llvm/llvm-project/pull/183442.
2026-02-27 14:02:00 -05:00

78 lines
2.1 KiB
LLVM

; Test the ADA section in the assembly output for all cases.
;
; RUN: llc < %s -mtriple=s390x-ibm-zos | FileCheck %s
; CHECK-LABEL: DoIt DS 0H
; CHECK: stmg 6,7,1840(4)
; CHECK: aghi 4,-224
; CHECK: lg 1,0(5)
; CHECK: lg 6,16(5)
; CHECK: lg 5,8(5)
; CHECK: stg 1,2264(4)
; CHECK: basr 7,6
; CHECK: bcr 0,0
; CHECK: lg 7,2072(4)
; CHECK: aghi 4,224
; CHECK: b 2(7)
define hidden void @DoIt() {
entry:
%F = alloca ptr, align 8
store ptr @DoFunc, ptr %F, align 8
%0 = load ptr, ptr %F, align 8
call void @Caller(ptr noundef %0)
ret void
}
declare void @DoFunc()
declare void @Caller(ptr noundef)
; CHECK-LABEL: get_i DS 0H
; CHECK: stmg 6,8,1872(4)
; CHECK: aghi 4,-192
; CHECK: lg 1,24(5)
; CHECK: lg 2,32(5)
; CHECK: lgf 1,0(1)
; CHECK: lg 6,48(5)
; CHECK: lg 5,40(5)
; CHECK: l 8,0(2)
; CHECK: basr 7,6
; CHECK: bcr 0,0
; CHECK: ar 3,8
; CHECK: lgfr 3,3
; CHECK: lmg 7,8,2072(4)
; CHECK: aghi 4,192
; CHECK: b 2(7)
@i = external global i32, align 4
@i2 = external global i32, align 4
define signext i32 @get_i() {
entry:
%0 = load i32, ptr @i, align 4
%1 = load i32, ptr @i2, align 4
%call = call signext i32 @callout(i32 signext %1)
%add = add nsw i32 %0, %call
ret i32 %add
}
declare signext i32 @callout(i32 signext)
; CHECK: stdin#C CSECT
; CHECK: C_WSA64 CATTR ALIGN(4),FILL(0),DEFLOAD,NOTEXECUTABLE,RMODE(64),PART(stdi
; CHECK: in#S)
; CHECK: stdin#S XATTR LINKAGE(XPLINK),REFERENCE(DATA),SCOPE(SECTION)
; CHECK: * Offset 0 pointer to function descriptor DoFunc
; CHECK: DC VD(DoFunc@indirect)
; CHECK: * Offset 8 function descriptor of Caller
; CHECK: DC RD(Caller)
; CHECK: DC VD(Caller)
; CHECK: * Offset 24 pointer to data symbol i2
; CHECK: DC AD(i2)
; CHECK: * Offset 32 pointer to data symbol i
; CHECK: DC AD(i)
; CHECK: * Offset 40 function descriptor of callout
; CHECK: DC RD(callout)
; CHECK: DC VD(callout)
; CHECK: EXTRN DoFunc@indirect
; CHECK: DoFunc@indirect XATTR LINKAGE(XPLINK),REFERENCE(CODE,INDIRECT),SCOPE(EX
; CHECK: PORT)
; CHECK: DoFunc@indirect ALIAS C'DoFunc'