[llvm-bugs] [Bug 43160] New: [deadargelim] removes "this" from x86_thiscallcc

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 29 00:14:17 PDT 2019


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

            Bug ID: 43160
           Summary: [deadargelim] removes "this" from x86_thiscallcc
           Product: libraries
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: CFSworks at gmail.com
                CC: llvm-bugs at lists.llvm.org

This is very similar to bug 38487; my test case in fact is slightly modified
from there.

In this case, I've modified the F::k function to avoid relying on the `this`
pointer. -deadargelim removes `this`, but leaves the calling convention set to
x86_thiscallcc, so the second argument (whatever that may be) ends up shoved
into ECX.

When combined with inalloca, the following fatal error is generated:

cannot use inalloca attribute on a register parameter


However, inalloca aside, removing `this` from any calling convention that
treats `this` specially does break that calling convention. The calling
convention should either be changed (to fastcc?) or the functions with these
special calling conventions should simply have their `this` pointer left alone.

// x.cpp
// clang++ -target i386-pc-windows-msvc -O3 -c x.cpp

struct Y
{
    int i; 
    Y();
    Y(const Y&);
};

void h(Y y);

namespace {
struct F {
    void k(Y y) {
        y.i = 0;
        h(y);
    }
};
}

void foo()
{
    F f;
    Y y;
    f.k(y);
}

-- 
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/20190829/9c602bb9/attachment.html>


More information about the llvm-bugs mailing list