================
@@ -1601,9 +1602,37 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
// Create the alloca. Note that we set the name separately from
// building the instruction so that it's there even in no-asserts
// builds.
- address = CreateTempAlloca(allocaTy, Ty.getAddressSpace(),
- allocaAlignment, D.getName(),
- /*ArraySize=*/nullptr, &AllocaAddr);
+ //
+ // "VGPR as memory" objects keep their backing registers only once the
+ // optimizing register allocator runs. At -O0 the backend cannot lower
+ // these accesses (e.g. when the address escapes a basic block), so the
+ // request is not honored: fall back to an ordinary (scratch) alloca and
+ // warn, matching the documented behavior.
+ // TODO: Lower addrspace(13) allocas at -O0 too (e.g. by spilling the
+ // backing tuple to scratch) so this fallback can be removed.
+ const auto *VGPRAttr = D.getAttr<AMDGPUVGPRAttr>();
+ const bool UseVGPRMemory =
+ VGPRAttr && CGM.getCodeGenOpts().OptimizationLevel != 0;
+ if (VGPRAttr && !UseVGPRMemory)
+ CGM.getDiags().Report(D.getLocation(),
+ diag::warn_amdgpu_vgpr_not_guaranteed_at_O0)
+ << VGPRAttr;
+
----------------
arsenm wrote:
Repeating from above, this cannot be a warning. The semantics are broken, and
this isn't an actionable warning for the user
https://github.com/llvm/llvm-project/pull/205435
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits