[llvm] [GlobalISel] Preserve volatile and atomic undef/poison stores (PR #200099)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 02:35:18 PDT 2026


================
@@ -542,8 +542,20 @@ static bool loadStoreBitcastWorkaround(const LLT Ty) {
   return EltSize != 32 && EltSize != 64;
 }
 
+// True for a pointer in an address space beyond the known AMDGPU address
+// spaces (e.g. produced by an illegal addrspacecast). Such pointers have no
+// register class or load/store selection pattern.
+static bool isUnsupportedPointerType(LLT Ty) {
+  return Ty.isPointer() && Ty.getAddressSpace() > AMDGPUAS::MAX_AMDGPU_ADDRESS;
+}
+
 static bool isLoadStoreLegal(const GCNSubtarget &ST, const LegalityQuery &Query) {
   const LLT Ty = Query.Types[0];
+  // Stores of a pointer in an unsupported address space have no selection
+  // pattern; route them to custom legalization, which reinterprets the stored
+  // value as an integer of the same size.
+  if (Query.Opcode == TargetOpcode::G_STORE && isUnsupportedPointerType(Ty))
+    return false;
----------------
arsenm wrote:

This should be fixed in the selection patterns, not hacked around in the legalizer rules 

https://github.com/llvm/llvm-project/pull/200099


More information about the llvm-commits mailing list