Suspicious code in backend scheduler

Hello,
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 :slight_smile:

Regards

Amaury Pouly

Thanks for the report. It's been getting lucky. I'll fix it.

Evan