This is an archive of the discontinued LLVM Phabricator instance.

[DirectX backend] Fix build and test error caused by out of sync with upstream change.
ClosedPublic

Authored by python3kgae on Nov 11 2022, 12:00 AM.

Diff Detail

Event Timeline

python3kgae created this revision.Nov 11 2022, 12:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 12:00 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
python3kgae requested review of this revision.Nov 11 2022, 12:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 12:00 AM

Fix missing clang-format arc missed.

Keep memory attribute and translate it into readnone/readonly/argmemonly.

Add memory(none) in test.

tex3d added a subscriber: tex3d.Nov 11 2022, 2:10 PM

I think we need to add MemoryEffects DXIL canonicalization to translate from attribute values with more nuance to conservative versions for DXIL serialization - see comment on DXILPrepare.cpp. Otherwise, we could have duplicate attribute sets once these are translated in DXILBitcodeWriter, which would result in bitcode differences between equivalent DXIL IR. In other words, if you round-trip the DXIL output from here, the bitcode would change.

We could use some unit tests for how we sanitize and translate different MemoryEffects combinations as well.

llvm/lib/Target/DirectX/DXILPrepare.cpp
57

I think merely allowing this through is insufficient. We should canonicalize the MemoryEffects attribute to a few conservative values for DXIL to avoid duplicate attribute sets once these are translated during serialization.

llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
942

If function only reads from arg mem, won't ME.onlyReadsMemory() be true, leading to both attributes: readonly and argmemonly? I think in this case you only want argmemonly.

I think instead, we need something like:

if (ME.onlyAccessesArgPointees()) {
  ...
} else if (ME.onlyReadsMemory()) {
  ...
}
948

Should we have unit tests to ensure proper translation of different/interesting MemoryEffects combinations?

tex3d added inline comments.Nov 11 2022, 2:15 PM
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
942

Then again, I do see some other case with both these attributes, so maybe this behavior is desirable.

python3kgae marked 3 inline comments as done.Nov 11 2022, 2:30 PM
python3kgae added inline comments.
llvm/lib/Target/DirectX/DXILPrepare.cpp
57
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
942

It is OK for a function has both readnone argmemonly attribute.

948

We could always add tests.
But this PR is just supposed to fix the build and test, so no one is blocked.

python3kgae marked 2 inline comments as done.

Use Attribute::getMemoryEffects directly.

Add tracking issue for DIAssignID.

beanz accepted this revision.Nov 14 2022, 11:14 AM

LGTM

This revision is now accepted and ready to land.Nov 14 2022, 11:14 AM

Rebase and fix build error.

This revision was landed with ongoing or failed builds.Nov 14 2022, 12:50 PM
This revision was automatically updated to reflect the committed changes.