Hi, I'm trying to make pass_fre work better for me. But I got a
problem. Like the code below:

int glob;

void __attribute__((oninline))
foo() {
  // do nothing meaningful
}

int main() {
  if (glob) {
    foo();
  } else {
    // do something that won't change glob
  }

  if (glob) {
    foo();
  } else {
    // do something that won't change glob
  }
}

I'm trying to merge the two if blocks. And of course it won't work. I
see the code in tree-ssa-structalias.cc, it will do this check:

static bool
pt_solution_includes_1 (struct pt_solution *pt, const_tree decl) {
  // xxxx
  if (pt->nonlocal
      && is_global_var (decl))
    return true;
 // xxxx
}

So the pt->nonlocal will prevent the merge. I would like to ask if I
can make this check less rigid by providing more information about
function foo(). Because obviously the foo function does not change the
value of glob here, but it is caused by the fact that it is noinline.

So if I can prove that foo won't change glob and pass this infomation
to this check, my goal was achieved. Is this possible?

Thanks
Hanke Zhang

Reply via email to