Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible that GimpleCond's true_label & false_label are None? #152

Open
aqjune opened this issue Nov 15, 2018 · 3 comments
Open

Is it possible that GimpleCond's true_label & false_label are None? #152

aqjune opened this issue Nov 15, 2018 · 3 comments

Comments

@aqjune
Copy link

aqjune commented Nov 15, 2018

I am scanning through GIMPLE instructions generated from this C code:

void if_simple() {
  int c = cond();
  if (c) {
    f1();
  }
}

The generated GIMPLE is like this:

if_simple ()
{
  int c;

  <bb 2> [100.00%]:
  c_4 = cond ();
  if (c_4 != 0)
    goto <bb 3>; [36.64%]
  else
    goto <bb 4>; [63.36%]

  <bb 3> [36.64%]:
  f1 ();

  <bb 4> [100.00%]:
  return;

}

However, in Python, I'm getting gcc.GimpleCond which has true_label & false_label set to None.

Is there anything I'm missing or is it a bug?

Thanks

@davidmalcolm
Copy link
Owner

davidmalcolm commented Nov 15, 2018

Internally, these are coming from gimple_cond_true_label and gimple_cond_false_label, which presumably are returning NULL, and this is being handled at the Python level as None.

I'm not sure how they could be NULL. When is your code running, compared to the various passes?

@aqjune
Copy link
Author

aqjune commented Nov 15, 2018

My callback function is registered before optimized pass.

@tom91136
Copy link

Just adding some information in case someone finds this. After CFG all direct control flows in the language (i.e goto) are lowered to individual basic blocks with predecessors and successors, with an optional PHI node for input. The CFG step also deletes the labels for the cond node so the only way to recover this is to inspect each basic block's edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants