Bug 39274 - internal compiler error: in check_cfg, at haifa-sched.c, var-tracking
Summary: internal compiler error: in check_cfg, at haifa-sched.c, var-tracking
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-23 16:00 UTC by Sergei Larin
Modified: 2010-07-21 09:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Larin 2009-02-23 16:00:47 UTC
This simple code: 

typedef void (*TestFunction)(int *);

void Add(int *testCase);
void test(void);
int* TestNew( TestFunction function);

static void foo(int* tc){
   test();
}

int* GetProfileSuite(){
   Add(TestNew(foo));
   return 0;
}

...triggers internal assert on my port of 4.3.2 when compiled with -O2 -g. It will pass with -O2 only or with -O2 -fno-var-tracking -g. 

The assert triggered is this one:

...
static void
check_cfg (rtx head, rtx tail)
{
...
if (control_flow_insn_p (head))
   {
      gcc_assert (BB_END (bb) == head); <<<<<< This one 

      if (any_uncondjump_p (head))
          gcc_assert (EDGE_COUNT (bb->succs) == 1
                 && BARRIER_P (NEXT_INSN (head)));

It looks like free_cfg pass removes something it should not after NOTE_INSN_VAR_LOCATION was inserted by variable_tracking pass.
Comment 1 Andrew Pinski 2009-02-24 22:33:09 UTC
>It looks like free_cfg pass removes something it should not after
> NOTE_INSN_VAR_LOCATION was inserted by variable_tracking pass.


Are you running the scheduler manually in your machine dependent reorg?  If so you need to call compute_bb_for_insn before calling schedule_insns.
Comment 2 Sergei Larin 2009-02-25 17:00:27 UTC
Thank you for the suggestion, but... 

I use schedule_ebbs in machine dependent reorg, and I do call compute_bb_for_insn before it. CFG is messed up before I get there... 
Comment 3 Steven Bosscher 2010-07-21 09:58:14 UTC
Look at the ia64 port (and a few others too, e.g. blackfin), they call compute_bb_for_insn first thing in machine reorg and that works. It is obviously not ideal, but the only pass between free_cfg and machine_reorg that can destroy  the CFG is dbr_sched (delay branch scheduling).

Anyway, out-of-tree port => INVALID.

Feel free to re-open this bug report if you can reproduce it with an in-tree port, of course.