[clang] b2323f4 - [AIX][Debug] generate an error instead of crash in backend for -gdwarf-5
Chen Zheng via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 19 00:39:27 PDT 2024
Author: Chen Zheng
Date: 2024-04-19T03:39:17-04:00
New Revision: b2323f43e3cdb52b4e15a7d4f434cd5c64740dd4
URL: https://github.com/llvm/llvm-project/commit/b2323f43e3cdb52b4e15a7d4f434cd5c64740dd4
DIFF: https://github.com/llvm/llvm-project/commit/b2323f43e3cdb52b4e15a7d4f434cd5c64740dd4.diff
LOG: [AIX][Debug] generate an error instead of crash in backend for -gdwarf-5
Before this change -gdwarf-5 on AIX will cause backend crash, because
some DWARF5 sections are not defined in XCOFF.
Explicitly statement -gdwarf-5 as unsupported in frontend on AIX.
Added:
Modified:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/CodeGen/dwarf-version.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f10aa4dfaa9ddd..b65b96db16bd79 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2116,8 +2116,12 @@ unsigned tools::getDwarfVersion(const ToolChain &TC,
const llvm::opt::ArgList &Args) {
unsigned DwarfVersion = ParseDebugDefaultVersion(TC, Args);
if (const Arg *GDwarfN = getDwarfNArg(Args))
- if (int N = DwarfVersionNum(GDwarfN->getSpelling()))
+ if (int N = DwarfVersionNum(GDwarfN->getSpelling())) {
DwarfVersion = N;
+ if (DwarfVersion == 5 && TC.getTriple().isOSAIX())
+ TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+ << GDwarfN->getSpelling() << TC.getTriple().str();
+ }
if (DwarfVersion == 0) {
DwarfVersion = TC.GetDefaultDwarfVersion();
assert(DwarfVersion && "toolchain default DWARF version must be nonzero");
diff --git a/clang/test/CodeGen/dwarf-version.c b/clang/test/CodeGen/dwarf-version.c
index e63316ace69c87..258c258e5f5a26 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -46,8 +46,10 @@
// RUN: FileCheck %s --check-prefix=VER3
// RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-4 -S -emit-llvm -o - %s | \
// RUN: FileCheck %s --check-prefix=VER4
-// RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-5 -S -emit-llvm -o - %s | \
-// RUN: FileCheck %s --check-prefix=VER5
+// RUN: not %clang -target powerpc-ibm-aix-xcoff -gdwarf-5 -S -emit-llvm -o - %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=UNSUPPORTED-VER5
+// RUN: not %clang -target powerpc64-ibm-aix-xcoff -gdwarf-5 -S -emit-llvm -o - %s 2>&1| \
+// RUN: FileCheck %s --check-prefix=UNSUPPORTED-VER5
int main (void) {
return 0;
@@ -59,6 +61,7 @@ int main (void) {
// VER3: !{i32 7, !"Dwarf Version", i32 3}
// VER4: !{i32 7, !"Dwarf Version", i32 4}
// VER5: !{i32 7, !"Dwarf Version", i32 5}
+// UNSUPPORTED-VER5: error: unsupported option '-gdwarf-5'
// NODWARF-NOT: !"Dwarf Version"
// CODEVIEW: !{i32 2, !"CodeView", i32 1}
More information about the cfe-commits
mailing list