[llvm] Prevent building for riscv32-unknown-fuchsia
authorLeonard Chan <leonardchan@google.com>
Wed, 1 Mar 2023 19:42:15 +0000 (19:42 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 1 Mar 2023 19:42:56 +0000 (19:42 +0000)
Fuchsia is exclusively 64-bit so this throw an error when using this
triple.

Differential Revision: https://reviews.llvm.org/D144998

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/test/CodeGen/RISCV/rv32-fuchsia.ll [new file with mode: 0644]

index 4b510df..5fcb94c 100644 (file)
@@ -111,6 +111,9 @@ RISCVTargetMachine::RISCVTargetMachine(const Target &T, const Triple &TT,
   // RISC-V supports the MachineOutliner.
   setMachineOutliner(true);
   setSupportsDefaultOutlining(true);
+
+  if (TT.isOSFuchsia() && !TT.isArch64Bit())
+    report_fatal_error("Fuchsia is only supported for 64-bit");
 }
 
 const RISCVSubtarget *
diff --git a/llvm/test/CodeGen/RISCV/rv32-fuchsia.ll b/llvm/test/CodeGen/RISCV/rv32-fuchsia.ll
new file mode 100644 (file)
index 0000000..c628ec7
--- /dev/null
@@ -0,0 +1,6 @@
+; RUN: not --crash llc -mtriple=riscv32-unknown-fuchsia < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: Fuchsia is only supported for 64-bit
+define void @nothing() nounwind {
+  ret void
+}