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: unassignedb...@nondot.org
          Reporter: cfswo...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to