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

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 20:59:29 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Owen Anderson (resistor)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/217809.diff


1 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp (+3) 


``````````diff
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);

``````````

</details>


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


More information about the llvm-commits mailing list