Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tests/assembly-llvm/asm/loongarch-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ extern "C" {

// CHECK-LABEL: sym_fn:
// CHECK: #APP
// CHECK: pcalau12i $t0, %got_pc_hi20(extern_func)
// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_func)
// loongarch64: pcalau12i $t0, %got_pc_hi20(extern_func)
// loongarch64: ld.d $t0, $t0, %got_pc_lo12(extern_func)
// loongarch32: pca{{(lau|ddu)}}12i $t0, %got_pc{{(add)?}}_hi20(extern_func)
// loongarch32: ld.w $t0, $t0, %got_pc{{(add)?}}_lo12({{(extern_func|\.Lpcadd_hi0)}})
// CHECK: #NO_APP
#[no_mangle]
pub unsafe fn sym_fn() {
Expand All @@ -38,8 +40,10 @@ pub unsafe fn sym_fn() {

// CHECK-LABEL: sym_static:
// CHECK: #APP
// CHECK: pcalau12i $t0, %got_pc_hi20(extern_static)
// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_static)
// loongarch64: pcalau12i $t0, %got_pc_hi20(extern_static)
// loongarch64: ld.d $t0, $t0, %got_pc_lo12(extern_static)
// loongarch32: pca{{(lau|ddu)}}12i $t0, %got_pc{{(add)?}}_hi20(extern_static)
// loongarch32: ld.w $t0, $t0, %got_pc{{(add)?}}_lo12({{(extern_static|\.Lpcadd_hi1)}})
Comment on lines +45 to +46
Copy link
Contributor

@heiher heiher Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! The two LoongArch32 variants generate different instruction sequences here: la32r emits pcaddu12i + ld.w, while la32s emits pcalau12i + ld.w. While a regex wildcard would cut down on test code line, it also makes the expected output much harder to understand at a glance. A clearer option would be to split into loongarch32r and loongarch32s (using -Ctarget-feature=+32s).

Suggested change
// loongarch32: pca{{(lau|ddu)}}12i $t0, %got_pc{{(add)?}}_hi20(extern_static)
// loongarch32: ld.w $t0, $t0, %got_pc{{(add)?}}_lo12({{(extern_static|\.Lpcadd_hi1)}})
// loongarch32s: pcalau12i $t0, %got_pc_hi20(extern_static)
// loongarch32s: ld.w $t0, $t0, %got_pc_lo12(extern_static)
// loongarch32r: pcaddu12i $t0, %got_pcadd_hi20(extern_static)
// loongarch32r: ld.w $t0, $t0, %got_pcadd_lo12(.Lpcadd_hi1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these changes were backported to LLVM 22, so I've incorporated this in #150722. I think that matches what you suggested here.

// CHECK: #NO_APP
#[no_mangle]
pub unsafe fn sym_static() {
Expand Down
Loading