[llvm-bugs] [Bug 49663] New: Wrong CFI metadata for registers spilled in prolog

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 20 14:53:26 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49663

            Bug ID: 49663
           Summary: Wrong CFI metadata for registers spilled in prolog
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: simonas+llvm.org at kazlauskas.me
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

Consider the following snippet (https://llvm.godbolt.org/z/cTr35q):

    target triple = "i686"

    define void @no_availble_registers_many_args(i32 %a, i32 %b, i32 %c, i32
%d) "no_caller_saved_registers" {
    %all = alloca i32, i64 18000
    %ab = add i32 %a, %b
    %cd = add i32 %c, %d
    %abcd = add i32 %ab, %cd
    %b0 = getelementptr inbounds i32, i32* %all, i64 98
    store volatile i32 %abcd, i32* %b0
    ret void
    }

This produces the following assembly in the prologue:

        .cfi_startproc
        pushl   %ecx
        .cfi_def_cfa_offset 8
        pushl   %eax
        .cfi_def_cfa_offset 12
        subl    $72000, %esp                    # imm = 0x11940
        .cfi_def_cfa_offset 72012
        .cfi_offset %eax, -12
        .cfi_offset %ecx, -8

Here we set the `.cfi_offset` for the spilled registers (eax, ecx) too late and
to the wrong offsets on the stack.

These `.cfi` directives would've been correct if they were emitted immediately
after the `push` instruction, but with the huge allocation on the stack, we
actially `.def_cfa_offset` first, thus changing the offsets entirely, and
making these directives incorrect.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210320/feb873b7/attachment.html>


More information about the llvm-bugs mailing list