This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Don't use unreachable on stores to unhandled address space
ClosedPublic

Authored by arsenm on Feb 21 2022, 3:31 PM.

Details

Reviewers
rampitec
Group Reviewers
Restricted Project
Summary

For stores to constant address space, this will now consistently hit a
selection error instead of hitting unreachable in an asserts build.

I'm not sure what we should really do here. We could either just
codegen as if it were global, delete the instruction, or declare the
IR invalid (we really should have a target IR verifier to enforce it).

Diff Detail

Unit TestsFailed

Event Timeline

arsenm created this revision.Feb 21 2022, 3:31 PM
arsenm requested review of this revision.Feb 21 2022, 3:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2022, 3:31 PM
Herald added a subscriber: wdng. · View Herald Transcript

In fact not only the stores but atomics as well including atomic load. It is probably better to declare it an invalid IR. The only exception when it might make any sense to lower it as a global is the atomic load, although it is not really needed so there is no need to open this can of worms.

In fact not only the stores but atomics as well including atomic load. It is probably better to declare it an invalid IR. The only exception when it might make any sense to lower it as a global is the atomic load, although it is not really needed so there is no need to open this can of worms.

We at least need to produce the same error in debug vs. release, which this achieves

rampitec accepted this revision.Feb 21 2022, 4:22 PM

LGTM anyway. I believe atomics need it too.

This revision is now accepted and ready to land.Feb 21 2022, 4:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 2:32 PM
Herald added a subscriber: hsmhsm. · View Herald Transcript
dyung added a subscriber: dyung.Apr 13 2022, 11:27 AM

Hi @arsenm, the test you added is failing on our internal linux build bot that builds a release build without asserts with the following error:

Command Output (stderr):
--
/home/dyung/src/upstream/llvm_clean_git/llvm/test/CodeGen/AMDGPU/store-to-constant-error.ll:4:9: error: SDAG: expected string not found in input
; SDAG: LLVM ERROR: Cannot select: t{{[0-9]+}}: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)>
        ^
<stdin>:1:1: note: scanning from here
LLVM ERROR: Cannot select: 0x55f05ad6f228: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)> 0x55f05acd7d38, Constant:i32<1>, 0x55f05ad6f020, undef:i64
^

Can you take a look?

Hi @arsenm, the test you added is failing on our internal linux build bot that builds a release build without asserts with the following error:

Command Output (stderr):
--
/home/dyung/src/upstream/llvm_clean_git/llvm/test/CodeGen/AMDGPU/store-to-constant-error.ll:4:9: error: SDAG: expected string not found in input
; SDAG: LLVM ERROR: Cannot select: t{{[0-9]+}}: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)>
        ^
<stdin>:1:1: note: scanning from here
LLVM ERROR: Cannot select: 0x55f05ad6f228: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)> 0x55f05acd7d38, Constant:i32<1>, 0x55f05ad6f020, undef:i64
^

Can you take a look?

This is because the nodes in the debug output change from numbered notes to raw pointers in release builds

foad added a comment.Apr 14 2022, 1:18 AM

Hi @arsenm, the test you added is failing on our internal linux build bot that builds a release build without asserts with the following error:

Command Output (stderr):
--
/home/dyung/src/upstream/llvm_clean_git/llvm/test/CodeGen/AMDGPU/store-to-constant-error.ll:4:9: error: SDAG: expected string not found in input
; SDAG: LLVM ERROR: Cannot select: t{{[0-9]+}}: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)>
        ^
<stdin>:1:1: note: scanning from here
LLVM ERROR: Cannot select: 0x55f05ad6f228: ch = store<(store (s32) into %ir.ptr.load, addrspace 4)> 0x55f05acd7d38, Constant:i32<1>, 0x55f05ad6f020, undef:i64
^

Can you take a look?

This is because the nodes in the debug output change from numbered notes to raw pointers in release builds

For the record this was fixed by e78f70bccb8919d74bbbe492aa2fb0eb230b7467.