https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118243

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot 
gnu.org
             Status|ASSIGNED                    |NEW
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, in fact the fix seems wrong as the __imag__ testcase shows.  It seems for
IPA_PARAM_OP_SPLIT we have to build the composed value from multiple parts,
not simply pick the one at offset zero and throw away the rest.

How was this supposed to work?

using complex_t = int __complex__;

struct A {
    complex_t value;
    A(double r) : value{0, r} {}
};

[[gnu::noipa]]
void f(int a)
{
  if (a != 1)
    __builtin_abort();
}
[[gnu::noipa]] void g(const char *, int x){}


void test(const complex_t &c, const int &x) {
    if (x < 0)
        g("%d\n", x);
    else
    {
        f( __imag__ c);
    }
}

void f1() {
    {
        A a{1};
        test(a.value, 123);
    }
}

int main()
{
        f1();
}


for that testcase we have

(gdb) p mod_info->pass_through_map
$3 = {<vec<pass_through_split_map, va_heap, vl_ptr>> = {m_vec = 0x554b220 = {{
        base_index = 0, unit_offset = 0, new_index = 0}, {base_index = 0, 
        unit_offset = 4, new_index = 1}}}, <No data fields>}
(gdb) p *apm
$4 = {type = <complex_type 0x7ffff6fc17e0 complex_t>, 
  alias_ptr_type = <reference_type 0x7ffff6fc1930>, unit_offset = 0, 
  base_index = 0, prev_clone_index = 0, op = IPA_PARAM_OP_SPLIT, 
  prev_clone_adjustment = 0, param_prefix_index = 1, reverse = 0, 
  user_flag = 0}

so what seems to be missing at the IPA decision stage is to only support
a single part from IPA_PARAM_OP_SPLIT?  Alternatively we'd have to
build up the parameter from multiple parts rather than just a single one.

Reply via email to