This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Remove non-instructions from GCNHazardRecognizer buffer
ClosedPublic

Authored by critson on Sep 6 2018, 3:58 AM.

Details

Summary

This fixes a bug where a large number of implicit def instructions can cause the GCNHazardRecognizer not to insert required NOPs.

Change-Id: Ie75338f94de704ee5816b05afd0c922c6748a95b

Diff Detail

Repository
rL LLVM

Event Timeline

critson created this revision.Sep 6 2018, 3:58 AM
arsenm added inline comments.Sep 6 2018, 5:56 AM
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
222 ↗(On Diff #164051)

isDebugInstr()

test/CodeGen/AMDGPU/hazard-lookahead.mir
8–13 ↗(On Diff #164051)

We already have a test for implicit_def behavior in hazard.mir? You can merge this test into that one

38 ↗(On Diff #164051)

Need another test with DBG_LABEL

arsenm added inline comments.Sep 6 2018, 5:58 AM
test/CodeGen/AMDGPU/hazard-lookahead.mir
12–13 ↗(On Diff #164051)

Should also use -NEXT checks

critson updated this revision to Diff 164385.Sep 7 2018, 4:15 AM

Use isDebugInstr instead of DEBUG_VALUE.
Merge tests into existing hazard.mir.
Add test for DEBUG_LABEL.

critson marked an inline comment as done.Sep 7 2018, 4:17 AM
arsenm accepted this revision.Sep 7 2018, 8:35 AM

LGTM, but reword the commit message since nothing is really removed

This revision is now accepted and ready to land.Sep 7 2018, 8:35 AM
nhaehnle added inline comments.Sep 10 2018, 2:25 AM
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
263–265 ↗(On Diff #164385)

Please remove INLINEASM here, as well. A test case would be good as well.

There is no guarantee that inline assembly contains actual instructions, and in fact there are cases where Mesa currently generates fake inline assembly as a workaround.

nhaehnle added inline comments.Sep 10 2018, 2:29 AM
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
263–265 ↗(On Diff #164385)

Actually, scratch that, I got my wires crossed about the logic of this code. This part of it should be fine?

However, I think the point stands that the same issue that affects DBG_VALUEs with respect to the buffer can also affect inline assembly instructions.

critson marked 2 inline comments as done.Sep 10 2018, 2:49 AM
critson added inline comments.
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
263–265 ↗(On Diff #164385)

We cannot remove INLINEASM from the buffer as INLINEASM can interact with registers and cause the introduction of NOPs.
There is a test for this behaviour in hazard-inlineasm.mir.
If a large number of INLINEASM are overflowing the buffer then this will require a separate workaround (or increased buffer size).

critson marked 2 inline comments as done.Sep 10 2018, 2:49 AM
This revision was automatically updated to reflect the committed changes.