This is an archive of the discontinued LLVM Phabricator instance.

SelectionDAG: Fix bug in ClusterNeighboringLoads
ClosedPublic

Authored by nhaehnle on Feb 7 2020, 1:25 PM.

Details

Summary

The method attempts to find loads that can be legally clustered by
looking for loads consuming the same chain glue token.

However, the old code looks at _all_ users of values produced by the
chain node -- including uses of the loaded/returned value of volatile
loads or atomics. This could lead to circular dependencies which then
failed during scheduling.

With this change, we filter out users by getResNo, i.e. by which
SDValue value they use, to ensure that we only look at users of the
chain glue token.

This appears to be a rather old bug, which is perhaps surprising.
However, the test case is actually quite fragile (i.e., it is hidden
by fairly small changes), and the test _must_ use volatile loads for
the bug to manifest.

Diff Detail

Event Timeline

nhaehnle created this revision.Feb 7 2020, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2020, 1:25 PM
foad accepted this revision.Feb 7 2020, 2:13 PM

LGTM.

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
238

Is there no slicker way of iterating the uses of an SDValue, without having to manually check getResNo() each time?

This revision is now accepted and ready to land.Feb 7 2020, 2:13 PM
nhaehnle marked an inline comment as done.Feb 12 2020, 12:13 AM
nhaehnle added inline comments.
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
238

I looked for it, but apparently not :/

This revision was automatically updated to reflect the committed changes.