llvm-project/llvm/test/CodeGen/SystemZ/zos-landingpad.ll
Kai Nacke 33872f1218
[GOFF] Add writing of section symbols (#133799)
Unlike other formats, the GOFF object file format uses a 2 dimensional structure
to define the location of data. For example, the equivalent of the ELF .text
section is made up of a Section Definition (SD) and a class (Element Definition;
ED). The name of the SD symbol depends on the application, while the class has
the predefined name C_CODE/C_CODE64 in AMODE31 and AMODE64 respectively.

Data can be placed into this structure in 2 ways. First, the data (in a text
record) can be associated with an ED symbol. To refer to data, a Label
Definition (LD) is used to give an offset into the data a name. When binding,
the whole data is pulled into the resulting executable, and the addresses
given by the LD symbols are resolved.

The alternative is to use a Part Definition (PR). In this case, the data (in
a text record) is associated with the part. When binding, only the data of
referenced PRs is pulled into the resulting binary.

Both approaches are used. SD, ED, and PR elements are modeled by nested
MCSectionGOFF instances, while LD elements are associated with MCSymbolGOFF
instances.

At the binary level, a record called "External Symbol Definition" (ESD) is used. The
ESD has a type (SD, ED, PR, LD), and depending on the type a different subset of
the fields is used.
2025-06-26 11:52:14 -04:00

44 lines
1.5 KiB
LLVM

; RUN: llc < %s -mtriple=s390x-none-zos -mcpu=z10 | FileCheck %s
;
; Ensures that landingpad instructions use the right Exception Pointer
; and Exception Selector registers, and that the exception table is emitted.
declare void @callee()
declare void @passeh(ptr, i32) noreturn
declare i32 @__zos_cxx_personality_v2(...)
define void @test1() uwtable personality ptr @__zos_cxx_personality_v2 {
entry:
%ehptr = alloca ptr, align 8
%ehsel = alloca i32, align 8
invoke void @callee() to label %done unwind label %lpad
done:
ret void
; Match the return instruction.
; CHECK: b 2(7)
lpad:
%0 = landingpad { ptr, i32 } cleanup
; The Exception Pointer is %r1; the Exception Selector, %r2.
; CHECK: L#BB{{[^%]*}} %lpad
; CHECK-DAG: stg 1,{{.*}}
; CHECK-DAG: st 2,{{.*}}
%1 = extractvalue { ptr, i32 } %0, 0
%2 = extractvalue { ptr, i32 } %0, 1
store ptr %1, ptr %ehptr, align 8
store i32 %2, ptr %ehsel, align 8
call void @passeh(ptr %1, i32 %2)
unreachable
}
; Check that offsets to the FD of the personality routine and LSDA are emitted in PPA1
; CHECK: .byte 145 {{.*PPA1 Flags}}
; CHECK: Bit 3: 1 = C++ EH block
; TODO: Emit the value instead of a dummy value.
; CHECK: Personality routine
; CHECK: LSDA location
; Check that the exception table is emitted into .lsda section.
; CHECK: stdin#C CSECT
; CHECK: C_WSA64 CATTR ALIGN(2),FILL(0),NOTEXECUTABLE,RMODE(64),PART(.gcc_exception_table.test1)
; CHECK: .gcc_exception_table.test1 XATTR LINKAGE(XPLINK),REFERENCE(DATA),SCOPE(SECTION)
; CHECK: GCC_except_table0: