[llvm] [Mips] Fix compiler crash when returning fp128 after calling a functi… (PR #117525)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 18:49:53 PST 2025
================
@@ -2903,6 +2903,225 @@ entry:
%cond = select i1 %cmp, fp128 %c, fp128 %d
ret fp128 %cond
}
+
+define { i8, i128 } @bar_structure_without_fp128() {
+ ret { i8, i128 } zeroinitializer
+}
+
+define fp128 @call_structure_without_fp128() {
+; C_CC_FMT-LABEL: call_structure_without_fp128:
+; C_CC_FMT: # %bb.0: # %entry
+; C_CC_FMT-NEXT: daddiu $sp, $sp, -48
+; C_CC_FMT-NEXT: .cfi_def_cfa_offset 48
+; C_CC_FMT-NEXT: sd $ra, 40($sp) # 8-byte Folded Spill
+; C_CC_FMT-NEXT: sd $gp, 32($sp) # 8-byte Folded Spill
+; C_CC_FMT-NEXT: .cfi_offset 31, -8
+; C_CC_FMT-NEXT: .cfi_offset 28, -16
+; C_CC_FMT-NEXT: lui $1, %hi(%neg(%gp_rel(call_structure_without_fp128)))
+; C_CC_FMT-NEXT: daddu $1, $1, $25
+; C_CC_FMT-NEXT: daddiu $gp, $1, %lo(%neg(%gp_rel(call_structure_without_fp128)))
+; C_CC_FMT-NEXT: daddiu $4, $sp, 0
+; C_CC_FMT-NEXT: ld $25, %call16(bar_structure_without_fp128)($gp)
+; C_CC_FMT-NEXT: .reloc .Ltmp51, R_MIPS_JALR, bar_structure_without_fp128
+; C_CC_FMT-NEXT: .Ltmp51:
+; C_CC_FMT-NEXT: jalr $25
+; C_CC_FMT-NEXT: nop
+; C_CC_FMT-NEXT: daddiu $2, $zero, 0
+; C_CC_FMT-NEXT: daddiu $4, $zero, 0
+; C_CC_FMT-NEXT: ld $gp, 32($sp) # 8-byte Folded Reload
+; C_CC_FMT-NEXT: ld $ra, 40($sp) # 8-byte Folded Reload
+; C_CC_FMT-NEXT: daddiu $sp, $sp, 48
+; C_CC_FMT-NEXT: jr $ra
+; C_CC_FMT-NEXT: nop
+;
+; CMP_CC_FMT-LABEL: call_structure_without_fp128:
+; CMP_CC_FMT: # %bb.0: # %entry
+; CMP_CC_FMT-NEXT: daddiu $sp, $sp, -48
+; CMP_CC_FMT-NEXT: .cfi_def_cfa_offset 48
+; CMP_CC_FMT-NEXT: sd $ra, 40($sp) # 8-byte Folded Spill
+; CMP_CC_FMT-NEXT: sd $gp, 32($sp) # 8-byte Folded Spill
+; CMP_CC_FMT-NEXT: .cfi_offset 31, -8
+; CMP_CC_FMT-NEXT: .cfi_offset 28, -16
+; CMP_CC_FMT-NEXT: lui $1, %hi(%neg(%gp_rel(call_structure_without_fp128)))
+; CMP_CC_FMT-NEXT: daddu $1, $1, $25
+; CMP_CC_FMT-NEXT: daddiu $gp, $1, %lo(%neg(%gp_rel(call_structure_without_fp128)))
+; CMP_CC_FMT-NEXT: daddiu $4, $sp, 0
+; CMP_CC_FMT-NEXT: ld $25, %call16(bar_structure_without_fp128)($gp)
+; CMP_CC_FMT-NEXT: .reloc .Ltmp51, R_MIPS_JALR, bar_structure_without_fp128
+; CMP_CC_FMT-NEXT: .Ltmp51:
+; CMP_CC_FMT-NEXT: jalrc $25
+; CMP_CC_FMT-NEXT: daddiu $2, $zero, 0
+; CMP_CC_FMT-NEXT: daddiu $4, $zero, 0
+; CMP_CC_FMT-NEXT: ld $gp, 32($sp) # 8-byte Folded Reload
+; CMP_CC_FMT-NEXT: ld $ra, 40($sp) # 8-byte Folded Reload
+; CMP_CC_FMT-NEXT: daddiu $sp, $sp, 48
+; CMP_CC_FMT-NEXT: jrc $ra
+entry:
+ call { i8, i128 } @bar_structure_without_fp128()
+ ret fp128 0xL00000000000000000000000000000000
+}
+
+define { fp128 } @bar_structure_fp128() {
+ ret { fp128 } zeroinitializer
+}
+
+define fp128 @tail_call_structure_fp128() {
+; C_CC_FMT-LABEL: tail_call_structure_fp128:
+; C_CC_FMT: # %bb.0: # %entry
+; C_CC_FMT-NEXT: daddiu $sp, $sp, -16
+; C_CC_FMT-NEXT: .cfi_def_cfa_offset 16
+; C_CC_FMT-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill
+; C_CC_FMT-NEXT: sd $gp, 0($sp) # 8-byte Folded Spill
+; C_CC_FMT-NEXT: .cfi_offset 31, -8
+; C_CC_FMT-NEXT: .cfi_offset 28, -16
+; C_CC_FMT-NEXT: lui $1, %hi(%neg(%gp_rel(tail_call_structure_fp128)))
+; C_CC_FMT-NEXT: daddu $1, $1, $25
+; C_CC_FMT-NEXT: daddiu $gp, $1, %lo(%neg(%gp_rel(tail_call_structure_fp128)))
+; C_CC_FMT-NEXT: ld $25, %call16(bar_structure_fp128)($gp)
+; C_CC_FMT-NEXT: .reloc .Ltmp52, R_MIPS_JALR, bar_structure_fp128
+; C_CC_FMT-NEXT: .Ltmp52:
+; C_CC_FMT-NEXT: jalr $25
+; C_CC_FMT-NEXT: nop
+; C_CC_FMT-NEXT: daddiu $2, $zero, 0
+; C_CC_FMT-NEXT: daddiu $4, $zero, 0
+; C_CC_FMT-NEXT: ld $gp, 0($sp) # 8-byte Folded Reload
+; C_CC_FMT-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload
+; C_CC_FMT-NEXT: daddiu $sp, $sp, 16
+; C_CC_FMT-NEXT: jr $ra
+; C_CC_FMT-NEXT: nop
+;
+; CMP_CC_FMT-LABEL: tail_call_structure_fp128:
+; CMP_CC_FMT: # %bb.0: # %entry
+; CMP_CC_FMT-NEXT: daddiu $sp, $sp, -16
+; CMP_CC_FMT-NEXT: .cfi_def_cfa_offset 16
+; CMP_CC_FMT-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill
+; CMP_CC_FMT-NEXT: sd $gp, 0($sp) # 8-byte Folded Spill
+; CMP_CC_FMT-NEXT: .cfi_offset 31, -8
+; CMP_CC_FMT-NEXT: .cfi_offset 28, -16
+; CMP_CC_FMT-NEXT: lui $1, %hi(%neg(%gp_rel(tail_call_structure_fp128)))
+; CMP_CC_FMT-NEXT: daddu $1, $1, $25
+; CMP_CC_FMT-NEXT: daddiu $gp, $1, %lo(%neg(%gp_rel(tail_call_structure_fp128)))
+; CMP_CC_FMT-NEXT: ld $25, %call16(bar_structure_fp128)($gp)
+; CMP_CC_FMT-NEXT: .reloc .Ltmp52, R_MIPS_JALR, bar_structure_fp128
+; CMP_CC_FMT-NEXT: .Ltmp52:
+; CMP_CC_FMT-NEXT: jalrc $25
+; CMP_CC_FMT-NEXT: daddiu $2, $zero, 0
+; CMP_CC_FMT-NEXT: daddiu $4, $zero, 0
+; CMP_CC_FMT-NEXT: ld $gp, 0($sp) # 8-byte Folded Reload
+; CMP_CC_FMT-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload
+; CMP_CC_FMT-NEXT: daddiu $sp, $sp, 16
+; CMP_CC_FMT-NEXT: jrc $ra
+entry:
+ %call = tail call fp128 @bar_structure_fp128()
+ ret fp128 0xL00000000000000000000000000000000
+}
+
+define fp128 @bar_fp128() {
----------------
yingopq wrote:
OK, I would add check for these bar* functions.
https://github.com/llvm/llvm-project/pull/117525
More information about the llvm-commits
mailing list