ScheduleDAG Question

I'm debugging a ScheduleDAG problem. Somehow a load appearing
before a call in the source gets scheduled after the call.
Since the callee modifies the location loaded from, wrong answers result.

Looking at the dag with -view-sched-dags, I don't see an edge from the
load to depend on the call.

How is this supposed to be handled by ScheduleDAG?

                                   -Dave

-view-sunit-dags seems to indicate such an edge does exist. Any
pointers on how to efficiently debug this?

                                   -Dave

My first step would be to make sure there's an appropriate edge in the
selection DAG... there's a possibility something could get messed up
by legalization or the dagcombiner.

Since scheduling and selection is mostly within a block, hopefully it
wouldn't be too hard to come up with a testcase?

-Eli

My first step would be to make sure there's an appropriate edge in the
selection DAG... there's a possibility something could get messed up
by legalization or the dagcombiner.

I turned off dagcombine and it didn't help.

Since scheduling and selection is mostly within a block, hopefully it
wouldn't be too hard to come up with a testcase?

Yep, I've got a much reduced testcase now (and converted from Fortran
to C which makes things much easier to work with). I'm going to test
against TOT and see if I see the same problem.

                                   -Dave

TOT is bug-free. I'm about to try 2.5.

My little testcase definitely has missing edges in the sched dag and sunit
dag. Where do edges from loads of globals to calls get added? That's what's
missing here.

                            -Dave

They should be there from the very beginning, when the selection dag is built.

-Eli

Nope, not there. I've attached the dot output. The call of killcombine
looks completely divorced from the load feeding the two extract_vector_elt
nodes. Am I reading the graph correctly?

Hmm...except there's a little dashed blue line from the call to the chain (I
think) field of the load. Is that the dependence I want? I don't know how
to read these graphs.

Is the code that's supposed to do this in ScheduleDAGBuild.cpp?

Thanks for your help.

                                   -Dave

reset.builddag.ps (39.1 KB)

Interesting. So with -view-legalize-dags, that little dashed blue line has
moved from the load to the store that feeds the load. That's wrong.

But it's still there with -view-legalize-types-dags, so legalize types must
be buggy. But -disable-legalize-types doesn't fix the problem. So the
general legalize code seems to have the same issue.

LLVM 2.5 compiles this fine, so it's something we've altered in the codebase.
I did a diff of all of our changes to lib/CodeGen and include/llvm/CodeGen
but nothing jumpoed out as obviously wrong. I suppose it's possible we
present slightly different code to the legalize passes than the unmodified
LLVM.

Fun times, indeed.

                                -Dave

You might want to try the -debug dumps; it might be a bit easier to follow.

-Eli

Eli Friedman wrote:

You might want to try the -debug dumps; it might be a bit easier to follow.

I find the -debug DAG dumps completely incomprehensible. Addresses are
not fun to look at. :slight_smile: But I have been looking at them as well. More
analysis tomorrow.

                             -Dave

Hi David,

Interesting... I have come across a problem that looks like edge is
being removed and I'm wondering if it may be related. The problem is
described in http://llvm.org/bugs/show_bug.cgi?id=4891.

Regards,

Ben