[llvm] [TargetLoweringObjectFile] Handle riscv BE (PR #155166)

Djordje Todorovic via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 24 07:57:19 PDT 2025


https://github.com/djtodoro updated https://github.com/llvm/llvm-project/pull/155166

>From b0f2c48c4b8b128a19fd2d1511d5069f46dd7c6a Mon Sep 17 00:00:00 2001
From: Djordje Todorovic <djordje.todorovic at htecgroup.com>
Date: Sun, 24 Aug 2025 15:10:17 +0200
Subject: [PATCH] [TargetLoweringObjectFile] Handle riscv BE

Add DWARF exception handling support for riscv big-endian targets.
More CodeGen changes related to riscvbe are coming.
---
 .../lib/CodeGen/TargetLoweringObjectFileImpl.cpp |  2 ++
 llvm/test/CodeGen/RISCV/dwarf-eh.ll              | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index d19ef923ef740..739dcc7f4c868 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -247,6 +247,8 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
     break;
   case Triple::riscv32:
   case Triple::riscv64:
+  case Triple::riscv32be:
+  case Triple::riscv64be:
     LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
     PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
                           dwarf::DW_EH_PE_sdata4;
diff --git a/llvm/test/CodeGen/RISCV/dwarf-eh.ll b/llvm/test/CodeGen/RISCV/dwarf-eh.ll
index 39cc0d52c9fe1..dd9e9e59206ac 100644
--- a/llvm/test/CodeGen/RISCV/dwarf-eh.ll
+++ b/llvm/test/CodeGen/RISCV/dwarf-eh.ll
@@ -14,6 +14,22 @@
 ; RUN:     | FileCheck %s
 ; RUN: llc -mtriple=riscv64 --code-model=medium -relocation-model=pic < %s \
 ; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv32be --code-model=small  < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv32be --code-model=medium < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv32be --code-model=small  -relocation-model=pic < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv32be --code-model=medium -relocation-model=pic < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv64be --code-model=small  < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv64be --code-model=medium < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv64be --code-model=small  -relocation-model=pic < %s \
+; RUN:     | FileCheck %s
+; RUN: llc -mtriple=riscv64be --code-model=medium -relocation-model=pic < %s \
+; RUN:     | FileCheck %s
 
 declare void @throw_exception()
 



More information about the llvm-commits mailing list