[PATCH] D56878: [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls'
sdardis added inline comments. Comment at: cfe/trunk/include/clang/Driver/Options.td:2423 + Group, + HelpText<"Try turning PIC calls (j{al}r{c} $25) into direct calls " + "(MIPS only)">, Flags<[HelpHidden]>; I think this help text could be a little better. Instead of implying that the compiler could turn PIC calls into direct calls, something like "Produce relaxation hints for linkers to try optimizing PIC call sequences into direct calls", I believe describes the optimization better. Likewise in the negative sense for the -mno-relax-pic-calls. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56878/new/ https://reviews.llvm.org/D56878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55878: [Driver] Use --hash-style=gnu instead of both on FreeBSD
sdardis added a comment. > I can't find rationale behind the MIPS discrepancy in the original commit. I > can add the if branch back if you tell me why... From my recollections, the gnu-hash style isn't supported in ld.bfd for MIPS. A patch was posted to the binutils list (https://sourceware.org/ml/binutils/2015-10/msg00057.html) to support this, but there was an issue with FSF copyright assignment. As the patch is non-trivial, it would have to be independently re-developed for submission to binutils and later lld. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55878/new/ https://reviews.llvm.org/D55878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51356: [docs][mips] Clang 7.0 Release notes
sdardis added inline comments. Comment at: ReleaseNotes.rst:121 +- On MIPS FreeBSD default CPUs have been changed to ``mips2`` + for 32-bit targets and ``mips3`` for 32-bit targets. + ``mips3`` for 64 bit targets. D48499. Repository: rC Clang https://reviews.llvm.org/D51356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48169: [mips] Add '-mcrc', '-mno-crc' options to enable/disable CRC ASE
sdardis added inline comments. Comment at: include/clang/Driver/Options.td:2214 HelpText<"Disable SVR4-style position-independent code (Mips only)">; +def mno_crc : Flag<["-"], "mno-crc">, Group, + HelpText<"Disallow use of CRC instructions (Mips only)">; atanasyan wrote: > Does it make a sense to define this option as an alias to the `mnocrc` and > allow to use both `-mno-crc` and `-mnocrc` for ARM and MIPS? I thought about commenting on that. The problem there is that you then permitting clang to be more lax than binutils which inhibits compatibility between the two tools. Repository: rC Clang https://reviews.llvm.org/D48169 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47829: [Driver] Accept the -fno-shrink-wrap option for GCC compatibility
sdardis added a comment. In https://reviews.llvm.org/D47829#1124040, @efriedma wrote: > Is this something which is actually useful to control? From your > description, you want to add the flag to clang not because you actually want > to use it, but just because you can't figure out how to pass the right flags > to your clang build. > > If it is useful, it should be implemented as a function attribute, not a > global flag. This is useful to control in the sense of being able to opt-in or opt-out of the shrink wrapping pass for clang, especially in the cases of where we might discover a triggerable bug in a released version of clang. Currently, the compiler-rt sanitizer tests make use of the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when generating the test objects. Working around this would require stripping the incompatible arguments from those variables when building the test objects. This seems to me to worse choice, as I'm also posting a patch to automatically add -fno-shrink-wrap when building LLVM with GCC for MIPS (https://reviews.llvm.org/D48069). Repository: rC Clang https://reviews.llvm.org/D47829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47829: [Driver] Accept the -fno-shrink-wrap option for GCC compatibility
sdardis updated this revision to Diff 150904. sdardis added a comment. Modify implementation to produce a function attribute. Repository: rC Clang https://reviews.llvm.org/D47829 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CodeGenFunction.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/noshrinkwrapping.c Index: test/CodeGen/noshrinkwrapping.c === --- /dev/null +++ test/CodeGen/noshrinkwrapping.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -S -fno-shrink-wrapping %s -emit-llvm -o - | FileCheck %s + +// CHECK-LABEL: main +// CHECK: attributes #0 = {{.*}}"no-shrink-wrapping"="true"{{.*}} + +int main() { + return 0; +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -743,6 +743,8 @@ Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions); + Opts.NoShrinkWrap = Args.hasArg(OPT_fno_shrink_wrap); + Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables); Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4054,6 +4054,9 @@ Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ); + if (Args.hasArg(options::OPT_fno_shrink_wrap)) +CmdArgs.push_back("-fno-shrink-wrap"); + // -fno-strict-overflow implies -fwrapv if it isn't disabled, but // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { Index: lib/CodeGen/CodeGenFunction.cpp === --- lib/CodeGen/CodeGenFunction.cpp +++ lib/CodeGen/CodeGenFunction.cpp @@ -935,6 +935,11 @@ } } + // Add no-shrink-wrap value. + if (CGM.getCodeGenOpts().NoShrinkWrap) +Fn->addFnAttr("no-shrink-wrap", + llvm::toStringRef(CGM.getCodeGenOpts().NoShrinkWrap)); + // Add no-jump-tables value. Fn->addFnAttr("no-jump-tables", llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables)); Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -216,6 +216,7 @@ CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report is enabled. CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled. CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled. +CODEGENOPT(NoShrinkWrap , 1, 0) ///< Set when -fno-shrink-wrap is enabled. CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled. CODEGENOPT(UnsafeFPMath , 1, 0) ///< Allow unsafe floating point optzns. CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1393,6 +1393,8 @@ HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group, Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">; +def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group, + Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">; def fno_spell_checking : Flag<["-"], "fno-spell-checking">, Group, Index: test/CodeGen/noshrinkwrapping.c === --- /dev/null +++ test/CodeGen/noshrinkwrapping.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -S -fno-shrink-wrapping %s -emit-llvm -o - | FileCheck %s + +// CHECK-LABEL: main +// CHECK: attributes #0 = {{.*}}"no-shrink-wrapping"="true"{{.*}} + +int main() { + return 0; +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -743,6 +743,8 @@ Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions); + Opts.NoShrinkWrap = Args.hasArg(OPT_fno_shrink_wrap); + Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables); Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4054,6 +4054,9
[PATCH] D47829: [Driver] Accept the -fno-shrink-wrap option for GCC compatibility
sdardis created this revision. sdardis added a reviewer: rsmith. Herald added a reviewer: javed.absar. Herald added subscribers: atanasyan, kristof.beyls, arichardson. As reported in GCC bug #86069, LLVM currently provokes a bug in GCC where objects compiled for MIPS with PIC and optimizations where shrink wrapped functions can attempt to access the global pointer's spill slot before the global pointer is spilled. This bug is present in GCC since at least 4.9.2, and affects the AArch64 backend when LLVM is built for a MIPS host. However, setting CMAKE_C_FLAGS and CMAKE_CXX_FLAGS affects the compiler-rt tests which rely on the just built clang rather than the host or cross GCC. Since Clang doesn't support this flag, so the tests spuriously fail. Unfortunately, not all targets support shrink wrapping in LLVM at this time, so providing -fshrink-wrap would expose users to any number of wrong-codegen issues. For targets that do support shrink wrapping, this option performs as expected. Repository: rC Clang https://reviews.llvm.org/D47829 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/shrink-wrap.c Index: test/Driver/shrink-wrap.c === --- /dev/null +++ test/Driver/shrink-wrap.c @@ -0,0 +1,12 @@ +// RUN: %clang -### %s -fno-shrink-wrap 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO < %t %s + +// The below case should be handled when shrink wrapping is available for all +// targets. + +// FIXME: %clang -### %s -fshrink-wrap 2> %t +// FIXME: FileCheck --check-prefix=CHECK-YES < %t %s + +// CHECK-NO: "-mllvm" "-enable-shrink-wrap=false" + +// CHECK-YES: "-mllvm" "-enable-shrink-wrap=true" Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4047,6 +4047,11 @@ Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ); + if (Args.hasArg(options::OPT_fno_shrink_wrap)) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back("-enable-shrink-wrap=false"); + } + // -fno-strict-overflow implies -fwrapv if it isn't disabled, but // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1388,6 +1388,8 @@ HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group, Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">; +def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group, + Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">; def fno_spell_checking : Flag<["-"], "fno-spell-checking">, Group, Index: test/Driver/shrink-wrap.c === --- /dev/null +++ test/Driver/shrink-wrap.c @@ -0,0 +1,12 @@ +// RUN: %clang -### %s -fno-shrink-wrap 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO < %t %s + +// The below case should be handled when shrink wrapping is available for all +// targets. + +// FIXME: %clang -### %s -fshrink-wrap 2> %t +// FIXME: FileCheck --check-prefix=CHECK-YES < %t %s + +// CHECK-NO: "-mllvm" "-enable-shrink-wrap=false" + +// CHECK-YES: "-mllvm" "-enable-shrink-wrap=true" Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4047,6 +4047,11 @@ Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ); + if (Args.hasArg(options::OPT_fno_shrink_wrap)) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back("-enable-shrink-wrap=false"); + } + // -fno-strict-overflow implies -fwrapv if it isn't disabled, but // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1388,6 +1388,8 @@ HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group, Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">; +def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group, + Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">,
[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. Herald added a subscriber: chrib. Sorry for the delay. LGTM. Repository: rUNW libunwind https://reviews.llvm.org/D41968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM, with a touch up of the error message to match the others we have regarding -mabicalls. Some other minor nits inlined. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:340 + "ignoring '%0' option as it cannot be used with " + "explicit use of -mabicalls and the N64 ABI">, InGroup; abeserminji wrote: > sdardis wrote: > > Use the %select{optionA|optionB|..|optionZ}$NUM operator here like: > > > > "cannot be used with the %select{explicit|implicit}1 usage of -mabicalls > > and the N64 ABI" > > > > Which eliminates the need for two separate warnings. > Thanks for the hint. I simplified it now. Just saw the error messages above; so for style, you should reformat the message to be of the form "ignoring '%0' option as it cannt be used with %select{|implicit usage of}1-mabicalls and the N64 ABI". This way all the error messages are consistent. Comment at: lib/Driver/ToolChains/CommonArgs.cpp:1024 +mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName); +// For n64 ABI, PIC is always true, except in case when -mno-abicalls +// option is used. And we exit at next check if that's true, Nit: "When targeting the N64 ABI, PIC is the default, except in the case when the -mno-abicalls option is used." Comment at: test/Driver/mips-abicalls-warning.c:2 // REQUIRES: mips-registered-target -// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s -// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and the N64 ABI +// RUN: %clang -### -c -target mips64-mti-elf -fno-pic %s 2>&1 | FileCheck -check-prefix=CHECK-PIC1-IMPLICIT %s +// CHECK-PIC1-IMPLICIT: warning: ignoring '-fno-pic' option as it cannot be used with implicit use of -mabicalls and the N64 ABI Add some checks for -fno-pie, -fno-PIE. https://reviews.llvm.org/D44684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option
sdardis added inline comments. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:340 + "ignoring '%0' option as it cannot be used with " + "explicit use of -mabicalls and the N64 ABI">, InGroup; Use the %select{optionA|optionB|..|optionZ}$NUM operator here like: "cannot be used with the %select{explicit|implicit}1 usage of -mabicalls and the N64 ABI" Which eliminates the need for two separate warnings. Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:242-250 +if (!ABICallsArg) { + D.Diag(diag::warn_drv_unsupported_pic_with_implicit_mabicalls) + << LastPICArg->getAsString(Args); + NonPIC = false; +} else if (UseAbiCalls) { + D.Diag(diag::warn_drv_unsupported_pic_with_explicit_mabicalls) + << LastPICArg->getAsString(Args); Then all of this can be simplified. Repository: rL LLVM https://reviews.llvm.org/D44684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option
sdardis requested changes to this revision. sdardis added a comment. This revision now requires changes to proceed. A quick comment on the error message, inlined. It's about the quality of the diagnostics. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:336-337 +def warn_drv_unsupported_pic : Warning< + "ignoring '-fno-pic' option as it cannot be used with " + "-mabicalls and the N64 ABI">, InGroup; Can you fine tune this error message to say: "ignoring '-fno-pic' option as it cannot be used with explicit use of -mabicalls and the N64 ABI" when -mabicalls is used on the commandline and: "ignoring '-fno-pic' option as it cannot be used with implicit use of -mabicalls and the N64 ABI" when -mno-abicalls and -mabicalls are not present. You should also report the precise pic/PIC/pie/PIE option used in the error message. You should be able to get it from the argument directly: http://llvm.org/doxygen/classllvm_1_1opt_1_1Arg.html Repository: rC Clang https://reviews.llvm.org/D44684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44381: [mips] Prevent PIC to be set to level 2
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM. Repository: rC Clang https://reviews.llvm.org/D44381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44381: [mips] Prevent PIC to be set to level 2
sdardis requested changes to this revision. sdardis added a comment. This revision now requires changes to proceed. You should also update the description of the patch. Repository: rC Clang https://reviews.llvm.org/D44381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis added a comment. Thanks for the review. Repository: rL LLVM https://reviews.llvm.org/D43509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
This revision was automatically updated to reflect the committed changes. Closed by commit rL329167: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when… (authored by sdardis, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D43509?vs=135044=140930#toc Repository: rL LLVM https://reviews.llvm.org/D43509 Files: libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake Index: libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake === --- libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake +++ libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been +# added to the required libraries during in the configuration of LLVM, which +# would cause the check for CXX atomics without libatomic to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) Index: libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake === --- libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake +++ libcxx/trunk/cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been +# added to the required libraries during in the configuration of LLVM, which +# would cause the check for CXX atomics without libatomic to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis added a comment. Ping. Repository: rCXX libc++ https://reviews.llvm.org/D43509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics
This revision was automatically updated to reflect the committed changes. Closed by commit rL329053: [clangd][cmake] Provide libatomic when there is no native support for 64bit… (authored by sdardis, committed by ). Herald added subscribers: llvm-commits, MaskRay. Changed prior to commit: https://reviews.llvm.org/D44248?vs=137555=140750#toc Repository: rL LLVM https://reviews.llvm.org/D44248 Files: clang-tools-extra/trunk/clangd/CMakeLists.txt Index: clang-tools-extra/trunk/clangd/CMakeLists.txt === --- clang-tools-extra/trunk/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/clangd/CMakeLists.txt @@ -2,6 +2,11 @@ Support ) +set(CLANGD_ATOMIC_LIB "") +if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) + list(APPEND CLANGD_ATOMIC_LIB "atomic") +endif() + add_clang_library(clangDaemon AST.cpp ClangdLSPServer.cpp @@ -50,6 +55,7 @@ clangToolingCore clangToolingRefactor ${LLVM_PTHREAD_LIB} + ${CLANGD_ATOMIC_LIB} ) if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) Index: clang-tools-extra/trunk/clangd/CMakeLists.txt === --- clang-tools-extra/trunk/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/clangd/CMakeLists.txt @@ -2,6 +2,11 @@ Support ) +set(CLANGD_ATOMIC_LIB "") +if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) + list(APPEND CLANGD_ATOMIC_LIB "atomic") +endif() + add_clang_library(clangDaemon AST.cpp ClangdLSPServer.cpp @@ -50,6 +55,7 @@ clangToolingCore clangToolingRefactor ${LLVM_PTHREAD_LIB} + ${CLANGD_ATOMIC_LIB} ) if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis added a comment. Ping. Repository: rCXX libc++ https://reviews.llvm.org/D43509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44381: [mips] Prevent PIC to be set to level 2
sdardis added inline comments. Comment at: lib/Driver/ToolChains/CommonArgs.cpp:983 + return std::make_tuple(llvm::Reloc::Static, 0U, false); +// It's never PIC level 2 for mips. +IsPICLevelTwo = false; Can you reformulate this comment to say that MIPS does not use PIC level 2? Also, please add a note stating that even with -mxgot / -fPIC / multigot , MIPS does not use PIC level 2 unlike other architecutres for historical reasons. Repository: rC Clang https://reviews.llvm.org/D44381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics
sdardis added a comment. Thanks, I wasn't sure who to add as a reviewer. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics
sdardis added a comment. Ping? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44381: [mips] Change the way how Clang chooses relocation mode
sdardis added a comment. This patch looks mostly ok, but I think there are some small issues with it. Can you separate the new warnings/error relating to -fno-pic / -mabicalls into another patch from the change which alters the behaviour of __PIC__ / __pic__ ? The title of the patch is misleading, as you're adding warnings related to -fno-pic / -mabicalls and changing how __pic__ is defined. Repository: rC Clang https://reviews.llvm.org/D44381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics
sdardis created this revision. Herald added subscribers: ioeric, jkorous-apple, ilya-biryukov, arichardson, mgorny, klimek. This addresses a persistent failure on clang-cmake-mips buildbot. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44248 Files: clangd/CMakeLists.txt Index: clangd/CMakeLists.txt === --- clangd/CMakeLists.txt +++ clangd/CMakeLists.txt @@ -2,6 +2,11 @@ Support ) +set(CLANGD_ATOMIC_LIB "") +if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) + list(APPEND CLANGD_ATOMIC_LIB atomic) +endif() + add_clang_library(clangDaemon ClangdLSPServer.cpp ClangdServer.cpp @@ -48,6 +53,7 @@ clangToolingCore clangToolingRefactor ${LLVM_PTHREAD_LIB} + ${CLANGD_ATOMIC_LIB} ) if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) Index: clangd/CMakeLists.txt === --- clangd/CMakeLists.txt +++ clangd/CMakeLists.txt @@ -2,6 +2,11 @@ Support ) +set(CLANGD_ATOMIC_LIB "") +if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) + list(APPEND CLANGD_ATOMIC_LIB atomic) +endif() + add_clang_library(clangDaemon ClangdLSPServer.cpp ClangdServer.cpp @@ -48,6 +53,7 @@ clangToolingCore clangToolingRefactor ${LLVM_PTHREAD_LIB} + ${CLANGD_ATOMIC_LIB} ) if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis added a comment. Ping. Repository: rCXX libc++ https://reviews.llvm.org/D43509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis added a comment. Ping. Repository: rCXX libc++ https://reviews.llvm.org/D43509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. Herald added a subscriber: christof. LGTM after https://reviews.llvm.org/D43585 lands. Repository: rUNW libunwind https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43585: [libunwind] Permit additional compiler flags to be passed to tests.
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D43585#1017957, @bsdjhb wrote: > My only question is if this should be named LIBUNWIND_TEST_COMPILER_FLAGS to > match the name used in libc++? I would say yes for the sake of consistency with the option it's controls and libcxx. Additionally, we also require config.test_linker_flags to be set as well, so we need LIBUNWIND_LINKER_FLAGS. LGTM with those two additional changes. I've tested it with your N32 patch and it works. Repository: rUNW libunwind https://reviews.llvm.org/D43585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43585: [libunwind] Permit additional compiler flags to be passed to tests.
sdardis added a subscriber: arichardson. sdardis added a comment. This works as expected with your corresponding libcxx patch. However @arichardson 's https://reviews.llvm.org/D42139 does similar things for libcxx. We should wait for that to land, and ensure that this patch is rebased against that. Comment at: CMakeLists.txt:142 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") +set(LIBUNWIND_TEST_CFLAGS "" CACHE PATH "Additional compiler flags for test programs.") PATH should be STRING. Comment at: test/lit.site.cfg.in:25 config.cxx_ext_threads = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@" +config.test_cflags = "@LIBUNWIND_TEST_CFLAGS@" This should be test_compiler_cflags. Repository: rUNW libunwind https://reviews.llvm.org/D43585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43487: [mips] Spectre variant two mitigation for MIPSR2
This revision was automatically updated to reflect the committed changes. Closed by commit rL325651: [mips] Spectre variant two mitigation for MIPSR2 (authored by sdardis, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D43487 Files: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/Mips.h cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h cfe/trunk/test/Driver/mips-features.c cfe/trunk/test/Driver/mips-indirect-branch.c Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -402,3 +402,9 @@ // RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' + +// -mindirect-jump=hazard +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 \ +// RUN: | FileCheck --check-prefix=INDIRECT-BH %s +// INDIRECT-BH: "-target-feature" "+use-indirect-jump-hazard" Index: cfe/trunk/test/Driver/mips-indirect-branch.c === --- cfe/trunk/test/Driver/mips-indirect-branch.c +++ cfe/trunk/test/Driver/mips-indirect-branch.c @@ -0,0 +1,23 @@ +// REQUIRES: mips-registered-target +// -mindirect-jump=hazard -mips32 +// RUN: %clang -target mips-unknown-linux-gnu -mips32 -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS32 +// MIPS32: error: '-mindirect-jump=hazard' is unsupported with the 'mips32' architecture + +// -mindirect-jump=hazard -mmicromips +// RUN: %clang -target mips-unknown-linux-gnu -mmicromips -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MICROMIPS +// MICROMIPS: error: '-mindirect-jump=hazard' is unsupported with the 'micromips' architecture + +// -mindirect-jump=hazard -mips16 +// RUN: %clang -target mips-unknown-linux-gnu -mips16 -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS16 +// MIPS16: error: '-mindirect-jump=hazard' is unsupported with the 'mips16' architecture + +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \ +// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=RETOPLINE +// RETOPLINE: error: unknown '-mindirect-jump=' option 'retopline' + +// RUN: %clang -target mips-unknown-linux-gnu -### -mips32 -c %s \ +// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=MIXED +// MIXED: error: unknown '-mindirect-jump=' option 'retopline' Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h === --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.h @@ -53,6 +53,7 @@ bool shouldUseFPXX(const llvm::opt::ArgList , const llvm::Triple , StringRef CPUName, StringRef ABIName, mips::FloatABI FloatABI); +bool supportsIndirectJumpHazardBarrier(StringRef ); } // end namespace mips } // end namespace target Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp === --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp @@ -343,6 +343,28 @@ AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4, "nomadd4"); AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt"); + + if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) { +StringRef Val = StringRef(A->getValue()); +if (Val == "hazard") { + Arg *B = + Args.getLastArg(options::OPT_mmicromips, options::OPT_mno_micromips); + Arg *C = Args.getLastArg(options::OPT_mips16, options::OPT_mno_mips16); + + if (B && B->getOption().matches(options::OPT_mmicromips)) +D.Diag(diag::err_drv_unsupported_indirect_jump_opt) +<< "hazard" << "micromips"; + else if (C && C->getOption().matches(options::OPT_mips16)) +D.Diag(diag::err_drv_unsupported_indirect_jump_opt) +<< "hazard" << "mips16"; + else if (mips::supportsIndirectJumpHazardBarrier(CPUName)) +Features.push_back("+use-indirect-jump-hazard"); + else +D.Diag(diag::err_drv_unsupported_indirect_jump_opt) +<< "hazard" << CPUName; +} else + D.Diag(diag::err_drv_unknown_indirect_jump_opt) << Val; + } } mips::IEEE754Standard mips::getIEEE754Standard(StringRef ) { @@ -447,3 +469,20 @@ return UseFPXX; } + +bool mips::supportsIndirectJumpHazardBarrier(StringRef ) { + // Supporting the hazard barrier method of dealing
[PATCH] D43509: [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
sdardis created this revision. sdardis added a reviewer: EricWF. Herald added subscribers: christof, mgorny. When libcxx is built in tree for a host which requires libatomic, LLVM's configuration steps will determine it is required and add it to CMAKE_REQUIRED_LIBRARIES. When libcxx is later configured, it tests if it has C++ atomics without libatomic. The test erroneously passes as libatomic is already part of the set of required libraries. In turn, a number of the atomic tests will fail as they require libatomic but the test suite is configured not to use libatomic. Address this by always dropping libatomic from the set of required libraries before determining if LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB is true, then restoring the set of required libraries. Repository: rCXX libc++ https://reviews.llvm.org/D43509 Files: cmake/Modules/CheckLibcxxAtomic.cmake Index: cmake/Modules/CheckLibcxxAtomic.cmake === --- cmake/Modules/CheckLibcxxAtomic.cmake +++ cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been added +# to the required libraries earlier in the configuration, which would cause +# this check to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) Index: cmake/Modules/CheckLibcxxAtomic.cmake === --- cmake/Modules/CheckLibcxxAtomic.cmake +++ cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been added +# to the required libraries earlier in the configuration, which would cause +# this check to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43487: [mips] Spectre variant two mitigation for MIPSR2
sdardis created this revision. sdardis added a reviewer: atanasyan. Herald added a subscriber: arichardson. This patch provides migitation for CVE-2017-5715, Spectre variant two, which affects the https://reviews.llvm.org/P5600 and https://reviews.llvm.org/P6600. It provides the option -mindirect-jump=hazard, which instructs the LLVM backend to replace indirect branches with their hazard barrier variants. This option is accepted when targetting a MIPS revision two or later. The migitation strategy suggested by MIPS for these processors is to use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard barrier variants of the 'jalr' and 'jr' instructions respectively. These instructions impede the execution of instruction stream until architecturally defined hazards (changes to the instruction stream, privileged registers which may affect execution) are cleared. These instructions in MIPS' designs are not speculated past. These instructions are used with the attribute +use-indirect-jump-hazard when branching indirectly and for indirect function calls. These instructions are defined by the MIPS32R2 ISA, so this mitigation method is not compatible with processors which implement an earlier revision of the MIPS ISA. Implementation note: I've opted to provide this as an -mindirect-jump={hazard,...} style option in case alternative mitigation methods are required for other implementations of the MIPS ISA in future, e.g. retpoline style solutions. Repository: rC Clang https://reviews.llvm.org/D43487 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/Options.td lib/Basic/Targets/Mips.h lib/Driver/ToolChains/Arch/Mips.cpp lib/Driver/ToolChains/Arch/Mips.h test/Driver/mips-features.c test/Driver/mips-indirect-branch.c Index: test/Driver/mips-indirect-branch.c === --- /dev/null +++ test/Driver/mips-indirect-branch.c @@ -0,0 +1,23 @@ +// REQUIRES: mips-registered-target +// -mindirect-jump=hazard -mips32 +// RUN: %clang -target mips-unknown-linux-gnu -mips32 -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS32 +// MIPS32: error: '-mindirect-jump=hazard' is unsupported with the 'mips32' architecture + +// -mindirect-jump=hazard -mmicromips +// RUN: %clang -target mips-unknown-linux-gnu -mmicromips -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MICROMIPS +// MICROMIPS: error: '-mindirect-jump=hazard' is unsupported with the 'micromips' architecture + +// -mindirect-jump=hazard -mips16 +// RUN: %clang -target mips-unknown-linux-gnu -mips16 -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 | FileCheck %s --check-prefix=MIPS16 +// MIPS16: error: '-mindirect-jump=hazard' is unsupported with the 'mips16' architecture + +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \ +// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=RETOPLINE +// RETOPLINE: error: unknown '-mindirect-jump=' option 'retopline' + +// RUN: %clang -target mips-unknown-linux-gnu -### -mips32 -c %s \ +// RUN:-mindirect-jump=retopline 2>&1 | FileCheck %s --check-prefix=MIXED +// MIXED: error: unknown '-mindirect-jump=' option 'retopline' Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -402,3 +402,9 @@ // RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' + +// -mindirect-jump=hazard +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \ +// RUN:-mindirect-jump=hazard 2>&1 \ +// RUN: | FileCheck --check-prefix=INDIRECT-BH %s +// INDIRECT-BH: "-target-feature" "+use-indirect-jump-hazard" Index: lib/Driver/ToolChains/Arch/Mips.h === --- lib/Driver/ToolChains/Arch/Mips.h +++ lib/Driver/ToolChains/Arch/Mips.h @@ -53,6 +53,7 @@ bool shouldUseFPXX(const llvm::opt::ArgList , const llvm::Triple , StringRef CPUName, StringRef ABIName, mips::FloatABI FloatABI); +bool supportsIndirectJumpHazardBarrier(StringRef ); } // end namespace mips } // end namespace target Index: lib/Driver/ToolChains/Arch/Mips.cpp === --- lib/Driver/ToolChains/Arch/Mips.cpp +++ lib/Driver/ToolChains/Arch/Mips.cpp @@ -343,6 +343,28 @@ AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4, "nomadd4"); AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt"); + + if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) { +StringRef Val = StringRef(A->getValue()); +if (Val == "hazard") { + Arg *B =
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. Yes. Something like LIBUNWIND_TEST_CFLAGS mapping to config.test_cflags, which libunwind/test/libunwind/test/config.py then appends when building the tests. Thanks. Repository: rUNW libunwind https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. The only thing this needs now is to get correct testing support. Could you add support for passing down to the configuration script an additional set of cflags like compiler-rt and libomp do (as a separate patch)? If you look at libomp, you'll see LIBOMP_TEST_CFLAGS defined in the cmake build system and threaded through various places so the built tests can have the correct options. Without supporting that we get a mixed set of objects, which isn't correct. Repository: rUNW libunwind https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41968: [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.
sdardis added a reviewer: compnerd. sdardis added a comment. I am not sure what the answer is. There's a slightly different issue in that returning the contents of a floating point register on MIPS and expecting it to be a double is not necessarily correct. For a 64bit FPU, the result of lwc1/mtc1 leaves the upper 32bits of an floating point register as **UNPREDICTABLE** by the architecture definition. It's entirely possible for the application being unwound to be operating on single precision values, but the contents of the register in it's entirety are a signalling nan. I think the least worst option for registers is to always present the data as double values and to only permit access to the sets of double registers for O32, and leave the API user to determine how to proceed. Unfortunately this complicates unwinding in the case of https://reviews.llvm.org/source/compiler-rt/ in strict fp32 mode as that doesn't have double precision at all. But there's more work to be done for https://reviews.llvm.org/source/compiler-rt/ support anyway, so it can be deferred. Some nits inlined. Also, watch out for ABI guards such as (defined(_ABIN32) || defined(_ABI64), these can be replaced with __mips64. Comment at: src/Registers.hpp:2659 + uint32_t _padding; + double _floats[32]; +#endif bsdjhb wrote: > I chose to always use double here to avoid having different context sizes for > the 32-bit vs 64-bit FPR cases. Add a comment highlighting that design choice. Comment at: src/UnwindRegistersRestore.S:647 +#if __mips_fpr == 32 + l.d $f0, (4 * 36 + 8 * 0)($4) + l.d $f2, (4 * 36 + 8 * 2)($4) Use ldc1 instead of l.d . l.d is an alias of ldc1. Comment at: src/UnwindRegistersRestore.S:755 +#ifdef __mips_hard_float + l.d $f0, (8 * 35)($4) + l.d $f1, (8 * 36)($4) ldc1 here too. Comment at: src/UnwindRegistersSave.S:119 -#elif defined(__mips__) && defined(_ABIO32) && defined(__mips_soft_float) +#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32 Comment at: src/UnwindRegistersSave.S:172 +#if __mips_fpr == 32 + s.d $f0, (4 * 36 + 8 * 0)($4) + s.d $f2, (4 * 36 + 8 * 2)($4) Use sdc1 rather than s.d. Comment at: src/UnwindRegistersSave.S:228 -#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) && \ -defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) defined(__mips64) rather than the checking if the ABI names are defined. Comment at: src/UnwindRegistersSave.S:280 +#ifdef __mips_hard_float + s.d $f0, (8 * 35)($4) + s.d $f1, (8 * 36)($4) sdc1 rather s.d Comment at: src/libunwind.cpp:64 # define REGISTER_KIND Registers_or1k -#elif defined(__mips__) && defined(_ABIO32) && defined(__mips_soft_float) +#elif defined(__mips__) && defined(_ABIO32) # define REGISTER_KIND Registers_mips_o32 Check for that _MIPS_SIM == _ABIO32 as well. Comment at: src/libunwind.cpp:66 # define REGISTER_KIND Registers_mips_o32 -#elif defined(__mips__) && (defined(_ABIN32) || defined(_ABI64)) && \ -defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABIN32) || defined(_ABI64)) # define REGISTER_KIND Registers_mips_newabi Check for __mips64 rather than defined(_ABIXXX). https://reviews.llvm.org/D41968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. Ok, I've found my issue. inttypes.h in libcxx include_next's , which on my debian linux systems has the include chain , , . "helpfully" provides #defines of the various _ABIXXX macros, which normally the compiler defines depending on the ABI. The include chain for other parts of libunwind differ which means src/UnwindLevel1-gcc-ext.c had a different definition of the stuct unw_context_t, which was the version defined for O32. As GCC and clang laid out the stack differently for each ABI differently the bug was masked. However for N32 at https://reviews.llvm.org/owners/package/3/, the layout was such that the unwind context in the locals area was right below the saved registers for _Unwind_Backtrace which trashed older saved values, then triggered a SIGSEGV on return due to reloading the saved contents of the $lo into $ra in my case. The fix is fairly simple. Change the ABI #ifdef defined() checks to be: #ifdef _defined(_ABIO32) && _MIPS_SIM == _ABIO32 for O32 or similar for a single ABI. For N32 and N64 together, it's sufficient to test for the presence of __mips64. Comment at: include/__libunwind_config.h:74 # elif defined(__mips__) # if defined(_ABIO32) && defined(__mips_soft_float) #define _LIBUNWIND_TARGET_MIPS_O32 1 See my comment about the N32 abi check. Comment at: include/__libunwind_config.h:78 #define _LIBUNWIND_CURSOR_SIZE 24 +# elif defined(_ABIN32) && defined(__mips_soft_float) +#define _LIBUNWIND_TARGET_MIPS_NEWABI 1 This needs to be: ``` #elif defined(_ABIN32) && _MIPS_SIM == _ABIN32 ``` Comment at: include/__libunwind_config.h:82 +#define _LIBUNWIND_CURSOR_SIZE 42 # elif defined(_ABI64) && defined(__mips_soft_float) #define _LIBUNWIND_TARGET_MIPS_NEWABI 1 Same here. Comment at: src/AddressSpace.hpp:233 +inline uint64_t LocalAddressSpace::getRegister(pint_t addr) { +#if __SIZEOF_POINTER__ == 8 || (defined(__mips__) && defined(_ABIN32)) + return get64(addr); Change that mips check to defined(__mips64) which covers the target being mips and it being n64 or n32. Comment at: src/UnwindRegistersRestore.S:688 -#elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) && \ +defined(__mips_soft_float) Rather checking that the _ABI64 or _ABIN32 are defined, check that __mips64 is defined. Comment at: src/UnwindRegistersSave.S:175 -#elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) && \ +defined(__mips_soft_float) See my comment on register restore file. Comment at: src/libunwind.cpp:66 # define REGISTER_KIND Registers_mips_o32 -#elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABIN32) || defined(_ABI64)) && \ +defined(__mips_soft_float) Check that __mips64 is defined rather than the specific _ABI macros. https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42416: [Driver] Add support for mips32 and scudo
This revision was automatically updated to reflect the committed changes. Closed by commit rL323412: [Driver] Add support for mips32 and scudo (authored by sdardis, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D42416?vs=131047=131403#toc Repository: rL LLVM https://reviews.llvm.org/D42416 Files: cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/Driver/fsanitize.c Index: cfe/trunk/test/Driver/fsanitize.c === --- cfe/trunk/test/Driver/fsanitize.c +++ cfe/trunk/test/Driver/fsanitize.c @@ -628,6 +628,10 @@ // RUN: %clang -target arm-linux-androideabi -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target i386-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // CHECK-SCUDO: "-fsanitize=scudo" // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-PIE Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp === --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp @@ -846,6 +846,8 @@ SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + const bool IsMIPS = getTriple().getArch() == llvm::Triple::mips || + getTriple().getArch() == llvm::Triple::mipsel; const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el; const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || @@ -875,7 +877,7 @@ Res |= SanitizerKind::Efficiency; if (IsX86 || IsX86_64) Res |= SanitizerKind::Function; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch) Res |= SanitizerKind::Scudo; if (IsAArch64) Res |= SanitizerKind::HWAddress; Index: cfe/trunk/test/Driver/fsanitize.c === --- cfe/trunk/test/Driver/fsanitize.c +++ cfe/trunk/test/Driver/fsanitize.c @@ -628,6 +628,10 @@ // RUN: %clang -target arm-linux-androideabi -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target i386-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // CHECK-SCUDO: "-fsanitize=scudo" // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-PIE Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp === --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp @@ -846,6 +846,8 @@ SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + const bool IsMIPS = getTriple().getArch() == llvm::Triple::mips || + getTriple().getArch() == llvm::Triple::mipsel; const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el; const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || @@ -875,7 +877,7 @@ Res |= SanitizerKind::Efficiency; if (IsX86 || IsX86_64) Res |= SanitizerKind::Function; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 ||
[PATCH] D42416: [Driver] Add support for mips32 and scudo
sdardis marked an inline comment as done. sdardis added a comment. Thanks, will fix the nit on commit. Repository: rC Clang https://reviews.llvm.org/D42416 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42416: [Driver] Add support for mips32 and scudo
sdardis created this revision. sdardis added reviewers: cryptoad, atanasyan. Herald added a subscriber: arichardson. r317337 missed that scudo is supported on MIPS32, so permit that option for MIPS32. Repository: rC Clang https://reviews.llvm.org/D42416 Files: lib/Driver/ToolChains/Linux.cpp test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -628,6 +628,10 @@ // RUN: %clang -target arm-linux-androideabi -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target i386-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // CHECK-SCUDO: "-fsanitize=scudo" // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-PIE Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -846,6 +846,8 @@ SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + const bool IsMIPS = getTriple().getArch() == llvm::Triple::mips || +getTriple().getArch() == llvm::Triple::mipsel; const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el; const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || @@ -875,7 +877,7 @@ Res |= SanitizerKind::Efficiency; if (IsX86 || IsX86_64) Res |= SanitizerKind::Function; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch) Res |= SanitizerKind::Scudo; if (IsAArch64) Res |= SanitizerKind::HWAddress; Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -628,6 +628,10 @@ // RUN: %clang -target arm-linux-androideabi -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // RUN: %clang -target i386-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mips-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO +// RUN: %clang -target mipsel-unknown-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO // CHECK-SCUDO: "-fsanitize=scudo" // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-PIE Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -846,6 +846,8 @@ SanitizerMask Linux::getSupportedSanitizers() const { const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; + const bool IsMIPS = getTriple().getArch() == llvm::Triple::mips || +getTriple().getArch() == llvm::Triple::mipsel; const bool IsMIPS64 = getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el; const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 || @@ -875,7 +877,7 @@ Res |= SanitizerKind::Efficiency; if (IsX86 || IsX86_64) Res |= SanitizerKind::Function; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch) Res |= SanitizerKind::Scudo; if (IsAArch64) Res |= SanitizerKind::HWAddress; ___ cfe-commits mailing list cfe-commits@lists.llvm.org
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. I just checked both my qemu copy and on my mips64 machine and it seems to be a a copy / paste error. Reposting here directly from my machines: MIPS64: diff --git a/test/libunwind/test/config.py b/test/libunwind/test/config.py index 2a0c828..a8952c3 100644 --- a/test/libunwind/test/config.py +++ b/test/libunwind/test/config.py @@ -48,6 +48,8 @@ class Configuration(LibcxxConfiguration): # Stack unwinding tests need unwinding tables and these are not # generated by default on all Targets. self.cxx.compile_flags += ['-funwind-tables'] + self.cxx.compile_flags += ['-mabi=n32'] +self.cxx.link_flags += ['-mabi=n32'] if not self.get_lit_bool('enable_threads', True): self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS'] self.config.available_features.add('libunwind-no-threads') X86_64: diff --git a/test/libunwind/test/config.py b/test/libunwind/test/config.py index 2a0c828..f1953e2 100644 --- a/test/libunwind/test/config.py +++ b/test/libunwind/test/config.py @@ -48,6 +48,8 @@ class Configuration(LibcxxConfiguration): # Stack unwinding tests need unwinding tables and these are not # generated by default on all Targets. self.cxx.compile_flags += ['-funwind-tables'] + self.cxx.compile_flags += ['-mabi=n32'] +self.cxx.link_flags += ['-mabi=n32', '/home/sdardis/mips-mti-linux-gnu/2016.05-06/bin/../lib/gcc/mips-mti-linux-gnu/4.9.2/../../../../mips-mti-linux-gnu/lib/mips-r2-hard/lib32/libgcc_s.so.1'] if not self.get_lit_bool('enable_threads', True): self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS'] self.config.available_features.add('libunwind-no-threads') I corrected whitespace nit before I posted the comment. https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. Um, I now appear to be getting different results for running under QEMU doing it the proper way. I was previously rebuilding the failing test by hand and running under qemu. I don't believe I changed anything important, I'll have to take a longer look. If you define an Executor for libunwind you can run the testsuite under QEMU, automagically. I have: LIBUNWIND_EXECUTOR PrefixExecutor(['/home/sdardis/bin/qemu-mipsn32.sh'],LocalExecutor()) /home/sdardis/bin/qemu-mips32.sh for is a simple bash script: #!/bin/bash ~/mips-mti-linux-gnu/2016.05-06/bin/qemu-mipsn32 -L /home/snd-local/mips-mti-linux-gnu/2016.05-06/sysroot/mips-r2-hard/ -E LD_LIBRARY_PATH=/home/snd-local/mips-mti-linux-gnu/2016.05-06/mips-mti-linux-gnu/lib/mips-r2-hard/lib32/ "$@" Hope this helps. Thanks for all the work you're putting into this. https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added a comment. This was libunwind's test suite: Compiled test failed unexpectedly! Testing Time: 0.53s Failing Tests (1): libunwind :: libunwind_02.pass.cpp Expected Passes: 3 Unexpected Failures: 1 The hacky patch I used to test n32: --- a/test/libunwind/test/config.py +++ b/test/libunwind/test/config.py @@ -48,6 +48,8 @@ class Configuration(LibcxxConfiguration): # Stack unwinding tests need unwinding tables and these are not # generated by default on all Targets. self.cxx.compile_flags += ['-funwind-tables'] +self.cxx.compile_flags += ['-mabi=n33'] +self.cxx.link_flags += ['-mabi=n32'] if not self.get_lit_bool('enable_threads', True): self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS'] self.config.available_features.add('libunwind-no-threads') https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added inline comments. Comment at: include/__libunwind_config.h:73 +# elif defined(_ABIN32) && defined(__mips_soft_float) +#define _LIBUNWIND_TARGET_MIPS_NEWABI 1 +#define _LIBUNWIND_CONTEXT_SIZE 35 compnerd wrote: > Minor nit: I prefer either `NABI` or `NEW_ABI`. Normally mips documentation/source code either spells out n32/n64 when referring to the 64 bit abis or calls it a variation of NewABI/newabi/NEWABI (all one word). Comment at: src/Registers.hpp:2252-2253 +#if defined(_LIBUNWIND_TARGET_MIPS_NEWABI) +/// Registers_mips_newabi holds the register state of a thread in a NEWABI +/// MIPS process including both the N32 and N64 ABIs. +class _LIBUNWIND_HIDDEN Registers_mips_newabi { Nit on the wording: Registers_mips_newabi holds the register state of a thread in a NEWABI MIPS process including both the N32 and N64 ABIs. -> Registers_mips_newabi holds the register state of a thread in a MIPS process using NEWABI (the N32 or N64 ABIs). https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35624: Removal of microMIPS64R6
sdardis added inline comments. Comment at: lib/Basic/Targets/Mips.cpp:209 bool MipsTargetInfo::validateTarget(DiagnosticsEngine ) const { + // microMIPS64R6 backend is removed + if ((getTriple().getArch() == llvm::Triple::mips64 || "was removed." https://reviews.llvm.org/D35624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis added a comment. @compnerd, ping? https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40023: [RISCV] Implement ABI lowering
sdardis added a comment. > Mips is the only other implementer of shouldSignExtUnsignedType but is > unaffected, as unlike classifyArgumentType, classifyReturnType will not > extend i32 values (@sdardis: is this a bug?). I believe this is an oversight that is addressed in the backend. The MIPS64 backend treats 'trunc i64 %x to i32' as '(SLL (EXTRACT_SUBREG GPR64:$src, sub_32), 0)', which is required to match MIPS32 arithmetic works on MIPS64. I will take a longer look at this issue. Thanks. https://reviews.llvm.org/D40023 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39074: [libunwind][MIPS]: Add support for unwinding in N32 processes.
sdardis added inline comments. Comment at: include/__libunwind_config.h:59-68 +# elif defined(__mips__) && defined(_ABIN32) && defined(__mips_soft_float) +# define _LIBUNWIND_TARGET_MIPS_N64 1 +# define _LIBUNWIND_CONTEXT_SIZE 35 +# define _LIBUNWIND_CURSOR_SIZE 46 +# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 66 # elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) # define _LIBUNWIND_TARGET_MIPS_N64 1 Change the define of _LIBUNWIND_TARGET_MIPS_N64 to _LIBUNWIND_TARGET_MIPS_NEWABI, then these two elif branches can have the condition (defined(_ABIN32) && defined(_ABI64) and refactored into one elif branch. Comment at: include/__libunwind_config.h:62 +# define _LIBUNWIND_CONTEXT_SIZE 35 +# define _LIBUNWIND_CURSOR_SIZE 46 +# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 66 Shouldn't this 46 be 47? Comment at: src/AddressSpace.hpp:201 +inline uint64_t LocalAddressSpace::getRegister(pint_t addr) { +#if defined(__LP64__) || defined(__mips_n32) + return get64(addr); defined(__mips_n32) -> (defined(__mips__) && defined(_ABIN32)) Comment at: src/UnwindRegistersRestore.S:548 -#elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) && defined(__mips_soft_float) This line is overly long, break with '\' after the second &&. Comment at: src/UnwindRegistersSave.S:146 -#elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) +#elif defined(__mips__) && (defined(_ABI64) || defined(_ABIN32)) && defined(__mips_soft_float) This line looks overly long, break before the second &&. Comment at: src/libunwind.cpp:63-66 +#elif defined(__mips__) && defined(_ABIN32) && defined(__mips_soft_float) +# define REGISTER_KIND Registers_mips_n64 #elif defined(__mips__) && defined(_ABI64) && defined(__mips_soft_float) # define REGISTER_KIND Registers_mips_n64 Fold these two branches together and have the condition (defined(_ABIN32) || defined(_ABI64), then follow-up by renaming Registers_mips_n64 to Register_mips_NEWABI. Add a comment to the definition of that class stating that it covers both n32 and n64. https://reviews.llvm.org/D39074 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis added a reviewer: compnerd. sdardis added a subscriber: compnerd. sdardis added a comment. Two last inlined comments and I think that's everything. @compnerd Have I missed anything? Comment at: src/UnwindRegistersSave.S:100 +# +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set push After looking at another implementation of libunwind and the other platforms that are supported, it seems to me that we need to save all the registers. Comment at: src/UnwindRegistersSave.S:142 +# +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set push Similarly here as well. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis requested changes to this revision. sdardis added a comment. This revision now requires changes to proceed. Marking this as changes required to clear up my review queue - no further comments. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis added a comment. I have tested this on one of my machines after removing the checks for soft float (my debian install doesn't have the necessary headers for soft-float). With the patch you've pointed out and my inline comments addressed (bar the HI / LO register comments), it passes the supplied test suite. Can you change the checks for ABI from '_MIPS_SIM == $ABI' to 'defined($ABI)'? I mistakenly assumed they were always defined and that _MIPS_SIM was defined to be one of them but they are only defined when that particular ABI is being used. Comment at: include/libunwind.h:584 + UNW_MIPS_R31 = 31, +}; + Requires HI / LO registers. Comment at: src/Registers.hpp:2014 +uint32_t __pc; + }; + This appears to be missing the HI / LO registers. Comment at: src/Registers.hpp:2039 +return true; + // FIXME: Hard float + return false; FIXME: Hard float, DSP accumulator registers, MSA registers Comment at: src/UnwindRegistersSave.S:120-122 + jr $31 + # fp (in delay slot) + sw$30, (4 * 30)($4) Move the last store out of the delay slot and put 'or $2, $zero, $zero' in the delay slot to return UNW_ESUCCESS. Comment at: src/UnwindRegistersSave.S:155-157 + jr $31 + # fp (in delay slot) + sd$30, (8 * 30)($4) Move the last store out of the delay slot and put 'or $2, $zero, $zero' in the delay slot to return UNW_ESUCCESS. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis added a comment. Thanks for the pointer to that patch, I'll take a look tomorrow. Comment at: src/UnwindRegistersRestore.S:492 +#elif defined(__mips__) && _MIPS_SIM == _ABIO32 + Needs checking for soft-float. Comment at: src/UnwindRegistersRestore.S:543 + +#elif defined(__mips__) && _MIPS_SIM == _ABI64 + Needs checking for soft-float. Comment at: src/UnwindRegistersSave.S:90 +#elif defined(__mips__) && _MIPS_SIM == _ABIO32 + Needs checking for soft-float. Comment at: src/UnwindRegistersSave.S:125 + +#elif defined(__mips__) && _MIPS_SIM == _ABI64 + Needs checking for soft-float. https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
sdardis edited subscribers, added: cfe-commits; removed: llvm-commits. sdardis added a comment. +CC cfe-commits, -CC llvm-commits. Some comments inlined. I've managed to run the test-suite on one of my machines here and I'm seeing 3 failures: libunwind :: libunwind_01.pass.cpp libunwind :: libunwind_02.pass.cpp libunwind :: unw_getcontext.pass.cpp This is with a GCC toolchain, 6.3. Did you test with clang? Comment at: include/__libunwind_config.h:54 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32 +# elif defined(__mips_o32) +# define _LIBUNWIND_TARGET_MIPS_O32 1 Can you avoid using the __mips_o32 macro and instead use defined(__mips__) && _MIPS_SIM == _ABIO32 ? It appears the __mips_o32 is a FreeBSD specific macro. Also, test for __mips_soft_float . Comment at: include/__libunwind_config.h:59 +# define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32 +# elif defined(__mips_n64) +# define _LIBUNWIND_TARGET_MIPS_N64 1 Likewise "defined(__mips__) && _MIPS_SIM == _ABI64 && __mips_soft_float" Comment at: src/UnwindRegistersRestore.S:492 +#elif defined(__mips_o32) + defined(__mips_o32) -> defined(__mips__) && _MIPS_SIM == _ABIO32 Comment at: src/UnwindRegistersRestore.S:500 +// + .set noreorder + .set noat Prefix this with: .set push .set nomacro Also, the assembler directives should come after the function declaration / defines. Comment at: src/UnwindRegistersRestore.S:539 + lw$4, (4 * 4)($4) + +#elif defined(__mips_n64) .set pop Comment at: src/UnwindRegistersRestore.S:540 + +#elif defined(__mips_n64) + defined(__mips__) && _MIPS_SIM == _ABI64 Comment at: src/UnwindRegistersRestore.S:550 + .set noat +DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_n646jumptoEv) + // r0 is zero See my comments on the o32 assembly. Comment at: src/UnwindRegistersSave.S:90 +#elif defined(__mips_o32) + See my previous comments about this preprocessor macro. Comment at: src/UnwindRegistersSave.S:101 +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set noreorder + # s0 - s7 Wrap this with .set push .set noat .set nomacro Comment at: src/UnwindRegistersSave.S:120 + sw$30, (4 * 30)($4) + +#elif defined(__mips_n64) and: .set pop Comment at: src/UnwindRegistersSave.S:121 + +#elif defined(__mips_n64) + Again, see my previous comments on this preprocessor define. Comment at: src/UnwindRegistersSave.S:132 +DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) + .set noreorder + # s0 - s7 Wrap this with .set push .set noat .set nomacro Comment at: src/UnwindRegistersSave.S:151 + sd$30, (8 * 30)($4) + # elif defined(__mips__) .set pop Comment at: src/libunwind.cpp:66 #elif defined(__mips__) # warning The MIPS architecture is not supported. #else The MIPS architecture is not supported with this ABI and environment! https://reviews.llvm.org/D38110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38168: [mips] Accept but ignore -m(no-)branch-likely
This revision was automatically updated to reflect the committed changes. Closed by commit rL314213: [mips] Accept but ignore -m(no-)branch-likely (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D38168 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2047,6 +2047,10 @@ def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, Group; def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; +def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, + IgnoredGCCCompat; +def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, + IgnoredGCCCompat; def mdsp : Flag<["-"], "mdsp">, Group; def mno_dsp : Flag<["-"], "mno-dsp">, Group; def mdspr2 : Flag<["-"], "mdspr2">, Group; Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -392,3 +392,13 @@ // LONG-CALLS-ON: "-target-feature" "+long-calls" // LONG-CALLS-OFF: "-target-feature" "-long-calls" // LONG-CALLS-DEF-NOT: "long-calls" +// +// -mbranch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s +// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' +// +// -mno-branch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s +// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2047,6 +2047,10 @@ def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, Group; def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; +def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, + IgnoredGCCCompat; +def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, + IgnoredGCCCompat; def mdsp : Flag<["-"], "mdsp">, Group; def mno_dsp : Flag<["-"], "mno-dsp">, Group; def mdspr2 : Flag<["-"], "mdspr2">, Group; Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -392,3 +392,13 @@ // LONG-CALLS-ON: "-target-feature" "+long-calls" // LONG-CALLS-OFF: "-target-feature" "-long-calls" // LONG-CALLS-DEF-NOT: "long-calls" +// +// -mbranch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s +// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' +// +// -mno-branch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s +// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38168: [mips] Accept but ignore -m(no-)branch-likely
sdardis created this revision. Herald added a subscriber: arichardson. -mbranch-likely and -mno-branch-likely are used in some build systems for some MIPS targets. Accept these options but ignore them as they are an (de)optimiztion hint, and that branch likely instructions were deprecated but not removed from MIPS32 and MIPS64 ISAs. https://reviews.llvm.org/D38168 Files: include/clang/Driver/Options.td test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -392,3 +392,13 @@ // LONG-CALLS-ON: "-target-feature" "+long-calls" // LONG-CALLS-OFF: "-target-feature" "-long-calls" // LONG-CALLS-DEF-NOT: "long-calls" +// +// -mbranch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s +// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' +// +// -mno-branch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s +// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2047,6 +2047,10 @@ def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, Group; def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; +def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, + IgnoredGCCCompat; +def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, + IgnoredGCCCompat; def mdsp : Flag<["-"], "mdsp">, Group; def mno_dsp : Flag<["-"], "mno-dsp">, Group; def mdspr2 : Flag<["-"], "mdspr2">, Group; Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -392,3 +392,13 @@ // LONG-CALLS-ON: "-target-feature" "+long-calls" // LONG-CALLS-OFF: "-target-feature" "-long-calls" // LONG-CALLS-DEF-NOT: "long-calls" +// +// -mbranch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s +// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' +// +// -mno-branch-likely +// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s +// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2047,6 +2047,10 @@ def mno_check_zero_division : Flag<["-"], "mno-check-zero-division">, Group; def mcompact_branches_EQ : Joined<["-"], "mcompact-branches=">, Group; +def mbranch_likely : Flag<["-"], "mbranch-likely">, Group, + IgnoredGCCCompat; +def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group, + IgnoredGCCCompat; def mdsp : Flag<["-"], "mdsp">, Group; def mno_dsp : Flag<["-"], "mno-dsp">, Group; def mdspr2 : Flag<["-"], "mdspr2">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36712: Emit section information for extern variables
sdardis added a comment. > One suggestion inline for the wording inline, the important part is making > explicit The important part is making explicit that section information for a variable can be explicit or inferred. https://reviews.llvm.org/D36712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36712: Emit section information for extern variables
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. I agree with @kparzysz here. If there is a mis-match between the declaration and definition, there are cases where undesirable behaviour (as such) will not occur depending on how the mismatch occurs. One suggestion inline for the wording inline, the important part is making explicit LGTM, anyone else have more comments? Comment at: docs/LangRef.rst:582-584 +to be placed in and may have an optional explicit alignment specified. A +mismatch between section information in the variable declaration and its +definition is undefined behavior. "If there is a mismatch between the explicit or inferred section information for the variable declaration and its definition the resulting behaviour is undefined." https://reviews.llvm.org/D36712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions
sdardis added a comment. Thanks, Simon Repository: rL LLVM https://reviews.llvm.org/D36954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions
This revision was automatically updated to reflect the committed changes. Closed by commit rL311441: [Sema] Update release notes with details of implicit scalar to vector… (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D36954 Files: cfe/branches/release_50/docs/ReleaseNotes.rst Index: cfe/branches/release_50/docs/ReleaseNotes.rst === --- cfe/branches/release_50/docs/ReleaseNotes.rst +++ cfe/branches/release_50/docs/ReleaseNotes.rst @@ -116,7 +116,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -128,6 +162,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support Index: cfe/branches/release_50/docs/ReleaseNotes.rst === --- cfe/branches/release_50/docs/ReleaseNotes.rst +++ cfe/branches/release_50/docs/ReleaseNotes.rst @@ -116,7 +116,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -128,6 +162,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36954: [Sema] Update release notes with details of implicit scalar to vector conversions
sdardis created this revision. Add notes on this to the C language section, along with the C++ section. https://reviews.llvm.org/D36954 Files: docs/ReleaseNotes.rst Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -95,7 +95,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -107,6 +141,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support Index: docs/ReleaseNotes.rst === --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -95,7 +95,41 @@ C Language Changes in Clang --- -- ... +- Added near complete support for implicit scalar to vector conversion, a GNU + C/C++ language extension. With this extension, the following code is + considered valid: + +.. code-block:: c + +typedef unsigned v4i32 __attribute__((vector_size(16))); + +v4i32 foo(v4i32 a) { + // Here 5 is implicitly casted to an unsigned value and replicated into a + // vector with as many elements as 'a'. + return a + 5; +} + +The implicit conversion of a scalar value to a vector value--in the context of +a vector expression--occurs when: + +- The type of the vector is that of a ``__attribute__((vector_size(size)))`` + vector, not an OpenCL ``__attribute__((ext_vector_type(size)))`` vector type. + +- The scalar value can be casted to that of the vector element's type without + the loss of precision based on the type of the scalar and the type of the + vector's elements. + +- For compile time constant values, the above rule is weakened to consider the + value of the scalar constant rather than the constant's type. + +- Floating point constants with precise integral representations are not + implicitly converted to integer values, this is for compatability with GCC. + + +Currently the basic integer and floating point types with the following +operators are supported: ``+``, ``/``, ``-``, ``*``, ``%``, ``>``, ``<``, +``>=``, ``<=``, ``==``, ``!=``, ``&``, ``|``, ``^`` and the corresponding +assignment operators where applicable. ... @@ -107,6 +141,10 @@ C++ Language Changes in Clang - +- As mentioned in `C Language Changes in Clang`_, Clang's support for + implicit scalar to vector conversions also applies to C++. Additionally + the following operators are also supported: ``&&`` and ``||``. + ... C++1z Feature Support ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM with a test for warnings. See test/Driver/mips-abicalls.c for reference. Repository: rL LLVM https://reviews.llvm.org/D35982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36824: [mips] Rename getSupportedNanEncoding() to getIEEE754Standard() (NFC)
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM with comment addressed. Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:328 +mips::IEEE754Standard mips::getIEEE754Standard(StringRef ) { + // Strictly speaking, mips32r2 and mips64r2 are not in accordance to standard + // from 2008, it was first introduced in Release 3. However, other compilers "are not in accordance to standard from 2008, it was first introduced in Release 3." This should read: "do not conform to the IEEE754-2008 standard. Support for this standard was first introduced in Release 3." Repository: rL LLVM https://reviews.llvm.org/D36824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36712: Emit section information for extern variables
sdardis requested changes to this revision. sdardis added a reviewer: kparzysz. sdardis added a comment. This revision now requires changes to proceed. +kparzysz as Hexagon also makes use of the small data section. Comment at: docs/LangRef.rst:629 +corresponding to the LLVM module, section information specified in the +declaration is retained in LLVM IR to enable OpenCL processes. + efriedma wrote: > This doesn't really explain the part that matters. For LangRef, it doesn't > matter how the frontend decides to generate declarations (and it might be > different for frontends other than clang). And OpenCL might motivate this, > but it has nothing to do with the semantics. > > The key question here is what it actually means. Is it a promise the that a > definition will exist for the given symbol in the given section? If so, what > happens if the symbol is actually in a different section? ("Undefined > behavior" is probably an acceptable answer, but it needs to be stated > explicitly.) > to enable OpenCL processes. for targets which make use of this section information. I would also work in a sentence that says that attaching section information to a external declaration is an assertion or promise that the definition is located in that section. If the definition is actually located in a different section the behaviour is undefined. I'm favouring "undefined behaviour" in the error case as behaviour is so target and environment specific. https://reviews.llvm.org/D36712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic
sdardis added a comment. Thanks for the review and spotting this bug that lead me to finding the other bug. Repository: rL LLVM https://reviews.llvm.org/D36315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic
This revision was automatically updated to reflect the committed changes. Closed by commit rL310714: [mips] Support implicit gpopt with N64 when using -fno-pic (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D36315 Files: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -85,6 +85,24 @@ // RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" // +// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-GPOPT %s +// CHECK-N64-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-GPOPT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -fno-pic -mno-gpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s +// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -mgpopt (-fpic is implicit) +// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s +// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt" +// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1473,8 +1473,21 @@ // NOTE: We need a warning here or in the backend to warn when -mgpopt is // passed explicitly when compiling something with -mabicalls // (implictly) in affect. Currently the warning is in the backend. + // + // When the ABI in use is N64, we also need to determine the PIC mode that + // is in use, as -fno-pic for N64 implies -mno-abicalls. bool NoABICalls = ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + + llvm::Reloc::Model RelocationModel; + unsigned PICLevel; + bool IsPIE; + std::tie(RelocationModel, PICLevel, IsPIE) = + ParsePICArgs(getToolChain(), Args); + + NoABICalls = NoABICalls || + (RelocationModel == llvm::Reloc::Static && ABIName == "n64"); + bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt. if (NoABICalls && (!GPOpt || WantGPOpt)) { Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -85,6 +85,24 @@ // RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" // +// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-GPOPT %s +// CHECK-N64-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-GPOPT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -fno-pic -mno-gpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s +// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -mgpopt (-fpic is implicit) +// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s +// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt" +// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1473,8 +1473,21 @@ // NOTE: We need a warning here or in the backend to warn when -mgpopt is // passed explicitly when compiling something with -mabicalls // (implictly) in affect. Currently the warning is in the backend. + // + // When the ABI in use is N64, we also need to determine the PIC mode that + // is in use, as -fno-pic for N64 implies -mno-abicalls. bool NoABICalls = ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + + llvm::Reloc::Model RelocationModel;
[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]
sdardis requested changes to this revision. sdardis added a comment. This revision now requires changes to proceed. Follow @atanasyan 's suggestion and post a patch that renames that enum along with other changes. One comment inlined. Comment at: clang/Basic/DiagnosticDriverKinds.td:282-287 +def warn_target_unsupported_abslegacy : Warning< + "ignoring '-mabs=legacy' option because the '%0' architecture does not support it">, + InGroup; +def warn_target_unsupported_abs2008 : Warning< + "ignoring '-mabs=2008' option because the '%0' architecture does not support it">, + InGroup; These require tests. You should test that abs2008 is ignored pre-r2, legacy and abs2008 is accepted up to r5 and legacy is ignored for R6. Repository: rL LLVM https://reviews.llvm.org/D35982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35624: Removal of microMIPS64R6
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. One nit inlined, you can address it when committing. Comment at: Basic/Targets/Mips.cpp:206 bool MipsTargetInfo::validateTarget(DiagnosticsEngine ) const { + if ((getTriple().getArch() == llvm::Triple::mips64 || + getTriple().getArch() == llvm::Triple::mips64el) && Add a comment here stating that the microMIPS64R6 backend was removed. Repository: rL LLVM https://reviews.llvm.org/D35624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30465: [mips] Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64
sdardis closed this revision. sdardis added a comment. Closing this, https://reviews.llvm.org/rL297098. Repository: rL LLVM https://reviews.llvm.org/D30465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI
sdardis added a comment. Nit: my comment on line 297, "non position-independent code and N64 ABI" should be "non position-independent code and the N64 ABI". LGTM otherwise. Repository: rL LLVM https://reviews.llvm.org/D36550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. LGTM. Comment at: test/Driver/mips-longcalls-warning.c:1 +// REQUIRES: mips-registered-target +// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck -check-prefix=IMPLICIT %s atanasyan wrote: > sdardis wrote: > > Can you put this in test/Driver/mips-abicalls-warning.c from the other > > patch? I'd prefer to keep all the abicalls warnings together rather than > > separate tests based on the feature the conflict with. > > Can you put this in test/Driver/mips-abicalls-warning.c from the other > > patch? > > I can, but in that case it's probably better to join both patches because > that patch loses its test. > You can do it as an NFC change afterward both commits in that case. Repository: rL LLVM https://reviews.llvm.org/D36551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options
sdardis added inline comments. Comment at: test/Driver/mips-longcalls-warning.c:1 +// REQUIRES: mips-registered-target +// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck -check-prefix=IMPLICIT %s Can you put this in test/Driver/mips-abicalls-warning.c from the other patch? I'd prefer to keep all the abicalls warnings together rather than separate tests based on the feature the conflict with. Repository: rL LLVM https://reviews.llvm.org/D36551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI
sdardis added a comment. Slight tweak to the summary: > The -mabicalls option does not have a sense in case of non position > independent code on N64 ABI. After this change driver starts to show a > warning that -mabicalls is ignored in that case. The -mabicalls option does not make sense in the case of non position independent code for the N64 ABI. After this change the driver shows a warning that -mabicalls is ignored in that case. I think the major change in this patch is overly complex for what it should be, suggestion inline. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:297 + "ignoring '-mabicalls' option as it cannot be used with " + "non position-independent code and N64 ABI">, + InGroup; and the N64 ABI Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:233-253 + Arg *ABICallsArg = + Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); + if (!ABICallsArg) +NeedNoAbiCalls = DefNoAbiCalls; + else { +if (ABICallsArg->getOption().matches(options::OPT_mno_abicalls)) + NeedNoAbiCalls = true; I think this logic can be simplified to: bool UseAbiCalls = false; Arg *ABICallsArg = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); UseAbiCalls = !ABICallsArg || (ABICallsArg && ABICallsArg->getOption().matches(options::OPT_mabicalls)); if (UseAbiCalls && IsN64 && NonPIC) { D.Diag(diag::warn_drv_unsupported_abicalls); UseAbiCalls = false; } if (!UseAbiCalls) Features.push_back("+noabicalls"); else Features.push_back("-noabicalls"); As that way we immediately pick up the implicit case or explicit case of using -mabicalls and we can simply pick out the N64 && NonPic && UseAbiCalls case to warn and fix. Although we don't need to add "-noabicalls" to the Features vector, the backend defaults to that, though the tests expect it. Repository: rL LLVM https://reviews.llvm.org/D36550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options
sdardis added inline comments. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:296-297 +def warn_drv_unsupported_longcalls : Warning< + "ignoring '-mlong-calls' option as it cannot be used with " + "%select{|the implicit usage of }0-mabicalls">, + InGroup; "as it is not currently supported with " I think is better, as we currently don't support mixing the options but could do in the future. Repository: rL LLVM https://reviews.llvm.org/D36551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic
sdardis created this revision. Herald added a subscriber: arichardson. As clang defaults to -mno-abicalls when using -fno-pic for N64, implicitly use -mgpopt in that case. https://reviews.llvm.org/D36315 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -80,6 +80,24 @@ // RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" // +// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-GPOPT %s +// CHECK-N64-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-GPOPT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -fno-pic -mno-gpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s +// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -mgpopt (-fpic is implicit) +// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s +// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt" +// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1473,8 +1473,21 @@ // NOTE: We need a warning here or in the backend to warn when -mgpopt is // passed explicitly when compiling something with -mabicalls // (implictly) in affect. Currently the warning is in the backend. + // + // When the ABI in use is N64, we also need to determine the PIC mode that + // is in use, as -fno-pic for N64 implies -mno-abicalls. bool NoABICalls = ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + + llvm::Reloc::Model RelocationModel; + unsigned PICLevel; + bool IsPIE; + std::tie(RelocationModel, PICLevel, IsPIE) = + ParsePICArgs(getToolChain(), Args); + + NoABICalls = NoABICalls || + (RelocationModel == llvm::Reloc::Static && ABIName == "n64"); + bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt. if (NoABICalls && (!GPOpt || WantGPOpt)) { Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -80,6 +80,24 @@ // RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" // +// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-GPOPT %s +// CHECK-N64-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-GPOPT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -fno-pic -mno-gpopt +// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s +// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls" +// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt" +// +// MIPS64 + N64: -mgpopt (-fpic is implicit) +// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s +// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt" +// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1473,8 +1473,21 @@ // NOTE: We need a warning here or in the backend to warn when -mgpopt is // passed explicitly when compiling something with -mabicalls // (implictly) in affect. Currently the warning is in the backend. + // + // When the ABI in use is N64, we also need to determine the PIC mode that + // is in use, as -fno-pic for N64 implies -mno-abicalls. bool NoABICalls = ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + + llvm::Reloc::Model RelocationModel; + unsigned PICLevel; + bool IsPIE; + std::tie(RelocationModel, PICLevel, IsPIE) = + ParsePICArgs(getToolChain(), Args); + + NoABICalls = NoABICalls || +
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added a comment. https://reviews.llvm.org/rL309978 for the revert. Repository: rL LLVM https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added a comment. In https://reviews.llvm.org/D35917#830898, @joerg wrote: > I don't see any reason why zero-initialised constants should be emitted in > BSS. I know that GCC does that and I just fixed bugs in that because created > wrong section flags for it. So yes, I'd prefer to revert this and fix the > real problem. Will do. Repository: rL LLVM https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added inline comments. Comment at: cfe/trunk/lib/CodeGen/TargetInfo.cpp: + GVar->setLinkage(llvm::GlobalValue::ExternalLinkage); + GVar->setSection("rodata"); +} efriedma wrote: > Also, this change is clearly unacceptable; among other things, messing with > the linkage of static local variables is likely to lead to link errors. I will fix that. Repository: rL LLVM https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added a comment. It's required for feature parity with GCC. -fno-common will place globals into the bss section which uses memory at runtime. The -membedded-data and -muninit-const-in-rodata options are for reducing RAM usage in some embedded environments. Repository: rL LLVM https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added a comment. Thanks for the reviews of all of these options. Repository: rL LLVM https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
This revision was automatically updated to reflect the committed changes. Closed by commit rL309940: [mips] Implement -muninit-const-in-rodata (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D35917 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1515,6 +1515,14 @@ CmdArgs.push_back("-membedded-data=0"); } EmbeddedData->claim(); + + if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata, + options::OPT_mno_uninit_const_in_rodata)) { +if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) { + CmdArgs.push_back("-muninit-const-in-rodata"); + A->claim(); +} + } } } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -950,6 +950,8 @@ Opts.Backchain = Args.hasArg(OPT_mbackchain); + Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata); + Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -6656,6 +6656,20 @@ void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule , ForDefinition_t IsForDefinition) const override { + +if (const VarDecl *VD = dyn_cast_or_null(D)) { + if (CGM.getCodeGenOpts().UInitCstDataInROData && + VD->getType().isConstQualified() && !VD->hasInit()) { +llvm::GlobalVariable *GVar = dyn_cast_or_null(GV); +if (GVar && !GVar->hasSection()) { + GVar->setLinkage(llvm::GlobalValue::ExternalLinkage); + GVar->setSection("rodata"); +} + } + + return; +} + const FunctionDecl *FD = dyn_cast_or_null(D); if (!FD) return; llvm::Function *Fn = cast(GV); Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2057,6 +2057,14 @@ def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, HelpText<"Do not place constants in the .rodata section instead of the " ".sdata if they meet the -G threshold (MIPS)">; +def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">, + Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place " + "uninitialized constants in the read-only data section instead of" + " the common section (MIPS)">; +def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">, + Group, HelpText<"Do not place uninitialized constants in the " + "read-only data section instead of the common" + " section (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def === --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def @@ -101,6 +101,8 @@ CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. +CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data + ///< & -muinit-const-in-rodata is set CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is ///< enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. Index: cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c === --- cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c +++ cfe/trunk/test/CodeGen/mips-uninit-const-in-ro.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:1523 + CmdArgs.push_back("-muninit-const-in-rodata"); + A->claim(); +} atanasyan wrote: > What's happened if the `-muninit-const-in-rodata` is used without > `-membedded-data`? Will the compiler shows a warning about unused command > line option? Yes, it warns that it's unused. https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis updated this revision to Diff 109545. sdardis marked an inline comment as done. sdardis added a comment. Address review comment. https://reviews.llvm.org/D35917 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/TargetInfo.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/mips-uninit-const-in-ro.c Index: test/CodeGen/mips-uninit-const-in-ro.c === --- /dev/null +++ test/CodeGen/mips-uninit-const-in-ro.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm -mrelocation-model static \ +// RUN:-target-feature +noabicalls -mllvm -mgpopt -mllvm \ +// RUN:-membedded-data=1 -muninit-const-in-rodata -o - %s | \ +// RUN: FileCheck %s + +// Test that -muninit-const-in-rodata places constant uninitialized structures +// in the .rodata section rather than the commeon section. + +// CHECK: @a = global [8 x i32] zeroinitializer, section "rodata", align 4 +const int a[8]; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -950,6 +950,8 @@ Opts.Backchain = Args.hasArg(OPT_mbackchain); + Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata); + Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1515,6 +1515,14 @@ CmdArgs.push_back("-membedded-data=0"); } EmbeddedData->claim(); + + if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata, + options::OPT_mno_uninit_const_in_rodata)) { +if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) { + CmdArgs.push_back("-muninit-const-in-rodata"); + A->claim(); +} + } } } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -6656,6 +6656,20 @@ void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule , ForDefinition_t IsForDefinition) const override { + +if (const VarDecl *VD = dyn_cast_or_null(D)) { + if (CGM.getCodeGenOpts().UInitCstDataInROData && + VD->getType().isConstQualified() && !VD->hasInit()) { +llvm::GlobalVariable *GVar = dyn_cast_or_null(GV); +if (GVar && !GVar->hasSection()) { + GVar->setLinkage(llvm::GlobalValue::ExternalLinkage); + GVar->setSection("rodata"); +} + } + + return; +} + const FunctionDecl *FD = dyn_cast_or_null(D); if (!FD) return; llvm::Function *Fn = cast(GV); Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -101,6 +101,8 @@ CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. +CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data + ///< & -muinit-const-in-rodata is set CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is ///< enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2057,6 +2057,14 @@ def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, HelpText<"Do not place constants in the .rodata section instead of the " ".sdata if they meet the -G threshold (MIPS)">; +def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">, + Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place " + "uninitialized constants in the read-only data section instead of" + " the common section (MIPS)">; +def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">, + Group, HelpText<"Do not place uninitialized constants in the " + "read-only data section instead of the common" + " section (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls :
[PATCH] D35914: [mips] Add support -m(no-)embedded-data option
This revision was automatically updated to reflect the committed changes. Closed by commit rL309935: [mips] Add support -m(no-)embedded-data option (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D35914 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1484,7 +1484,9 @@ Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, - options::OPT_mno_extern_sdata); + options::OPT_mno_extern_sdata); +Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data, +options::OPT_mno_embedded_data); if (LocalSData) { CmdArgs.push_back("-mllvm"); if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { @@ -1504,6 +1506,17 @@ } ExternSData->claim(); } + +if (EmbeddedData) { + CmdArgs.push_back("-mllvm"); + if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) { +CmdArgs.push_back("-membedded-data=1"); + } else { +CmdArgs.push_back("-membedded-data=0"); + } + EmbeddedData->claim(); +} + } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2051,6 +2051,12 @@ def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group, HelpText<"Do not assume that externally defined data is in the small data if" " it meets the -G threshold (MIPS)">; +def membedded_data : Flag<["-"], "membedded-data">, Group, + HelpText<"Place constants in the .rodata section instead of the .sdata " + "section even if they meet the -G threshold (MIPS)">; +def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, + HelpText<"Do not place constants in the .rodata section instead of the " + ".sdata if they meet the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -65,6 +65,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" // +// -mno-abicalls -mgpopt -membedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-embedded-data -membedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s +// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1" +// +// -mno-abicalls -mgpopt -mno-embedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -membedded-data -mno-embedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s +// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s +// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1484,7 +1484,9 @@ Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, - options::OPT_mno_extern_sdata); + options::OPT_mno_extern_sdata); +Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data, +options::OPT_mno_embedded_data); if (LocalSData) { CmdArgs.push_back("-mllvm"); if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { @@ -1504,6 +1506,17 @@ } ExternSData->claim(); } + +if (EmbeddedData) { + CmdArgs.push_back("-mllvm"); + if
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis added a comment. Ping. https://reviews.llvm.org/D35917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36208: [mips] Enable target-specific attributes for MIPS64
sdardis added a comment. @aaron.ballman I missed your first comments when I'd submitted mine. In https://reviews.llvm.org/D36208#828957, @aaron.ballman wrote: > In https://reviews.llvm.org/D36208#828955, @sdardis wrote: > > > I think for the interrupt attribute, it should be an error. Currently it's > > an implementation detail that it errors out in the backend but in principal > > it can be supported (I haven't gotten around to addressing it.) > > > For the interrupt attribute, I think it should behave the same as the other > target-specific interrupt attributes unless there's a very good reason to be > inconsistent. My primary thought there was that the backend will error out with "LLVM ERROR: "interrupt" attribute is only supported for the O32 ABI on MIPS32R2+ at the present time." if the attribute is seen anywhere by the backend for MIPS64. Having clang detect this case and being able to point out where in the code being compiled the attribute exists is better than having LLVM declaring there's an error somewhere and giving up. It is semantically critical as interrupt handlers need specific prologue+epilog sequences. I don't object to preserving the current behaviour of warning + ignoring it though. > > >> For the micromips attribute, I believe it should be an error. My rational >> there is that the user has requested something that the compiler cannot >> perform. > > That's not really sufficient rationale, because the same logic can be said of > any ignored attribute. As best I can tell from the docs on this attribute, > this controls code generation to turn on or off micromips code generation, > which sounds like the code otherwise generated may still work just fine. > e.g., `void f(void) __attribute__((micromips)) {}` -- if you compile that > code on a non-MIPS target, why should it produce an error instead of merely > warning the user that the attribute is ignored? I stand corrected, we should just warn + ignore the micromips attribute for MIPS64 then. Repository: rL LLVM https://reviews.llvm.org/D36208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36208: [mips] Enable target-specific attributes for MIPS64
sdardis added a comment. I think for the interrupt attribute, it should be an error. Currently it's an implementation detail that it errors out in the backend but in principal it can be supported (I haven't gotten around to addressing it.) For the micromips attribute, I believe it should be an error. My rational there is that the user has requested something that the compiler cannot perform. Repository: rL LLVM https://reviews.llvm.org/D36208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36208: [mips] Enable target-specific attributes for MIPS64
sdardis added a comment. Some comments: Currently there is no support in the backend for the interrupt attribute for mips64 / using N32 & N64 abis, it will give a fatal error. Previously the backend lacked support for the static relocation model which is an expected requirement for interrupt handlers. microMIPS32r(3|6) is only supported for the O32 ABI, as microMIPS64R6 is deprecated and going to be removed. There is no support for the published microMIPS64R3 ISA. Repository: rL LLVM https://reviews.llvm.org/D36208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35917: [mips] Implement -muninit-const-in-rodata
sdardis created this revision. Herald added a subscriber: arichardson. This option when combined with -mgpopt and -membedded-data places all uninitialized constant variables in the read-only section. https://reviews.llvm.org/D35917 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/TargetInfo.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/mips-uninit-const-in-ro.c Index: test/CodeGen/mips-uninit-const-in-ro.c === --- /dev/null +++ test/CodeGen/mips-uninit-const-in-ro.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple mips-mti--elf -emit-llvm -mrelocation-model static \ +// RUN:-target-feature +noabicalls -mllvm -mgpopt -mllvm \ +// RUN:-membedded-data=1 -muninit-const-in-rodata -o - %s | \ +// RUN: FileCheck %s + +// Test that -muninit-const-in-rodata places constant uninitialized structures +// in the .rodata section rather than the commeon section. + +// CHECK: @a = global [8 x i32] zeroinitializer, section "rodata", align 4 +const int a[8]; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -949,6 +949,8 @@ Opts.Backchain = Args.hasArg(OPT_mbackchain); + Opts.UInitCstDataInROData = Args.hasArg(OPT_muninit_const_in_rodata); + Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue( Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1515,6 +1515,14 @@ CmdArgs.push_back("-membedded-data=0"); } EmbeddedData->claim(); + + if (Arg *A = Args.getLastArg(options::OPT_muninit_const_in_rodata, + options::OPT_mno_uninit_const_in_rodata)) { +if (A->getOption().matches(options::OPT_muninit_const_in_rodata)) { + CmdArgs.push_back("-muninit-const-in-rodata"); + A->claim(); +} + } } } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -6659,6 +6659,20 @@ void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule , ForDefinition_t IsForDefinition) const override { + +if (const VarDecl *VD = dyn_cast_or_null(D)) { + if (CGM.getCodeGenOpts().UInitCstDataInROData && + VD->getType().isConstQualified() && !VD->hasInit()) { +llvm::GlobalVariable *GVar = dyn_cast_or_null(GV); +if (GVar && !GVar->hasSection()) { + GVar->setLinkage(llvm::GlobalValue::ExternalLinkage); + GVar->setSection("rodata"); +} + } + + return; +} + const FunctionDecl *FD = dyn_cast_or_null(D); if (!FD) return; llvm::Function *Fn = cast(GV); Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -101,6 +101,8 @@ CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is enabled. CODEGENOPT(MSVolatile, 1, 0) ///< Set when /volatile:ms is enabled. CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled. +CODEGENOPT(UInitCstDataInROData, 1, 0) ///< Set when -mgpopt & -membedded-data + ///< & -muinit-const-in-rodata is set CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is ///< enabled. CODEGENOPT(NoExecStack , 1, 0) ///< Set when -Wa,--noexecstack is enabled. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2057,6 +2057,14 @@ def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, HelpText<"Do not place constants in the .rodata section instead of the " ".sdata if they meet the -G threshold (MIPS)">; +def muninit_const_in_rodata : Flag<["-"], "muninit-const-in-rodata">, + Group, Flags<[DriverOption,CC1Option]>, HelpText<"Place " + "uninitialized constants in the read-only data section instead of" + " the common section (MIPS)">; +def mno_uninit_const_in_rodata : Flag<["-"], "mno-uninit-const-in-rodata">, + Group, HelpText<"Do not Place uninitialized constants in the " + "read-only data section instead of the common" + " section (MIPS)">;
[PATCH] D35914: [mips] Add support -m(no-)embedded-data option
sdardis created this revision. Herald added a subscriber: arichardson. Add support for the -membedded-data option which places constant data in the .rodata section, rather than the .sdata section. https://reviews.llvm.org/D35914 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -65,6 +65,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" // +// -mno-abicalls -mgpopt -membedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-embedded-data -membedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s +// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1" +// +// -mno-abicalls -mgpopt -mno-embedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -membedded-data -mno-embedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s +// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s +// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1484,7 +1484,9 @@ Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, - options::OPT_mno_extern_sdata); + options::OPT_mno_extern_sdata); +Arg *EmbeddedData = Args.getLastArg(options::OPT_membedded_data, +options::OPT_mno_embedded_data); if (LocalSData) { CmdArgs.push_back("-mllvm"); if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { @@ -1504,6 +1506,17 @@ } ExternSData->claim(); } + +if (EmbeddedData) { + CmdArgs.push_back("-mllvm"); + if (EmbeddedData->getOption().matches(options::OPT_membedded_data)) { +CmdArgs.push_back("-membedded-data=1"); + } else { +CmdArgs.push_back("-membedded-data=0"); + } + EmbeddedData->claim(); +} + } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2051,6 +2051,12 @@ def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group, HelpText<"Do not assume that externally defined data is in the small data if" " it meets the -G threshold (MIPS)">; +def membedded_data : Flag<["-"], "membedded-data">, Group, + HelpText<"Place constants in the .rodata section instead of the .sdata " + "section even if they meet the -G threshold (MIPS)">; +def mno_embedded_data : Flag<["-"], "mno-embedded-data">, Group, + HelpText<"Do not place constants in the .rodata section instead of the " + ".sdata if they meet the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -65,6 +65,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s // CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" // +// -mno-abicalls -mgpopt -membedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-embedded-data -membedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATA %s +// CHECK-MEMBEDDEDDATA: "-mllvm" "-membedded-data=1" +// +// -mno-abicalls -mgpopt -mno-embedded-data +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -membedded-data -mno-embedded-data 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEMBEDDEDDATA %s +// CHECK-MNOEMBEDDEDDATA: "-mllvm" "-membedded-data=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s +// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data" +// // -mips16 // RUN: %clang -target
[PATCH] D35624: Removal of microMIPS64R6
sdardis added a reviewer: cfe-commits. sdardis added a comment. Also, this need to be posted to cfe-commits. Repository: rL LLVM https://reviews.llvm.org/D35624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35550: [mips] Add support for -m(no-)extern-data.
This revision was automatically updated to reflect the committed changes. Closed by commit rL308879: [mips] Add support for -m(no-)extern-data. (authored by sdardis). Changed prior to commit: https://reviews.llvm.org/D35550?vs=107073=107897#toc Repository: rL LLVM https://reviews.llvm.org/D35550 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -50,6 +50,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s // CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" // +// -mno-abicalls -mgpopt -mextern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-extern-sdata -mextern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATA %s +// CHECK-MEXTERNSDATA: "-mllvm" "-mextern-sdata=1" +// +// -mno-abicalls -mgpopt -mno-extern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mextern-sdata -mno-extern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEXTERNSDATA %s +// CHECK-MNOEXTERNSDATA: "-mllvm" "-mextern-sdata=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s +// CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1483,6 +1483,8 @@ Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); +Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, + options::OPT_mno_extern_sdata); if (LocalSData) { CmdArgs.push_back("-mllvm"); if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { @@ -1493,6 +1495,15 @@ LocalSData->claim(); } +if (ExternSData) { + CmdArgs.push_back("-mllvm"); + if (ExternSData->getOption().matches(options::OPT_mextern_sdata)) { +CmdArgs.push_back("-mextern-sdata=1"); + } else { +CmdArgs.push_back("-mextern-sdata=0"); + } + ExternSData->claim(); +} } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2045,6 +2045,12 @@ HelpText<"Extend the -G behaviour to object local data (MIPS)">; def mno_local_sdata : Flag<["-"], "mno-local-sdata">, Group, HelpText<"Do not extend the -G behaviour to object local data (MIPS)">; +def mextern_sdata : Flag<["-"], "mextern-sdata">, Group, + HelpText<"Assume that externally defined data is in the small data if it" + " meets the -G threshold (MIPS)">; +def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group, + HelpText<"Do not assume that externally defined data is in the small data if" + " it meets the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -50,6 +50,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s // CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" // +// -mno-abicalls -mgpopt -mextern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-extern-sdata -mextern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATA %s +// CHECK-MEXTERNSDATA: "-mllvm" "-mextern-sdata=1" +// +// -mno-abicalls -mgpopt -mno-extern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mextern-sdata -mno-extern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEXTERNSDATA %s +// CHECK-MNOEXTERNSDATA: "-mllvm" "-mextern-sdata=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s +// CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \
[PATCH] D35549: [mips] Add support for -m(no-)local-sdata
This revision was automatically updated to reflect the committed changes. Closed by commit rL308683: [mips] Add support for -m(no-)local-sdata (authored by sdardis). Changed prior to commit: https://reviews.llvm.org/D35549?vs=107071=107592#toc Repository: rL LLVM https://reviews.llvm.org/D35549 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -35,6 +35,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s // CHECK-MGPOPTDEF: "-mllvm" "-mgpopt" // +// -mgpopt -mno-abicalls -mlocal-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mno-local-sdata -mlocal-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATA %s +// CHECK-MLOCALSDATA: "-mllvm" "-mlocal-sdata=1" +// +// -mgpopt -mno-abicalls -mno-local-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mlocal-sdata -mno-local-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOLOCALSDATA %s +// CHECK-MNOLOCALSDATA: "-mllvm" "-mlocal-sdata=0" +// +// -mgpopt -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s +// CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1480,6 +1480,19 @@ if (NoABICalls && (!GPOpt || WantGPOpt)) { CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-mgpopt"); + +Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, + options::OPT_mno_local_sdata); +if (LocalSData) { + CmdArgs.push_back("-mllvm"); + if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { +CmdArgs.push_back("-mlocal-sdata=1"); + } else { +CmdArgs.push_back("-mlocal-sdata=0"); + } + LocalSData->claim(); +} + } else if ((!ABICalls || (!NoABICalls && ABICalls)) && WantGPOpt) D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2041,6 +2041,10 @@ def mno_gpopt : Flag<["-"], "mno-gpopt">, Group, HelpText<"Do not use GP relative accesses for symbols known to be in a small" " data section (MIPS)">; +def mlocal_sdata : Flag<["-"], "mlocal-sdata">, Group, + HelpText<"Extend the -G behaviour to object local data (MIPS)">; +def mno_local_sdata : Flag<["-"], "mno-local-sdata">, Group, + HelpText<"Do not extend the -G behaviour to object local data (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -35,6 +35,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s // CHECK-MGPOPTDEF: "-mllvm" "-mgpopt" // +// -mgpopt -mno-abicalls -mlocal-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mno-local-sdata -mlocal-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATA %s +// CHECK-MLOCALSDATA: "-mllvm" "-mlocal-sdata=1" +// +// -mgpopt -mno-abicalls -mno-local-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mlocal-sdata -mno-local-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOLOCALSDATA %s +// CHECK-MNOLOCALSDATA: "-mllvm" "-mlocal-sdata=0" +// +// -mgpopt -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s +// CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1480,6 +1480,19 @@ if (NoABICalls && (!GPOpt || WantGPOpt)) { CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-mgpopt"); + +Arg *LocalSData =
[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes
sdardis added inline comments. Comment at: include/clang/Basic/AttrDocs.td:1336 +if code compiled using ``-mlong-calls`` switch, it forces compiler to use +the ``jal`` instruction to call the function. + }]; rjmccall wrote: > sdardis wrote: > > rjmccall wrote: > > > I suggest the following wording: > > > > > > Clang supports the ``__attribute__((long_call))``, > > > ``__attribute__((far))``, and > > > ``__attribute__((near))`` attributes on MIPS targets. These attributes > > > may only be > > > added to function declarations and change the code generated by the > > > compiler when > > > directly calling the function. The ``near`` attribute allows calls to > > > the function to > > > be made using the ``jal`` instruction, which requires the function to be > > > defined in the > > > same 256MB segment as the caller. The ``long_call`` and ``far`` > > > attributes are > > > synonyms and require the use of a different call sequence that works > > > regardless of > > > the distance between the functions. > > > > > > These attributes take priority over command line switches such as > > > ``-mlong-calls``. > > > requires the function to be defined > > > > I'd change the "defined" to be "located". > > > > > in the same 256MB segment as the caller. > > > > I'd change this to: "in the same naturally aligned 256MB segment as the > > caller." > > > > This also needs a note saying that it has no effect for code compiled with > > -fpic. > Oh, yes, if these statements are true then it's absolutely important to > include them. I was going off of the raw ISA specification, since jal just > takes a relative offset, but if the toolchain has more specific requirements > then those are what should be documented. > > This whole feature is strange to me; do MIPS linkers just never introduce > things like branch islands and lazy-binding functions? > since jal just takes a relative offset, jal doesn't take an offset, the instruction takes an 26-bit immediate (called the instruction index) shifts it left 2 bits and combines it with the remaining upper bits of the address of the instruction in the delay slot of jal to form the new $pc--so it's possible to jump from the bottom of a 256MB segment to the top. (My apologies for the long answer here, jal is one of the odder control transfer instruction for MIPS.) > This whole feature is strange to me; do MIPS linkers just never introduce > things like branch islands and lazy-binding functions? This feature is orthogonal to lazy-binding functions. The usage of 'long-call' and 'near' is to support bare-metal / static relocation model environments where the caller and callee might be in different memory segments (e.g. KSEG0 and KSEG1) or have a custom memory layout for their program's sections. To the best of my knowledge, the GNU linker for MIPS only inserts stub functions / branch islands when compiling static code that calls PIC code. Repository: rL LLVM https://reviews.llvm.org/D35479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes
sdardis added a comment. Some comments on the documentation. Comment at: include/clang/Basic/AttrDocs.td:1336 +if code compiled using ``-mlong-calls`` switch, it forces compiler to use +the ``jal`` instruction to call the function. + }]; rjmccall wrote: > I suggest the following wording: > > Clang supports the ``__attribute__((long_call))``, ``__attribute__((far))``, > and > ``__attribute__((near))`` attributes on MIPS targets. These attributes may > only be > added to function declarations and change the code generated by the compiler > when > directly calling the function. The ``near`` attribute allows calls to the > function to > be made using the ``jal`` instruction, which requires the function to be > defined in the > same 256MB segment as the caller. The ``long_call`` and ``far`` attributes > are > synonyms and require the use of a different call sequence that works > regardless of > the distance between the functions. > > These attributes take priority over command line switches such as > ``-mlong-calls``. > requires the function to be defined I'd change the "defined" to be "located". > in the same 256MB segment as the caller. I'd change this to: "in the same naturally aligned 256MB segment as the caller." This also needs a note saying that it has no effect for code compiled with -fpic. Repository: rL LLVM https://reviews.llvm.org/D35479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.
This revision was automatically updated to reflect the committed changes. Closed by commit rL308431: [mips] Teach the driver to accept -m(no-)gpopt. (authored by sdardis). Changed prior to commit: https://reviews.llvm.org/D35548?vs=107114=107275#toc Repository: rL LLVM https://reviews.llvm.org/D35548 Files: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -1462,6 +1462,32 @@ A->claim(); } + Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt); + Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); + + // -mabicalls is the default for many MIPS environments, even with -fno-pic. + // -mgpopt is the default for static, -fno-pic environments but these two + // options conflict. We want to be certain that -mno-abicalls -mgpopt is + // the only case where -mllvm -mgpopt is passed. + // NOTE: We need a warning here or in the backend to warn when -mgpopt is + // passed explicitly when compiling something with -mabicalls + // (implictly) in affect. Currently the warning is in the backend. + bool NoABICalls = + ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); + if (NoABICalls && (!GPOpt || WantGPOpt)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=1"); + } else { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=0"); + if ((!ABICalls || (!NoABICalls && ABICalls)) && (!GPOpt || WantGPOpt)) +D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); + } + + if (GPOpt) +GPOpt->claim(); + if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { StringRef Val = StringRef(A->getValue()); if (mips::hasCompactBranches(CPUName)) { Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2035,6 +2035,12 @@ HelpText<"Use 64-bit floating point registers (MIPS only)">; def mfp32 : Flag<["-"], "mfp32">, Group, HelpText<"Use 32-bit floating point registers (MIPS only)">; +def mgpopt : Flag<["-"], "mgpopt">, Group, + HelpText<"Use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; +def mno_gpopt : Flag<["-"], "mno-gpopt">, Group, + HelpText<"Do not use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td @@ -279,6 +279,10 @@ def warn_target_unsupported_compact_branches : Warning< "ignoring '-mcompact-branches=' option because the '%0' architecture does not" " support it">, InGroup; +def warn_drv_unsupported_gpopt : Warning< + "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit" + " usage of}0-mabicalls">, + InGroup; def warn_drv_unable_to_find_directory_expected : Warning< "unable to find %0 directory, expected to be in '%1'">, Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td === --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td @@ -61,6 +61,7 @@ def EnumTooLarge : DiagGroup<"enum-too-large">; def UnsupportedNan : DiagGroup<"unsupported-nan">; def UnsupportedCB : DiagGroup<"unsupported-cb">; +def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">; def NullConversion : DiagGroup<"null-conversion">; def ImplicitConversionFloatingPointToBool : Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -10,6 +10,31 @@ // RUN: | FileCheck --check-prefix=CHECK-MNOABICALLS %s // CHECK-MNOABICALLS: "-target-feature" "+noabicalls" // +// -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s +// CHECK-MGPOPT-DEF-ABICALLS-NOT:
[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.
sdardis updated this revision to Diff 107114. sdardis marked an inline comment as done. sdardis added a comment. Addressed review comment, added warning when combining -mabicalls and -mgpopt. https://reviews.llvm.org/D35548 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c test/Driver/mips-gpopt-warning.c Index: test/Driver/mips-gpopt-warning.c === --- /dev/null +++ test/Driver/mips-gpopt-warning.c @@ -0,0 +1,6 @@ +// REQUIRES: mips-registered-target +// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt 2>&1 | FileCheck -check-prefix=IMPLICIT %s +// IMPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with the implicit usage of-mabicalls + +// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt -mabicalls 2>&1 | FileCheck -check-prefix=EXPLICIT %s +// EXPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with -mabicalls Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -10,6 +10,31 @@ // RUN: | FileCheck --check-prefix=CHECK-MNOABICALLS %s // CHECK-MNOABICALLS: "-target-feature" "+noabicalls" // +// -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s +// CHECK-MGPOPT-DEF-ABICALLS-NOT: "-mllvm" "-mgpopt" +// +// -mabicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mabicalls -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-EXPLICIT-ABICALLS %s +// CHECK-MGPOPT-EXPLICIT-ABICALLS-NOT: "-mllvm" "-mgpopt" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT %s +// CHECK-MGPOPT: "-mllvm" "-mgpopt=1" +// +// -mno-abicalls -mno-gpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOGPOPT %s +// CHECK-MNOGPOPT: "-mllvm" "-mgpopt=0" +// +// -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s +// CHECK-MGPOPTDEF: "-mllvm" "-mgpopt=1" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1462,6 +1462,32 @@ A->claim(); } + Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt); + Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); + + // -mabicalls is the default for many MIPS environments, even with -fno-pic. + // -mgpopt is the default for static, -fno-pic environments but these two + // options conflict. We want to be certain that -mno-abicalls -mgpopt is + // the only case where -mllvm -mgpopt is passed. + // NOTE: We need a warning here or in the backend to warn when -mgpopt is + // passed explicitly when compiling something with -mabicalls + // (implictly) in affect. Currently the warning is in the backend. + bool NoABICalls = + ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); + bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); + if (NoABICalls && (!GPOpt || WantGPOpt)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=1"); + } else { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=0"); + if ((!ABICalls || (!NoABICalls && ABICalls)) && (!GPOpt || WantGPOpt)) +D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1); + } + + if (GPOpt) +GPOpt->claim(); + if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { StringRef Val = StringRef(A->getValue()); if (mips::hasCompactBranches(CPUName)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2035,6 +2035,12 @@ HelpText<"Use 64-bit floating point registers (MIPS only)">; def mfp32 : Flag<["-"], "mfp32">, Group, HelpText<"Use 32-bit floating point registers (MIPS only)">; +def mgpopt : Flag<["-"], "mgpopt">, Group, + HelpText<"Use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; +def mno_gpopt : Flag<["-"], "mno-gpopt">, Group, + HelpText<"Do not use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">,
[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.
sdardis added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:1490 + GPOpt->claim(); + } + atanasyan wrote: > Could it be rewritten a bit shorter? > > ``` > bool NoAbiCalls = > ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls); > bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); > > if (NoAbiCalls && (!GPOpt || WantGPOpt)) { > CmdArgs.push_back("-mllvm"); > CmdArgs.push_back("-mgpopt=1"); > } else { > CmdArgs.push_back("-mllvm"); > CmdArgs.push_back("-mgpopt=0"); > } > > if (GPOpt) > GPOpt->claim(); > ``` Yes, it can. I think I mis-handled the case where -mabicalls and -mgpopt are combined. I'll reflow the logic along the lines of your suggestion and add a warning. https://reviews.llvm.org/D35548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35550: [mips] Add support for -m(no-)extern-data.
sdardis created this revision. Herald added a subscriber: arichardson. Add support for -m(no-)extern-data when using -mgpopt in the driver. It is enabled by default in the backend. https://reviews.llvm.org/D35550 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -50,6 +50,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s // CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" // +// -mno-abicalls -mgpopt -mextern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-extern-sdata -mextern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATA %s +// CHECK-MEXTERNSDATA: "-mllvm" "-mextern-sdata=1" +// +// -mno-abicalls -mgpopt -mno-extern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mextern-sdata -mno-extern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEXTERNSDATA %s +// CHECK-MNOEXTERNSDATA: "-mllvm" "-mextern-sdata=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s +// CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1466,6 +1466,7 @@ Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); Arg *LocalSData = Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); + Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, options::OPT_mno_extern_sdata); // -mabicalls is the default for many MIPS environments, even with -fno-pic. // -mgpopt is the default for static, -fno-pic environments but these two // options conflict. We want to be certain that -mno-abicalls -mgpopt is @@ -1498,6 +1499,16 @@ } LocalSData->claim(); } + +if (ExternSData) { + CmdArgs.push_back("-mllvm"); + if (ExternSData->getOption().matches(options::OPT_mextern_sdata)) { +CmdArgs.push_back("-mextern-sdata=1"); + } else { +CmdArgs.push_back("-mextern-sdata=0"); + } + ExternSData->claim(); +} } if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2045,6 +2045,12 @@ HelpText<"Extend the -G behaviour to object local data (MIPS)">; def mno_local_sdata : Flag<["-"], "mno-local-sdata">, Group, HelpText<"Do not extend the -G behaviour to object local data (MIPS)">; +def mextern_sdata : Flag<["-"], "mextern-sdata">, Group, + HelpText<"Assume that externally defined data is in the small data if it" + " meets the -G threshold (MIPS)">; +def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group, + HelpText<"Do not assume that externally defined data is in the small data if" + " it meets the -G threshold (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -50,6 +50,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s // CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" // +// -mno-abicalls -mgpopt -mextern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-extern-sdata -mextern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATA %s +// CHECK-MEXTERNSDATA: "-mllvm" "-mextern-sdata=1" +// +// -mno-abicalls -mgpopt -mno-extern-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mextern-sdata -mno-extern-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOEXTERNSDATA %s +// CHECK-MNOEXTERNSDATA: "-mllvm" "-mextern-sdata=0" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s +// CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@
[PATCH] D35549: [mips] Add support for -m(no-)local-sdata
sdardis created this revision. Herald added a subscriber: arichardson. Teach the driver to support -m(no-)local-sdata. The backend already matches GCC's default behaviour. https://reviews.llvm.org/D35549 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -35,6 +35,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s // CHECK-MGPOPTDEF: "-mllvm" "-mgpopt=1" // +// -mgpopt -mno-abicalls -mlocal-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mno-local-sdata -mlocal-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATA %s +// CHECK-MLOCALSDATA: "-mllvm" "-mlocal-sdata=1" +// +// -mgpopt -mno-abicalls -mno-local-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mlocal-sdata -mno-local-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOLOCALSDATA %s +// CHECK-MNOLOCALSDATA: "-mllvm" "-mlocal-sdata=0" +// +// -mgpopt -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s +// CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1464,7 +1464,8 @@ Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt); Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); - + Arg *LocalSData = + Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata); // -mabicalls is the default for many MIPS environments, even with -fno-pic. // -mgpopt is the default for static, -fno-pic environments but these two // options conflict. We want to be certain that -mno-abicalls -mgpopt is @@ -1487,6 +1488,16 @@ if (GPOpt) GPOpt->claim(); + +if (LocalSData) { + CmdArgs.push_back("-mllvm"); + if (LocalSData->getOption().matches(options::OPT_mlocal_sdata)) { +CmdArgs.push_back("-mlocal-sdata=1"); + } else { +CmdArgs.push_back("-mlocal-sdata=0"); + } + LocalSData->claim(); +} } if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2041,6 +2041,10 @@ def mno_gpopt : Flag<["-"], "mno-gpopt">, Group, HelpText<"Do not use GP relative accesses for symbols known to be in a small" " data section (MIPS)">; +def mlocal_sdata : Flag<["-"], "mlocal-sdata">, Group, + HelpText<"Extend the -G behaviour to object local data (MIPS)">; +def mno_local_sdata : Flag<["-"], "mno-local-sdata">, Group, + HelpText<"Do not extend the -G behaviour to object local data (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -35,6 +35,21 @@ // RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s // CHECK-MGPOPTDEF: "-mllvm" "-mgpopt=1" // +// -mgpopt -mno-abicalls -mlocal-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mno-local-sdata -mlocal-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATA %s +// CHECK-MLOCALSDATA: "-mllvm" "-mlocal-sdata=1" +// +// -mgpopt -mno-abicalls -mno-local-sdata +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt -mlocal-sdata -mno-local-sdata 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOLOCALSDATA %s +// CHECK-MNOLOCALSDATA: "-mllvm" "-mlocal-sdata=0" +// +// -mgpopt -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s +// CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1464,7 +1464,8 @@ Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt); Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); - + Arg *LocalSData = +
[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.
sdardis created this revision. Herald added a subscriber: arichardson. This patch teaches the driver to pass -mgpopt by default to the backend when it is supported, i.e. we are using -mno-abicalls. https://reviews.llvm.org/D35548 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/Clang.cpp test/Driver/mips-features.c Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -10,6 +10,31 @@ // RUN: | FileCheck --check-prefix=CHECK-MNOABICALLS %s // CHECK-MNOABICALLS: "-target-feature" "+noabicalls" // +// -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s +// CHECK-MGPOPT-DEF-ABICALLS-NOT: "-mllvm" "-mgpopt" +// +// -mabicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mabicalls -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-EXPLICIT-ABICALLS %s +// CHECK-MGPOPT-EXPLICIT-ABICALLS-NOT: "-mllvm" "-mgpopt" +// +// -mno-abicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT %s +// CHECK-MGPOPT: "-mllvm" "-mgpopt=1" +// +// -mno-abicalls -mno-gpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-gpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MNOGPOPT %s +// CHECK-MNOGPOPT: "-mllvm" "-mgpopt=0" +// +// -mno-abicalls +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPTDEF %s +// CHECK-MGPOPTDEF: "-mllvm" "-mgpopt=1" +// // -mips16 // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-mips16 -mips16 2>&1 \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1462,6 +1462,33 @@ A->claim(); } + Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt); + Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls); + + // -mabicalls is the default for many MIPS environments, even with -fno-pic. + // -mgpopt is the default for static, -fno-pic environments but these two + // options conflict. We want to be certain that -mno-abicalls -mgpopt is + // the only case where -mllvm -mgpopt is passed. + // NOTE: We need a warning here or in the backend to warn when -mgpopt is + // passed explicitly when compiling something with -mabicalls + // (implictly) in affect. Currently the warning is in the backend. + bool WantABICalls = + ABICalls && ABICalls->getOption().matches(options::OPT_mabicalls); + bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt); + bool DefaultABICalls = !ABICalls; + if (!DefaultABICalls && !WantABICalls) { +if (!GPOpt || WantGPOpt) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=1"); +} else { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-mgpopt=0"); +} + +if (GPOpt) + GPOpt->claim(); + } + if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) { StringRef Val = StringRef(A->getValue()); if (mips::hasCompactBranches(CPUName)) { Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2035,6 +2035,12 @@ HelpText<"Use 64-bit floating point registers (MIPS only)">; def mfp32 : Flag<["-"], "mfp32">, Group, HelpText<"Use 32-bit floating point registers (MIPS only)">; +def mgpopt : Flag<["-"], "mgpopt">, Group, + HelpText<"Use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; +def mno_gpopt : Flag<["-"], "mno-gpopt">, Group, + HelpText<"Do not use GP relative accesses for symbols known to be in a small" + " data section (MIPS)">; def mnan_EQ : Joined<["-"], "mnan=">, Group; def mabicalls : Flag<["-"], "mabicalls">, Group, HelpText<"Enable SVR4-style position-independent code (Mips only)">; Index: test/Driver/mips-features.c === --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -10,6 +10,31 @@ // RUN: | FileCheck --check-prefix=CHECK-MNOABICALLS %s // CHECK-MNOABICALLS: "-target-feature" "+noabicalls" // +// -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s +// CHECK-MGPOPT-DEF-ABICALLS-NOT: "-mllvm" "-mgpopt" +// +// -mabicalls -mgpopt +// RUN: %clang -target mips-linux-gnu -### -c %s -mabicalls -mno-gpopt -mgpopt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MGPOPT-EXPLICIT-ABICALLS %s +//
[PATCH] D35254: [mips][mt][7/7] Add driver option for the MIPS MT ASE.
This revision was automatically updated to reflect the committed changes. Closed by commit rL307847: [mips][mt][7/7] Add driver option for the MIPS MT ASE. (authored by sdardis). Repository: rL LLVM https://reviews.llvm.org/D35254 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/test/Driver/mips-features.c Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2027,6 +2027,10 @@ HelpText<"Enable MSA ASE (MIPS only)">; def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; +def mmt : Flag<["-"], "mmt">, Group, + HelpText<"Enable MT ASE (MIPS only)">; +def mno_mt : Flag<["-"], "mno-mt">, Group, + HelpText<"Disable MT ASE (MIPS only)">; def mfp64 : Flag<["-"], "mfp64">, Group, HelpText<"Use 64-bit floating point registers (MIPS only)">; def mfp32 : Flag<["-"], "mfp32">, Group, Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -70,6 +70,18 @@ // RUN: | FileCheck --check-prefix=CHECK-NOMMSA %s // CHECK-NOMMSA: "-target-feature" "-msa" // +// -mmt +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-mt -mmt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MMT %s +// CHECK-MMT: "-target-feature" "+mt" +// +// -mno-mt +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mmt -mno-mt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMMT %s +// CHECK-NOMMT: "-target-feature" "-mt" +// // -modd-spreg // RUN: %clang -target mips-linux-gnu -### -c %s -mno-odd-spreg -modd-spreg 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MODDSPREG %s Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp === --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp @@ -301,6 +301,7 @@ "nomadd4"); AddTargetFeature(Args, Features, options::OPT_mlong_calls, options::OPT_mno_long_calls, "long-calls"); + AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt,"mt"); } mips::NanEncoding mips::getSupportedNanEncoding(StringRef ) { Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2027,6 +2027,10 @@ HelpText<"Enable MSA ASE (MIPS only)">; def mno_msa : Flag<["-"], "mno-msa">, Group, HelpText<"Disable MSA ASE (MIPS only)">; +def mmt : Flag<["-"], "mmt">, Group, + HelpText<"Enable MT ASE (MIPS only)">; +def mno_mt : Flag<["-"], "mno-mt">, Group, + HelpText<"Disable MT ASE (MIPS only)">; def mfp64 : Flag<["-"], "mfp64">, Group, HelpText<"Use 64-bit floating point registers (MIPS only)">; def mfp32 : Flag<["-"], "mfp32">, Group, Index: cfe/trunk/test/Driver/mips-features.c === --- cfe/trunk/test/Driver/mips-features.c +++ cfe/trunk/test/Driver/mips-features.c @@ -70,6 +70,18 @@ // RUN: | FileCheck --check-prefix=CHECK-NOMMSA %s // CHECK-NOMMSA: "-target-feature" "-msa" // +// -mmt +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-mt -mmt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MMT %s +// CHECK-MMT: "-target-feature" "+mt" +// +// -mno-mt +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mmt -mno-mt 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMMT %s +// CHECK-NOMMT: "-target-feature" "-mt" +// // -modd-spreg // RUN: %clang -target mips-linux-gnu -### -c %s -mno-odd-spreg -modd-spreg 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MODDSPREG %s Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp === --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp @@ -301,6 +301,7 @@ "nomadd4"); AddTargetFeature(Args, Features, options::OPT_mlong_calls, options::OPT_mno_long_calls, "long-calls"); + AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt,"mt"); } mips::NanEncoding mips::getSupportedNanEncoding(StringRef ) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits