Skip to content

Commit f1e0392

Browse files
[RISCV] Disable generation of asynchronous unwind tables for RISCV baremetal (#81727)
The below culprit patch enabled the generation of asynchronous unwind tables (-funwind-tables=2) by default for RISCV for both linux and RISCVToolChain baremetal object. However, since there are 2 baremetal toolchain objects for RISCV, this created a discrepancy between their behavior. Moreover, enabling the generation of asynchronous unwind tables based on whether `-gcc-toolchain` option is present or not doesn't seem to be the best criteria to decide on the same. This patch make the behavior consistent by disabling the unwind tables in RISCVToolChain Baremetal object. Culprit Patch - https://reviews.llvm.org/D145164
1 parent 6ac2c04 commit f1e0392

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ RISCVToolChain::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
8686
return ToolChain::UNW_None;
8787
}
8888

89+
ToolChain::UnwindTableLevel RISCVToolChain::getDefaultUnwindTableLevel(
90+
const llvm::opt::ArgList &Args) const {
91+
return UnwindTableLevel::None;
92+
}
93+
8994
void RISCVToolChain::addClangTargetOptions(
9095
const llvm::opt::ArgList &DriverArgs,
9196
llvm::opt::ArgStringList &CC1Args,

clang/lib/Driver/ToolChains/RISCVToolchain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public Generic_ELF {
2828
RuntimeLibType GetDefaultRuntimeLibType() const override;
2929
UnwindLibType
3030
GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
31+
UnwindTableLevel
32+
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
3133
void
3234
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
3335
llvm::opt::ArgStringList &CC1Args) const override;

clang/test/Driver/riscv-features.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
// FAST-UNALIGNED-ACCESS: "-target-feature" "+fast-unaligned-access"
4242
// NO-FAST-UNALIGNED-ACCESS: "-target-feature" "-fast-unaligned-access"
4343

44+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
45+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
46+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
47+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
48+
//
49+
// UWTABLE: "-funwind-tables=2"
50+
// NOUWTABLE-NOT: "-funwind-tables=2"
51+
4452
// RUN: %clang --target=riscv32-linux -### %s -fsyntax-only 2>&1 \
4553
// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX
4654
// RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \

0 commit comments

Comments
 (0)