[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 117139. chrib added a comment. Hello, I realized that testing CCCisCXX for IsUnwindTablesDefault was not really good and useless here, because we cannot treat C as C++ mode. In fact only the file type matters, as seen in the tests. So I'd like to amend my previous proposal to - Add the InputType parameter to IsUnwindTablesDefault and use in the new function ARMNeedUnwindTable - Fix tests thinko (wrong triplet) - Rebase sorry for the respin, thanks ! https://reviews.llvm.org/D31140 Files: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Arch/ARM.cpp lib/Driver/ToolChains/Arch/ARM.h lib/Driver/ToolChains/BareMetal.cpp lib/Driver/ToolChains/BareMetal.h lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CrossWindows.cpp lib/Driver/ToolChains/CrossWindows.h lib/Driver/ToolChains/Darwin.cpp lib/Driver/ToolChains/Darwin.h lib/Driver/ToolChains/Fuchsia.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Gnu.h lib/Driver/ToolChains/Linux.cpp lib/Driver/ToolChains/Linux.h lib/Driver/ToolChains/MSVC.cpp lib/Driver/ToolChains/MSVC.h lib/Driver/ToolChains/MinGW.cpp lib/Driver/ToolChains/MinGW.h lib/Driver/ToolChains/NetBSD.h test/Driver/arm-unwind.c test/Driver/arm-unwind.cpp Index: test/Driver/arm-unwind.cpp === --- /dev/null +++ test/Driver/arm-unwind.cpp @@ -0,0 +1,9 @@ +// Add function attribute "uwtable" for arm ehabi targets in C++. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI: -munwind-tables + +// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU: -munwind-tables Index: test/Driver/arm-unwind.c === --- /dev/null +++ test/Driver/arm-unwind.c @@ -0,0 +1,9 @@ +// Do not add function attribute "uwtable" for arm ehabi targets for C mode. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI-NOT: -munwind-tables + +// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU-NOT: -munwind-tables Index: lib/Driver/ToolChains/NetBSD.h === --- lib/Driver/ToolChains/NetBSD.h +++ lib/Driver/ToolChains/NetBSD.h @@ -65,7 +65,7 @@ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override { return true; } Index: lib/Driver/ToolChains/MinGW.h === --- lib/Driver/ToolChains/MinGW.h +++ lib/Driver/ToolChains/MinGW.h @@ -60,7 +60,7 @@ const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -8,6 +8,7 @@ //===--===// #include "MinGW.h" +#include "Arch/ARM.h" #include "InputInfo.h" #include "CommonArgs.h" #include "clang/Driver/Compilation.h" @@ -361,8 +362,18 @@ return new tools::MinGW::Linker(*this); } -bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { - return getArch() == llvm::Triple::x86_64; +bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, types::ID InputType) const { + switch (getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +return tools::arm::ARMNeedUnwindTable(Args, types::isCXX(InputType)); + case llvm::Triple::x86_64: +return true; + default: +return false; + } } bool toolchains::MinGW::isPICDefault() const { Index: lib/Driver/ToolChains/MSVC.h === --- lib/Driver/ToolChains/MSVC.h +++ lib/Driver/ToolChains/MSVC.h @@ -73,7 +73,8 @@ Action::OffloadKind DeviceOffloadKind) const override; bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, +
[PATCH] D51354: Fix the -print-multi-directory flag to print the selected multilib.
chrib created this revision. Herald added subscribers: cfe-commits, srhines. Fix -print-multi-directory to print the selected multilib Repository: rC Clang https://reviews.llvm.org/D51354 Files: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChains/Linux.cpp test/Driver/print-multi-directory.c Index: test/Driver/print-multi-directory.c === --- /dev/null +++ test/Driver/print-multi-directory.c @@ -0,0 +1,28 @@ +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86-MULTILIBS %s + +// CHECK-X86-MULTILIBS: 32 +// CHECK-X86-MULTILIBS-NOT: x32 +// CHECK-X86-MULTILIBS-NOT: . + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux -m64 \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86_64-MULTILIBS %s + +// CHECK-X86_64-MULTILIBS: . +// CHECK-X86_64-MULTILIBS-NOT: x32 +// CHECK-X86_64-MULTILIBS-NOT: 32 + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \ +// RUN: -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-MULTILIBS %s + +// CHECK-ARM-MULTILIBS: thumb +// CHECK-ARM-MULTILIBS-NOT: . Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -210,6 +210,7 @@ : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); Multilibs = GCCInstallation.getMultilibs(); + SelectedMultilib = GCCInstallation.getMultilib(); llvm::Triple::ArchType Arch = Triple.getArch(); std::string SysRoot = computeSysRoot(); @@ -299,16 +300,14 @@ if (GCCInstallation.isValid()) { const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); const std::string &LibPath = GCCInstallation.getParentLibPath(); -const Multilib &Multilib = GCCInstallation.getMultilib(); -const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); // Add toolchain / multilib specific file paths. -addMultilibsFilePaths(D, Multilibs, Multilib, +addMultilibsFilePaths(D, Multilibs, SelectedMultilib, GCCInstallation.getInstallPath(), Paths); // Sourcery CodeBench MIPS toolchain holds some libraries under // a biarch-like suffix of the GCC installation. -addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), +addPathIfExists(D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), Paths); // GCC cross compiling toolchains will install target libraries which ship @@ -330,7 +329,7 @@ // Note that this matches the GCC behavior. See the below comment for where // Clang diverges from GCC's behavior. addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + - OSLibDir + Multilib.osSuffix(), + OSLibDir + SelectedMultilib.osSuffix(), Paths); // If the GCC installation we found is inside of the sysroot, we want to Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1661,14 +1661,13 @@ } if (C.getArgs().hasArg(options::OPT_print_multi_directory)) { -for (const Multilib &Multilib : TC.getMultilibs()) { - if (Multilib.gccSuffix().empty()) -llvm::outs() << ".\n"; - else { -StringRef Suffix(Multilib.gccSuffix()); -assert(Suffix.front() == '/'); -llvm::outs() << Suffix.substr(1) << "\n"; - } +const Multilib &Multilib = TC.getMultilib(); +if (Multilib.gccSuffix().empty()) + llvm::outs() << ".\n"; +else { + StringRef Suffix(Multilib.gccSuffix()); + assert(Suffix.front() == '/'); + llvm::outs() << Suffix.substr(1) << "\n"; } return false; } Index: include/clang/Driver/ToolChain.h === --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -149,6 +149,7 @@ protected: MultilibSet Multilibs; + Multilib SelectedMultilib; ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args); @@ -227,6 +228,8 @@ const MultilibSet &getMultilibs() const { return Multilibs; } + const Multilib &getMultilib() const { return SelectedMultilib; } + const SanitizerArgs& getSanitizerArgs() const; const XRayArgs& getXRayArgs() const; ___ cfe-commits mailing lis
[PATCH] D51354: Fix the -print-multi-directory flag to print the selected multilib.
chrib added a comment. https://bugs.llvm.org/show_bug.cgi?id=21360 Repository: rC Clang https://reviews.llvm.org/D51354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51354: Fix the -print-multi-directory flag to print the selected multilib.
This revision was automatically updated to reflect the committed changes. Closed by commit rC341373: Fix the -print-multi-directory flag to print the selected multilib. (authored by chrib, committed by ). Changed prior to commit: https://reviews.llvm.org/D51354?vs=162846&id=163835#toc Repository: rC Clang https://reviews.llvm.org/D51354 Files: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChains/Linux.cpp test/Driver/print-multi-directory.c Index: test/Driver/print-multi-directory.c === --- test/Driver/print-multi-directory.c +++ test/Driver/print-multi-directory.c @@ -0,0 +1,28 @@ +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86-MULTILIBS %s + +// CHECK-X86-MULTILIBS: 32 +// CHECK-X86-MULTILIBS-NOT: x32 +// CHECK-X86-MULTILIBS-NOT: . + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-none-linux -m64 \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-X86_64-MULTILIBS %s + +// CHECK-X86_64-MULTILIBS: . +// CHECK-X86_64-MULTILIBS-NOT: x32 +// CHECK-X86_64-MULTILIBS-NOT: 32 + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \ +// RUN: -mthumb \ +// RUN: -B%S/Inputs/basic_android_ndk_tree \ +// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \ +// RUN: -print-multi-directory \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-MULTILIBS %s + +// CHECK-ARM-MULTILIBS: thumb +// CHECK-ARM-MULTILIBS-NOT: . Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -210,6 +210,7 @@ : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); Multilibs = GCCInstallation.getMultilibs(); + SelectedMultilib = GCCInstallation.getMultilib(); llvm::Triple::ArchType Arch = Triple.getArch(); std::string SysRoot = computeSysRoot(); @@ -299,16 +300,14 @@ if (GCCInstallation.isValid()) { const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); const std::string &LibPath = GCCInstallation.getParentLibPath(); -const Multilib &Multilib = GCCInstallation.getMultilib(); -const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); // Add toolchain / multilib specific file paths. -addMultilibsFilePaths(D, Multilibs, Multilib, +addMultilibsFilePaths(D, Multilibs, SelectedMultilib, GCCInstallation.getInstallPath(), Paths); // Sourcery CodeBench MIPS toolchain holds some libraries under // a biarch-like suffix of the GCC installation. -addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), +addPathIfExists(D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(), Paths); // GCC cross compiling toolchains will install target libraries which ship @@ -330,7 +329,7 @@ // Note that this matches the GCC behavior. See the below comment for where // Clang diverges from GCC's behavior. addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + - OSLibDir + Multilib.osSuffix(), + OSLibDir + SelectedMultilib.osSuffix(), Paths); // If the GCC installation we found is inside of the sysroot, we want to Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1661,14 +1661,13 @@ } if (C.getArgs().hasArg(options::OPT_print_multi_directory)) { -for (const Multilib &Multilib : TC.getMultilibs()) { - if (Multilib.gccSuffix().empty()) -llvm::outs() << ".\n"; - else { -StringRef Suffix(Multilib.gccSuffix()); -assert(Suffix.front() == '/'); -llvm::outs() << Suffix.substr(1) << "\n"; - } +const Multilib &Multilib = TC.getMultilib(); +if (Multilib.gccSuffix().empty()) + llvm::outs() << ".\n"; +else { + StringRef Suffix(Multilib.gccSuffix()); + assert(Suffix.front() == '/'); + llvm::outs() << Suffix.substr(1) << "\n"; } return false; } Index: include/clang/Driver/ToolChain.h === --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -149,6 +149,7 @@ protected: MultilibSet Multilibs; + Multilib SelectedMultilib; ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args); @@ -227,6 +228,8 @@ const MultilibSet &getMultilibs() const { return Multilibs; } + const Multilib &getMultilib() const { return Select
[PATCH] D51354: Fix the -print-multi-directory flag to print the selected multilib.
chrib added a comment. Re-commit patch at r341547 with modified test case to use an explicit root tree for libraries Repository: rC Clang https://reviews.llvm.org/D51354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 135603. chrib added a comment. Herald added a subscriber: mehdi_amini. hello, realizing that this has been stuck for a while now. did I answer all the concerns ? rebased patch, gentle ping :-) many thanks, Christian https://reviews.llvm.org/D31140 Files: lib/CodeGen/AsmPrinter/ARMException.cpp lib/Target/ARM/ARMAsmPrinter.cpp test/CodeGen/ARM/PR35379.ll test/CodeGen/ARM/atomic-cmpxchg.ll test/CodeGen/ARM/big-endian-eh-unwind.ll test/CodeGen/ARM/constantpool-promote-duplicate.ll test/CodeGen/ARM/constantpool-promote.ll test/CodeGen/ARM/disable-fp-elim.ll test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll test/CodeGen/ARM/ehabi-handlerdata.ll test/CodeGen/ARM/ehabi-no-landingpad.ll test/CodeGen/ARM/ehabi.ll test/CodeGen/ARM/execute-only.ll test/CodeGen/ARM/float-helpers.s test/CodeGen/ARM/fp16-promote.ll test/CodeGen/ARM/illegal-bitfield-loadstore.ll test/CodeGen/ARM/select_const.ll test/CodeGen/ARM/setcc-logic.ll test/CodeGen/ARM/vcvt.ll test/CodeGen/ARM/vuzp.ll test/CodeGen/Thumb/copy_thumb.ll test/CodeGen/Thumb/mvn.ll test/CodeGen/Thumb/stm-scavenging.ll test/LTO/ARM/link-arm-and-thumb.ll test/MC/ARM/data-in-code.ll Index: test/MC/ARM/data-in-code.ll === --- test/MC/ARM/data-in-code.ll +++ test/MC/ARM/data-in-code.ll @@ -9,7 +9,7 @@ ;; Ensure that if a jump table is generated that it has Mapping Symbols ;; marking the data-in-code region. -define void @foo(i32* %ptr, i32 %b) nounwind uwtable ssp { +define void @foo(i32* %ptr, i32 %b) nounwind ssp { %tmp = load i32, i32* %ptr, align 4 switch i32 %tmp, label %exit [ i32 0, label %bb0 Index: test/LTO/ARM/link-arm-and-thumb.ll === --- test/LTO/ARM/link-arm-and-thumb.ll +++ test/LTO/ARM/link-arm-and-thumb.ll @@ -14,6 +14,7 @@ ; CHECK: .code 32 ; CHECK-NEXT: main +; CHECK-NEXT: .fnstart ; CHECK-NEXT: mov r0, #30 ; CHECK: .code 16 Index: test/CodeGen/Thumb/stm-scavenging.ll === --- test/CodeGen/Thumb/stm-scavenging.ll +++ test/CodeGen/Thumb/stm-scavenging.ll @@ -3,6 +3,8 @@ ; Use STM to save the three registers ; CHECK-LABEL: use_stm: +; CHECK: .save {r7, lr} +; CHECK: .setfp r7, sp ; CHECK: stm r3!, {r0, r1, r2} ; CHECK: bl throws_1 define void @use_stm(i32 %a, i32 %b, i32 %c, i32* %d) local_unnamed_addr noreturn "no-frame-pointer-elim"="true" { @@ -21,6 +23,8 @@ ; the address. We could transform this with some extra math, but ; that currently isn't implemented. ; CHECK-LABEL: no_stm: +; CHECK: .save {r7, lr} +; CHECK: .setfp r7, sp ; CHECK: str r0, ; CHECK: str r1, ; CHECK: str r2, Index: test/CodeGen/Thumb/mvn.ll === --- test/CodeGen/Thumb/mvn.ll +++ test/CodeGen/Thumb/mvn.ll @@ -61,6 +61,7 @@ define void @loop8_2(i8* %a, i8* %b) { ; CHECK-LABEL: loop8_2: +; CHECK: .save {r4, lr} ; CHECK-NEXT:push {r4, lr} ; CHECK-NEXT:movs r2, #0 ; CHECK-NEXT: .LBB3_1: @@ -155,6 +156,7 @@ define void @loop32_2(i32* %a, i32* %b) { ; CHECK-LABEL: loop32_2: +; CHECK: .save {r4, lr} ; CHECK-NEXT:push {r4, lr} ; CHECK-NEXT:movs r2, #0 ; CHECK-NEXT: .LBB7_1: Index: test/CodeGen/Thumb/copy_thumb.ll === --- test/CodeGen/Thumb/copy_thumb.ll +++ test/CodeGen/Thumb/copy_thumb.ll @@ -10,6 +10,7 @@ ; CHECK-LOLOMOV-NEXT: mov [[SRC1]], [[SRC2:r[01]]] ; CHECK-LOLOMOV-NEXT: mov [[SRC2]], [[TMP]] ; CHECK-LOLOMOV-LABEL: bar +; CHECK-LOLOMOV-LABEL: fnend ; ; 'MOV lo, lo' in Thumb mode produces undefined results on pre-v6 hardware ; RUN: llc -mtriple=thumbv4t-none--eabi < %s | FileCheck %s --check-prefix=CHECK-NOLOLOMOV @@ -19,6 +20,7 @@ ; CHECK-NOLOLOMOV-NEXT: movs [[SRC1]], [[SRC2:r[01]]] ; CHECK-NOLOLOMOV-NEXT: movs [[SRC2]], [[TMP]] ; CHECK-NOLOLOMOV-LABEL: bar +; CHECK-NOLOLOMOV-LABEL: fnend declare void @bar(i32, i32) Index: test/CodeGen/ARM/vuzp.ll === --- test/CodeGen/ARM/vuzp.ll +++ test/CodeGen/ARM/vuzp.ll @@ -353,6 +353,7 @@ define <8 x i8> @vuzp_trunc_and_shuffle(<8 x i8> %tr0, <8 x i8> %tr1, ; CHECK-LABEL: vuzp_trunc_and_shuffle: ; CHECK: @ %bb.0: +; CHECK-NEXT: .save {r11, lr} ; CHECK-NEXT: push {r11, lr} ; CHECK-NEXT: add r12, sp, #8 ; CHECK-NEXT: add lr, sp, #24 @@ -458,7 +459,9 @@ define <10 x i8> @vuzp_wide_type(<10 x i8> %tr0, <10 x i8> %tr1, ; CHECK-LABEL: vuzp_wide_type: ; CHECK: @ %bb.0: +; CHECK-NEXT: .save {r4, r10, r11, lr} ; CHECK-NEXT: push {r4, r10, r11, lr} +; CHECK-NEXT: .setfp r11, sp, #8 ; CHECK-NEXT: add r11, sp, #8 ; CHECK-NEXT: bic sp, sp, #15 ; CHECK-NEXT: add r12, r11, #32 Index: test/CodeGen/ARM/vcvt.ll ===
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 135610. chrib added a comment. damn it last diff was the llvm part (https://reviews.llvm.org/D31139). Here is the clang part. sorry for the noise, still not experienced with Phabricator. https://reviews.llvm.org/D31140 Files: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Arch/ARM.cpp lib/Driver/ToolChains/Arch/ARM.h lib/Driver/ToolChains/BareMetal.cpp lib/Driver/ToolChains/BareMetal.h lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CrossWindows.cpp lib/Driver/ToolChains/CrossWindows.h lib/Driver/ToolChains/Darwin.cpp lib/Driver/ToolChains/Darwin.h lib/Driver/ToolChains/Fuchsia.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Gnu.h lib/Driver/ToolChains/Linux.cpp lib/Driver/ToolChains/Linux.h lib/Driver/ToolChains/MSVC.cpp lib/Driver/ToolChains/MSVC.h lib/Driver/ToolChains/MinGW.cpp lib/Driver/ToolChains/MinGW.h lib/Driver/ToolChains/NetBSD.h test/Driver/arm-unwind.c test/Driver/arm-unwind.cpp Index: test/Driver/arm-unwind.cpp === --- /dev/null +++ test/Driver/arm-unwind.cpp @@ -0,0 +1,9 @@ +// Add function attribute "uwtable" for arm ehabi targets in C++. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI: -munwind-tables + +// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU: -munwind-tables Index: test/Driver/arm-unwind.c === --- /dev/null +++ test/Driver/arm-unwind.c @@ -0,0 +1,9 @@ +// Do not add function attribute "uwtable" for arm ehabi targets for C mode. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI-NOT: -munwind-tables + +// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU-NOT: -munwind-tables Index: lib/Driver/ToolChains/NetBSD.h === --- lib/Driver/ToolChains/NetBSD.h +++ lib/Driver/ToolChains/NetBSD.h @@ -65,7 +65,7 @@ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override { return true; } Index: lib/Driver/ToolChains/MinGW.h === --- lib/Driver/ToolChains/MinGW.h +++ lib/Driver/ToolChains/MinGW.h @@ -60,7 +60,7 @@ const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -8,6 +8,7 @@ //===--===// #include "MinGW.h" +#include "Arch/ARM.h" #include "InputInfo.h" #include "CommonArgs.h" #include "clang/Driver/Compilation.h" @@ -353,8 +354,18 @@ return new tools::MinGW::Linker(*this); } -bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { - return getArch() == llvm::Triple::x86_64; +bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, types::ID InputType) const { + switch (getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +return tools::arm::ARMNeedUnwindTable(Args, types::isCXX(InputType)); + case llvm::Triple::x86_64: +return true; + default: +return false; + } } bool toolchains::MinGW::isPICDefault() const { Index: lib/Driver/ToolChains/MSVC.h === --- lib/Driver/ToolChains/MSVC.h +++ lib/Driver/ToolChains/MSVC.h @@ -73,7 +73,8 @@ Action::OffloadKind DeviceOffloadKind) const override; bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, + types::ID InputType) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: lib/Driver/ToolChains/MSVC.cpp === -
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:569 + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { efriedma wrote: > Specifically checking for "llvm::Triple::EABI" is suspicious... what are you > trying to distinguish? I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by the way) I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is probably conservative and stick to what I can test. Do you think this pertains to more, for instance to AAPCS-LINUX, without breaking anything ? https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 101543. chrib added a comment. Herald added a subscriber: kristof.beyls. - Merge branch 'master' of ssh://codex.cro.st.com/llvm-arm/clang - Don't need a frame pointer for EABIHF also (AAPCS) https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/frame-pointer.c Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:569 + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { efriedma wrote: > chrib wrote: > > efriedma wrote: > > > Specifically checking for "llvm::Triple::EABI" is suspicious... what are > > > you trying to distinguish? > > I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by > > the way) > > > > I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is > > probably conservative and stick to what I can test. Do you think this > > pertains to more, for instance to AAPCS-LINUX, without breaking anything ? > > > So... something like isTargetAEABI() in ARMSubtarget.h? > > Please clarify the comment, and add a check for EABIHF. yes, (although I'm not sure for Darwin). The closest check for AAPCS I've found is Clang::AddARMTargetArgs. I've updated the patch to check EABIHF as well. https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib added a comment. OK, I have created a RFE tracker (BZ #32501). I will forward to cfe-dev. Regarding the need to avoid table-based unwinding, the way to handle those request for an explicit frame pointer when not required by the ABI is to use -fno-omit-frame-pointer flag, catching up with the GCC behavior. Also I'm not sure that the unwind table space is such an issue (for debugging) since they are not loadable. Other uses such as profiling is not be impacted by the change, and exceptions unwinder likelibgcc or libunwind should work without the frame pointer I'll amend the patch to check for Darwin and Netbsd. https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 101675. chrib added a comment. - do not omit the frame pointer for netbsd-eabi and darwin-eabi https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/frame-pointer.c Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,19 @@ } } + if (!Triple.isOSDarwin() && !Triple.isOSNetBSD() && + (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF)) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,19 @@ } } + if (!Triple.isOSDarwin() && !Triple.isOSNetBSD() && + (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF)) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52533: [test] Use --sysroot instead of -B in print-multi-directory.c
chrib added a reviewer: jroelofs. chrib added a comment. Hi Martin, maybe just a NIT, use --sysroot= rather than just --sysroot for consistency with other tests. Otherwise looks good to me, thanks (adding Jonathan as I'm not sure I can accept) Repository: rC Clang https://reviews.llvm.org/D52533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 113846. chrib added a comment. Herald added a subscriber: kristof.beyls. Rebase and cleanup NeedsUnwindTable for be variants. https://reviews.llvm.org/D31140 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1334,6 +1334,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -914,13 +914,32 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + // xxx checkarm eabi needs to emit the nowind attribute. + // implement function ins ARM.cpp + const llvm::Triple T = Context.getTargetInfo().getTriple(); + if (hasUnwindExceptions (LangOpts) + && (T.isARM() || T.isThumb ()) + && (T.getEnvironment() == llvm::Triple::EABI)) + return true; + + return false; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1334,6 +1334,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -914,13 +914,32 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + // xxx checkarm eabi needs to emit the nowind attribute. + // implement function ins ARM.cpp + const llvm::Triple T = Context.getTargetInfo().getTriple(); + if (hasUnwindExceptions (LangOpts) + && (T.isARM() || T.isThumb ()) + && (T.getEnvironment() == llvm::Triple::EABI)) + return true; + + return false; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib planned changes to this revision. chrib added a comment. Yes, I also tried to look into this direction, but I did not found a clean way from the driver to emit the attribute based on codegen options. Also unwind-tables must not be the default. (for C this is what I want to eliminate). In fact I haven't found an example of setting attributes in the driver. not sure it's even possible. Also, setting this new uwtable attribute close to the existing NoUnwind attribute in CodeGen makes the orthogonality both attributes more obvious (or less obscure :-). This said, testing for the Triple Arch here is not clean (I probably prefer a target overloads) but that was a conservative approach. to avoid that we would need to propose a follow up that simplifies the code as: // We might need an unwind table, even if the function cannot throw. if (hasUnwindExceptions(LangOpts) || CodeGenOpts.UnwindTables) B.addAttribute(llvm::Attribute::UWTable); // If the module doesn't support exceptions the function cannot throw. // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); but this will impact all targets and can cause other changes in the backend, so it's probably better to do this separately. Do you have an advice on that ? thanks, https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. forgot to give the motivating figure. this brings a code size reduction of 9.5 % (geomean of text sections sizes) on coremarkpro -Oz for cortex-m3 eabi https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 114589. chrib added a comment. Hello Eli, You were right, using IsUnwindTablesDefault is the correct way to abstract the need for UnwindTables. I missed the relationship between the driver munwind-table and GodeGenOpts.UnwindTables use in Codegen. Here is a new patch just setting IsUnwindTablesDefault for EHABI. No Changes in the testsuite results with https://reviews.llvm.org/D31139 https://reviews.llvm.org/D31140 Files: lib/Driver/ToolChains/BareMetal.cpp lib/Driver/ToolChains/BareMetal.h Index: lib/Driver/ToolChains/BareMetal.h === --- lib/Driver/ToolChains/BareMetal.h +++ lib/Driver/ToolChains/BareMetal.h @@ -32,6 +32,7 @@ public: bool useIntegratedAs() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isCrossCompiling() const override { return true; } bool isPICDefault() const override { return false; } bool isPIEDefault() const override { return false; } Index: lib/Driver/ToolChains/BareMetal.cpp === --- lib/Driver/ToolChains/BareMetal.cpp +++ lib/Driver/ToolChains/BareMetal.cpp @@ -57,6 +57,10 @@ return true; } +bool BareMetal::IsUnwindTablesDefault(const ArgList &Args) const { + return getDriver().CCCIsCXX(); +} + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { return isARMBareMetal(Triple); } Index: lib/Driver/ToolChains/BareMetal.h === --- lib/Driver/ToolChains/BareMetal.h +++ lib/Driver/ToolChains/BareMetal.h @@ -32,6 +32,7 @@ public: bool useIntegratedAs() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isCrossCompiling() const override { return true; } bool isPICDefault() const override { return false; } bool isPIEDefault() const override { return false; } Index: lib/Driver/ToolChains/BareMetal.cpp === --- lib/Driver/ToolChains/BareMetal.cpp +++ lib/Driver/ToolChains/BareMetal.cpp @@ -57,6 +57,10 @@ return true; } +bool BareMetal::IsUnwindTablesDefault(const ArgList &Args) const { + return getDriver().CCCIsCXX(); +} + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { return isARMBareMetal(Triple); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. OK, we can refine so that unwind-table is also not generated for C++ -fno-exceptions. To summarize this gives or C++ : || Unwind (table) | Exceptions (can throw) | | default| Y| Y | | fno-unwind | N| Y (1) | | fno-exceptions | N| N | (1) without unwind, no handler can be found so the default is to terminate. for C : | | Unwind (table) | Exceptions (can throw) | | default | N| N | | funwind | Y| N | | fexceptions | Y| N | Cheers, https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 115176. chrib added a comment. Update IsUnwindTablesDefault to test fno-exceptions. (see Darwin.cpp) Add comments. https://reviews.llvm.org/D31140 Files: lib/Driver/ToolChains/BareMetal.cpp lib/Driver/ToolChains/BareMetal.h Index: lib/Driver/ToolChains/BareMetal.h === --- lib/Driver/ToolChains/BareMetal.h +++ lib/Driver/ToolChains/BareMetal.h @@ -32,6 +32,7 @@ public: bool useIntegratedAs() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isCrossCompiling() const override { return true; } bool isPICDefault() const override { return false; } bool isPIEDefault() const override { return false; } Index: lib/Driver/ToolChains/BareMetal.cpp === --- lib/Driver/ToolChains/BareMetal.cpp +++ lib/Driver/ToolChains/BareMetal.cpp @@ -57,6 +57,14 @@ return true; } +bool BareMetal::IsUnwindTablesDefault(const ArgList &Args) const { + // Unwind tables are not emitted in C or if -fno-exceptions is supplied. + // For C++ we cannot rely on UWTable because we still need the .exidx section + // even if the function does not throw. + return Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + getDriver().CCCIsCXX()); +} + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { return isARMBareMetal(Triple); } Index: lib/Driver/ToolChains/BareMetal.h === --- lib/Driver/ToolChains/BareMetal.h +++ lib/Driver/ToolChains/BareMetal.h @@ -32,6 +32,7 @@ public: bool useIntegratedAs() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isCrossCompiling() const override { return true; } bool isPICDefault() const override { return false; } bool isPIEDefault() const override { return false; } Index: lib/Driver/ToolChains/BareMetal.cpp === --- lib/Driver/ToolChains/BareMetal.cpp +++ lib/Driver/ToolChains/BareMetal.cpp @@ -57,6 +57,14 @@ return true; } +bool BareMetal::IsUnwindTablesDefault(const ArgList &Args) const { + // Unwind tables are not emitted in C or if -fno-exceptions is supplied. + // For C++ we cannot rely on UWTable because we still need the .exidx section + // even if the function does not throw. + return Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + getDriver().CCCIsCXX()); +} + bool BareMetal::handlesTarget(const llvm::Triple &Triple) { return isARMBareMetal(Triple); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. oops yes of course. I forgot some bits while switching from testing the arch to testing the platform. indeed --target=arm-none-linux-gnueabihf lost its unwind info in c++. Surprisingly not caught by the llvm tests, will add some. thanks https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. Hello, I didn't find an easy way factorize the change in IsUnwindTableDefault to support the multiple ARM toolchains. After a quick check in Triple::arm in Driver/Toochains, many seem impacted (excepted NetBSD and Darwin that uses DwarfCFI or SJLG). So here is an attempt to move this into a small arm hook and use. Also, I realized that the cxx tests was not correctly checked because most of them are invoked as "clang" instead if "clang++" So another proposal is to check the input type in IsUnwindTablesDefault. Finally I've added the clang tests to check for this. thanks ! https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 116176. chrib added a comment. Herald added a subscriber: javed.absar. Changes since last revision: - Check IsUnwindTablesDefault in ARM Toolchains that support ExceptionHandling::ARM (not Darwin, NetBSD) - Check input type with driver mode for C++ mode. - Add Tests https://reviews.llvm.org/D31140 Files: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Arch/ARM.cpp lib/Driver/ToolChains/Arch/ARM.h lib/Driver/ToolChains/BareMetal.cpp lib/Driver/ToolChains/BareMetal.h lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CrossWindows.cpp lib/Driver/ToolChains/CrossWindows.h lib/Driver/ToolChains/Darwin.cpp lib/Driver/ToolChains/Darwin.h lib/Driver/ToolChains/Gnu.cpp lib/Driver/ToolChains/Gnu.h lib/Driver/ToolChains/MSVC.cpp lib/Driver/ToolChains/MSVC.h lib/Driver/ToolChains/MinGW.cpp lib/Driver/ToolChains/MinGW.h lib/Driver/ToolChains/NetBSD.h test/Driver/arm-unwind.c test/Driver/arm-unwind.cpp Index: test/Driver/arm-unwind.cpp === --- /dev/null +++ test/Driver/arm-unwind.cpp @@ -0,0 +1,9 @@ +// Add function attribute "uwtable" for arm ehabi targets in C++. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI: -munwind-tables + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN:| FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU: -munwind-tables Index: test/Driver/arm-unwind.c === --- /dev/null +++ test/Driver/arm-unwind.c @@ -0,0 +1,9 @@ +// Do not add function attribute "uwtable" for arm ehabi targets for C mode. + +// RUN: %clang -target arm-none-eabi -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-EABI %s +// CHECK-EABI-NOT: -munwind-tables + +// RUN: %clang -target arm--linux-gnueabihf -### -S %s -o %t.s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-GNU %s +// CHECK-GNU-NOT: -munwind-tables Index: lib/Driver/ToolChains/NetBSD.h === --- lib/Driver/ToolChains/NetBSD.h +++ lib/Driver/ToolChains/NetBSD.h @@ -65,7 +65,7 @@ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override { return true; } Index: lib/Driver/ToolChains/MinGW.h === --- lib/Driver/ToolChains/MinGW.h +++ lib/Driver/ToolChains/MinGW.h @@ -60,7 +60,7 @@ const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -8,6 +8,7 @@ //===--===// #include "MinGW.h" +#include "Arch/ARM.h" #include "InputInfo.h" #include "CommonArgs.h" #include "clang/Driver/Compilation.h" @@ -358,8 +359,19 @@ return new tools::MinGW::Linker(*this); } -bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { - return getArch() == llvm::Triple::x86_64; +bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, bool isCXX) const { + // Unwind tables are emitted when targeting x86_64 and ARM for C++ or -fexceptions). + switch (getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +return tools::arm::ARMNeedUnwindTable(Args, isCXX); + case llvm::Triple::x86_64: +return true; + default: +return false; + } } bool toolchains::MinGW::isPICDefault() const { Index: lib/Driver/ToolChains/MSVC.h === --- lib/Driver/ToolChains/MSVC.h +++ lib/Driver/ToolChains/MSVC.h @@ -73,7 +73,7 @@ Action::OffloadKind DeviceOffloadKind) const override; bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, bool isCXX) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; Index: lib/Driver/ToolChains/MSVC.cpp === -
[PATCH] D45814: Fix an assertion when -print-prog-name= is invoked without parameter. Returns an empty string.
chrib created this revision. Herald added a subscriber: cfe-commits. Fix an assertion when -print-prog-name= Repository: rC Clang https://reviews.llvm.org/D45814 Files: lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -4053,6 +4053,11 @@ } std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const { + + // Null program name cannot have a path. + if (Name.empty()) +return Name.str(); + SmallVector TargetSpecificExecutables; generatePrefixedToolNames(Name, TC, TargetSpecificExecutables); Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -4053,6 +4053,11 @@ } std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const { + + // Null program name cannot have a path. + if (Name.empty()) +return Name.str(); + SmallVector TargetSpecificExecutables; generatePrefixedToolNames(Name, TC, TargetSpecificExecutables); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45814: Fix an assertion when -print-prog-name=
chrib updated this revision to Diff 144322. chrib added a comment. Move the non-null name check out of GetProgramPath and add a test case. Assume that we trust the callers to check for non null ProgramName. Repository: rC Clang https://reviews.llvm.org/D45814 Files: lib/Driver/Driver.cpp test/Driver/print-empty-prog-name.c Index: test/Driver/print-empty-prog-name.c === --- /dev/null +++ test/Driver/print-empty-prog-name.c @@ -0,0 +1,5 @@ +// Test that -print-prog-name= correctly returns an empty string + +// RUN: %clang -print-prog-name= 2>&1 | FileCheck %s +// CHECK-NOT:{{.+}} + Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1589,7 +1589,13 @@ } if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) { -llvm::outs() << GetProgramPath(A->getValue(), TC) << "\n"; +StringRef ProgName = A->getValue(); + +// Null program name cannot have a path. +if (! ProgName.empty()) + llvm::outs() << GetProgramPath(ProgName, TC); + +llvm::outs() << "\n"; return false; } @@ -4053,6 +4059,7 @@ } std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const { + SmallVector TargetSpecificExecutables; generatePrefixedToolNames(Name, TC, TargetSpecificExecutables); Index: test/Driver/print-empty-prog-name.c === --- /dev/null +++ test/Driver/print-empty-prog-name.c @@ -0,0 +1,5 @@ +// Test that -print-prog-name= correctly returns an empty string + +// RUN: %clang -print-prog-name= 2>&1 | FileCheck %s +// CHECK-NOT:{{.+}} + Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1589,7 +1589,13 @@ } if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) { -llvm::outs() << GetProgramPath(A->getValue(), TC) << "\n"; +StringRef ProgName = A->getValue(); + +// Null program name cannot have a path. +if (! ProgName.empty()) + llvm::outs() << GetProgramPath(ProgName, TC); + +llvm::outs() << "\n"; return false; } @@ -4053,6 +4059,7 @@ } std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const { + SmallVector TargetSpecificExecutables; generatePrefixedToolNames(Name, TC, TargetSpecificExecutables); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45814: Fix an assertion when -print-prog-name=
chrib added a comment. Hi Saleem, Thanks for your review. I have amended the patch to avoid checking the name on the common path. About your second comment, I'm not sure we have to fix -print-file-name= for an equivalent problem since in case of empty parameter, we do a concatenation with the driver's path, which seems to be fine. Best Regards Christian Repository: rC Clang https://reviews.llvm.org/D45814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45814: Fix an assertion when -print-prog-name=
chrib added a comment. In https://reviews.llvm.org/D45814#1081203, @compnerd wrote: > Do you have commit access or do you need someone to commit this on your > behalf? can you commit it for me please ? thanks. Repository: rC Clang https://reviews.llvm.org/D45814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. In https://reviews.llvm.org/D31140#706411, @jroelofs wrote: > Can you clarify the logic here? It's my understanding that: > > `-fno-exceptions` does *not* imply `-fno-unwind-tables` > > however: > > `-fno-unwind-tables` *does* imply that exceptions cannot be used on targets > that require the tables to do unwinding. Yes, (bad things might happen or (std::terminate will be called, or destructors not called.)... But -f[no]-unwind-tables implies the UWTable attribute, not NoUwind attribute. To toggle NoUnwind, use -fno-exceptions And this is getting worse with .canunwind which means DoesNotThrow :) in my understanding, the logic is as follow: Since "An exception cannot propagate through a function with a nounwind table. The exception handling runtime environment terminates the program if it encounters a nounwind table during exception processing." (ARM Information Center) The "nounwind" LLVM attribute, which means "Function does not throw" translates as the EXIDX_CANTUNWIND value in the exception table index table which needs to be created for the purpose (for the function) And of course without exception runtime environment (the test here) we don't need this table. So I can see 3 cases: - nounwind set :Generate .cantunwind directive and unwind table - nounwind set but not EH Do not generate the .cantunwind directive and do not emit the unwind table - uwtable set Need to generate the unwind table (even without EH) The disable-arm-cantunwind flag means: without EH support if the function does not throw, do dot generate the exception tables and the EXIDX_CANTUNWIND value. https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib added a comment. Yes we can enable cantunwind with the nothrow gcc attribute when exceptions are enabled Forcing it in exceptions are not enabled (e.g for attribute cleanup) would require -funwind-tables at function level anyway So the flag should work, but conceptually I think you are right, this semantic should be better carried thru attributes, hopefully without adding a new one https://reviews.llvm.org/D31140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 93631. chrib added a dependency: D31139: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed with EHABI. chrib added a comment. 1. Updating https://reviews.llvm.org/D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI # Set UNTable of the language requiers an exception table. Conservately only for ARM, necessary to emit the .cantunwind directive. But could probably be enabled for all targets. depends on https://reviews.llvm.org/D31139 https://reviews.llvm.org/D31140 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,9 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + bool needsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,25 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::needsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && Arch==llvm::Triple::arm; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (needsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,9 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + bool needsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,25 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::needsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && Arch==llvm::Triple::arm; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (needsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 94329. chrib added a comment. - NeedsUnwindTable check thumb arch https://reviews.llvm.org/D31140 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,27 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && +(Arch == llvm::Triple::arm || + Arch == llvm::Triple::thumb); +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,27 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && +(Arch == llvm::Triple::arm || + Arch == llvm::Triple::thumb); +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib created this revision. Herald added a subscriber: aemerson. Do not force the frame pointer by default for ARM EABI (bugzilla #32501) https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 95945. chrib added a comment. 1. Updating https://reviews.llvm.org/D31972: Do not force the frame pointer by default for ARM EABI # Add test case https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/CodeGen/arm-fp-eabi.c Index: test/CodeGen/arm-fp-eabi.c === --- /dev/null +++ test/CodeGen/arm-fp-eabi.c @@ -0,0 +1,13 @@ +// RUN: %clang %s -target arm-none-eabi -O2 -S -o nofp.s +// RUN: grep -v '.setfp' nofp.s +// RUN: %clang %s -target arm-none-eabi -fno-omit-frame-pointer -O2 -S -o fp.s +// RUN: grep '.setfp' fp.s + +void +foo(void); + +int main() +{ + foo(); + return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/CodeGen/arm-fp-eabi.c === --- /dev/null +++ test/CodeGen/arm-fp-eabi.c @@ -0,0 +1,13 @@ +// RUN: %clang %s -target arm-none-eabi -O2 -S -o nofp.s +// RUN: grep -v '.setfp' nofp.s +// RUN: %clang %s -target arm-none-eabi -fno-omit-frame-pointer -O2 -S -o fp.s +// RUN: grep '.setfp' fp.s + +void +foo(void); + +int main() +{ + foo(); + return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 95958. chrib added a comment. - Fix thinko in test https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/CodeGen/arm-fp-eabi.c Index: test/CodeGen/arm-fp-eabi.c === --- /dev/null +++ test/CodeGen/arm-fp-eabi.c @@ -0,0 +1,13 @@ +// RUN: %clang %s -target arm-none-eabi -O2 -S -o nofp.s +// RUN: not grep '.setfp' nofp.s +// RUN: %clang %s -target arm-none-eabi -fno-omit-frame-pointer -O2 -S -o fp.s +// RUN: grep '.setfp' fp.s + +void +foo(void); + +int main() +{ + foo(); + return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/CodeGen/arm-fp-eabi.c === --- /dev/null +++ test/CodeGen/arm-fp-eabi.c @@ -0,0 +1,13 @@ +// RUN: %clang %s -target arm-none-eabi -O2 -S -o nofp.s +// RUN: not grep '.setfp' nofp.s +// RUN: %clang %s -target arm-none-eabi -fno-omit-frame-pointer -O2 -S -o fp.s +// RUN: grep '.setfp' fp.s + +void +foo(void); + +int main() +{ + foo(); + return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 96109. chrib added a comment. - Check not mdisable-fp-elim for arm eabi when optimizing https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/frame-pointer.c Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,17 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + // ARM EABI doesn't require a frame pointer + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib added inline comments. Comment at: test/CodeGen/arm-fp-eabi.c:1 +// RUN: %clang %s -target arm-none-eabi -O2 -S -o nofp.s +// RUN: not grep '.setfp' nofp.s ahatanak wrote: > Instead of generating a .s file and looking for ".setfp", you can pass -### > and check the presence or absence of -mdisable-fp-elim (see other tests in > test/Driver). yes sure, I extended the existing frame-pointer.c with the test similar to other archs. Thanks https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits