Skip to content

vararg related bug in custom lowering of FORMAL_ARGUMENTS #3842

@llvmbot

Description

@llvmbot
Bugzilla Link 3470
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

Extended Description

The following LLVM IR snippet:

target datalayout = "E-p:32:32:128-i1:8:128-i8:8:128-i16:16:128-i32:32:128-i64:32:128-f32:32:128-f64:64:128-v64:64:64-v128:128:128-a0:0:128-s0:128:128"
target triple = "spu"

define void @​a(...) {
entry:
call void @​b()
ret void
}

Is translated to this assembly code:

    .file   "vararg.bc"
    .text


    .align  3
    .global a
    .type   a, @​function

a:
stqd $lr, 16($sp)
stqd $sp, -32($sp)
ai $sp, $sp, -32
stqd $79, 1280($sp)
stqd $78, 1264($sp)
stqd $77, 1248($sp)
....
stqd $4, 80($sp)
stqd $3, 64($sp)
brasl $lr, b
lqd $lr, 48($sp)
ai $sp, $sp, 32
bi $lr
.size a,.-a

Since function 'a' accepts a variable number of arguments, all argument registers are spilled to the runtime stack.

However, the size of the stack frame is wrong, the space for the spilled registers is not taken into account. This results in a corrupted runtime stack.

There's another, less critical issue here:
$3-$79 are spilled here, but according to the SPU ABI only $3-$74 are used for argument passing, $75-$79 are scratch registers which don't need to be spilled to memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaconfirmedVerified by a second partyobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions