[LLVMdev] Suspicious code in backend scheduler

Amaury Pouly amaury.pouly at gmail.com
Sun Aug 8 06:27:33 PDT 2010

Still trying to write a custom scheduler, I stumbled accross a highly
suspicious code in all schedulers.
In both ScheduleDAGFast.cpp and ScheduleDAGRRList.cpp, one can find this
piece of code:

SUnit *CopyFromSU = CreateNewSUnit(NULL);

and then in the same files:

SUnit *CreateNewSUnit(SDNode *N) {
    SUnit *NewNode = NewSUnit(N);

And finally in ScheduleDAGSDNodes.cpp:

SUnit *ScheduleDAGSDNodes::NewSUnit(SDNode *N) {
  if (N->isMachineOpcode() && [...]

So basically, it means that calling CreateNewSUnit with NULL will call
NewSUnit with NULL and with result in NULL->isMachineOpcode() which would
certainly trigger a segfault.
Now I'm highly surprized because I still haven't encountered any segfault in
the scheduler yet all schedulers might call this code.
So either I'm missing something and this code is valid or this code has not
been executed for a *really* long time now and should be removed or fixed.
Unfortunately, I don't know the code enough to fix it if it's necessary
that's why I'm seeking for help or reviews on this point :)


Amaury Pouly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100808/1feedada/attachment.html>

More information about the llvm-dev mailing list