[llvm] [RISCV] Fix stage2 bootstrap crash caused by f6ea145aa8e89631ae04f72df32580b20256d40c (PR #217809)

Owen Anderson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 20:58:08 PDT 2026


https://github.com/resistor created https://github.com/llvm/llvm-project/pull/217809

It's not possible to compute an allocation granule for an unsized type.


>From 27cf44d2f9894546c2d92f5ae1ae8d5ae196cb87 Mon Sep 17 00:00:00 2001
From: Owen Anderson <resistor at mac.com>
Date: Thu, 20 Aug 2026 22:57:01 -0500
Subject: [PATCH] [RISCV] Fix stage2 bootstrap crash caused by
 f6ea145aa8e89631ae04f72df32580b20256d40c

It's not possible to compute an allocation granule for an unsized type.
---
 llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
index a0a42ea1fbb8f..3896e8eb7efa0 100644
--- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -1330,6 +1330,9 @@ void RISCVAsmPrinter::emitMachineConstantPoolValue(
 MaybeAlign
 RISCVAsmPrinter::getRequiredGlobalAlignmentGranule(const GlobalVariable &GV) {
   const MCSubtargetInfo &MCSTI = TM.getMCSubtargetInfo();
+  if (!GV.getType()->isSized())
+    return std::nullopt;
+
   uint64_t Size = GV.getGlobalSize(getDataLayout());
   if (MCSTI.hasFeature(RISCV::FeatureVendorXCheriot))
     return CHERIoTCapabilityFormat::getRequiredAlignment(Size);



More information about the llvm-commits mailing list