[llvm-branch-commits] [llvm] [RISC-V] Test ELF e_flags for llc -target-abi without module flag (PR #225128)

Alexander Richardson via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 21 08:58:51 PDT 2026


https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/225128

<!-- nspr:warning -->
> [!WARNING]
> ⚠️ **Part of a stacked PR.** Merge via `nspr land` or GitHub's **Merge stack** (if merging a single PR via the web UI, click **Rebase stack** or run `nspr sync` afterwards).
<!-- /nspr:warning -->

Verify that `llc -filetype=obj -target-abi=...` sets the ELF header `e_flags`
according to `-target-abi` even when the input IR has no `"target-abi"` module
flag and the enabled extensions (such as `+d`) would default to a different ABI.

This commit was created with the help of AI tools

>From 023a042a285fa3a3e2710800fb1d2b02d5237617 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Mon, 21 Sep 2026 08:58:22 -0700
Subject: [PATCH] [RISC-V] Test ELF e_flags for llc -target-abi without module
 flag

Verify that `llc -filetype=obj -target-abi=...` sets the ELF header `e_flags`
according to `-target-abi` even when the input IR has no `"target-abi"` module
flag and the enabled extensions (such as `+d`) would default to a different ABI.

This commit was created with the help of AI tools
---
 llvm/test/CodeGen/RISCV/target-abi-valid.ll | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/llvm/test/CodeGen/RISCV/target-abi-valid.ll b/llvm/test/CodeGen/RISCV/target-abi-valid.ll
index 53e4270857332..c6d7b31b73bde 100644
--- a/llvm/test/CodeGen/RISCV/target-abi-valid.ll
+++ b/llvm/test/CodeGen/RISCV/target-abi-valid.ll
@@ -30,6 +30,19 @@
 ; RUN:   | FileCheck -check-prefix=CHECK-IMP %s
 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64d < %s 2>&1 \
 ; RUN:   | FileCheck -check-prefix=CHECK-IMP %s
+; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64 -filetype=obj < %s \
+; RUN:   | llvm-readelf -h - | FileCheck -check-prefix=CHECK-OBJ-LP64 %s
+; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64f -filetype=obj < %s \
+; RUN:   | llvm-readelf -h - | FileCheck -check-prefix=CHECK-OBJ-LP64F %s
+; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi lp64d -filetype=obj < %s \
+; RUN:   | llvm-readelf -h - | FileCheck -check-prefix=CHECK-OBJ-LP64D %s
+; RUN: llc -mtriple=riscv64 -target-abi lp64e -filetype=obj < %s \
+; RUN:   | llvm-readelf -h - | FileCheck -check-prefix=CHECK-OBJ-LP64E %s
+
+; CHECK-OBJ-LP64:  Flags: 0x0{{$}}
+; CHECK-OBJ-LP64F: Flags: 0x2, single-float ABI{{$}}
+; CHECK-OBJ-LP64D: Flags: 0x4, double-float ABI{{$}}
+; CHECK-OBJ-LP64E: Flags: 0x8, RVE{{$}}
 
 define void @nothing() nounwind {
 ; CHECK-IMP-LABEL: nothing:



More information about the llvm-branch-commits mailing list