Skip to content

[RISCV] Only set Zca flag for EF_RISCV_RVC in ELFObjectFileBase::getR… #80928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ static RelaxAux initRelaxAux(LinkGraph &G) {
RelaxAux Aux;
Aux.Config.IsRV32 = G.getTargetTriple().isRISCV32();
const auto &Features = G.getFeatures().getFeatures();
Aux.Config.HasRVC = llvm::is_contained(Features, "+c");
Aux.Config.HasRVC = llvm::is_contained(Features, "+c") ||
llvm::is_contained(Features, "+zca");

for (auto &S : G.sections()) {
if (!shouldRelax(S))
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/ELFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Expected<SubtargetFeatures> ELFObjectFileBase::getRISCVFeatures() const {
unsigned PlatformFlags = getPlatformFlags();

if (PlatformFlags & ELF::EF_RISCV_RVC) {
Features.AddFeature("c");
Features.AddFeature("zca");
}

RISCVAttributeParser Attributes;
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_align_rvc.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
# RUN: -slab-allocate 100Kb -slab-address 0x0 -slab-page-size 4096 \
# RUN: -check %s %t.rv64

# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax,+zca %s -o %t.rv32zca
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x0 -slab-page-size 4096 \
# RUN: -check %s %t.rv32zca

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax,+zca %s -o %t.rv64zca
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x0 -slab-page-size 4096 \
# RUN: -check %s %t.rv64zca

.globl main,align2,align4,align8,align16,align32
.type main,@function
main:
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_call_boundary.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -check %s %t.rv64

# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax,+zca %s -o %t.rv32zca
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -check %s %t.rv32zca

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax,+zca %s -o %t.rv64zca
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -check %s %t.rv64zca

.globl main
.type main,@function
main:
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_call_rvc.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@
# RUN: -debug-only=jitlink -check %s -check-name=jitlink-check-rv32 %t.rv32 \
# RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32 %s

# RUN: llvm-mc -triple=riscv64 -mattr=+relax,+c -filetype=obj -o %t.rv64 %s
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -debug-only=jitlink -check %s %t.rv64 \
# RUN: 2>&1 | FileCheck %s
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -debug-only=jitlink -check %s -check-name=jitlink-check-rv64 %t.rv64 \
# RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64 %s

# RUN: llvm-mc -triple=riscv32 -mattr=+relax,+zca -filetype=obj -o %t.rv32zca %s
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -debug-only=jitlink -check %s %t.rv32zca \
# RUN: 2>&1 | FileCheck %s
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
# RUN: -debug-only=jitlink -check %s -check-name=jitlink-check-rv32 %t.rv32zca \
# RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32 %s

# RUN: llvm-mc -triple=riscv64 -mattr=+relax,+c -filetype=obj -o %t.rv64 %s
# RUN: llvm-jitlink -noexec \
# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \
Expand Down