1. Nov 13, 2020
    • Fangrui Song's avatar
      [ELF] Don't consider SHF_ALLOC ".debug*" sections debug sections · 8df4e609
      Fangrui Song authored
      Fixes PR48071
      
      * The Rust compiler produces SHF_ALLOC `.debug_gdb_scripts` (which normally does not have the flag)
      * `.debug_gdb_scripts` sections are removed from `inputSections` due to --strip-debug/--strip-all
      * When processing --gc-sections, pieces of a SHF_MERGE section can be marked live separately
      
      `=>` segfault when marking liveness of a `.debug_gdb_scripts` which is not split into pieces (because it is not in `inputSections`)
      
      This patch circumvents the problem by not treating SHF_ALLOC ".debug*" as debug sections (to prevent --strip-debug's stripping)
      (which is still useful on its own).
      
      Reviewed By: grimar
      
      Differential Revision: https://reviews.llvm.org/D91291
      8df4e609
    • Kevin P. Neal's avatar
      [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point · ac523d2d
      Kevin P. Neal authored
      As of D80952 we are disabling strict floating point on all hosts except
      those that are explicitly listed as supported. Use of strict floating point
      on other hosts requires use of the -fexperimental-strict-floating-point
      flag. This is to avoid bugs like "https://bugs.llvm.org/show_bug.cgi?id=45329"
      (which has an incorrect link in the previous review).
      
      In the review for D80952 I was asked to mark the -fexperimental option as
      a MarshallingInfoFlag. This patch does exactly that.
      
      Differential Revision: https://reviews.llvm.org/D88987
      ac523d2d
    • Sanjay Patel's avatar
      8a1e6366
    • Jamie Schmeiser's avatar
      Reland: Introduce -dot-cfg-mssa option which creates dot-cfg style file with... · 5f672fef
      Jamie Schmeiser authored
      Reland: Introduce -dot-cfg-mssa option which creates dot-cfg style file with mssa comments included in source
      
      Summary:
      Expand the print-memoryssa and print<memoryssa> passes with a new hidden
      option -cfg-dot-mssa that names a file. When set, a dot-cfg style file
      will be generated into the named file with the memoryssa comments retained
      and those blocks containing them shown in light pink. The option does
      nothing in isolation.
      
      Author: Jamie Schmeiser <schmeise@ca.ibm.com>
      
      Reviewed By: asbirlea (Alina Sbirlea), dblaikie (David Blaikie)
      
      Differential Revision: https://reviews.llvm.org/D90638
      5f672fef
    • Nico Weber's avatar
      [gn build] (semi-manually) port 173b5116 · 37a1336d
      Nico Weber authored
      37a1336d
    • Alexander Kornienko's avatar
      76b6cb51
    • Simon Pilgrim's avatar
      [ValueTracking] Update computeKnownBitsFromShiftOperator callbacks to take... · f72d350b
      Simon Pilgrim authored
      [ValueTracking] Update computeKnownBitsFromShiftOperator callbacks to take KnownBits shift amount. NFCI.
      
      We were creating this internally, but will need to support general KnownBits amounts as part of D90479.
      f72d350b
    • Fangrui Song's avatar
      [ELF] Make SORT_INIT_PRIORITY support .ctors.N · 40a42f9f
      Fangrui Song authored
      Input sections `.ctors/.ctors.N` may go to either the output section `.init_array` or the output section `.ctors`:
      
      * output `.ctors`: currently we sort them by name. This patch changes to sort by priority from high to low. If N in `.ctors.N` is in the form of %05u, there is no semantic difference. Actually GCC and Clang do use %05u. (In the test `ctors_dtors_priority.s` and Gold's test `gold/testsuite/script_test_14.s`, we can see %03u, but they are not really produced by compilers.)
      * output `.init_array`: users can provide an input section description `SORT_BY_INIT_PRIORITY(.init_array.* .ctors.*)` to mix `.init_array.*` and `.ctors.*`. This can make .init_array.N and .ctors.(65535-N) interchangeable.
      
      With this change, users can mix `.ctors.N` and `.init_array.N` in `.init_array` (PR44698 and PR48096) with linker scripts. As an example:
      
      ```
      SECTIONS {
        .init_array : {
          *(SORT_BY_INIT_PRIORITY(.init_array.* .ctors.*))
          *(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)
        }
      } INSERT AFTER .fini_array;
      SECTIONS {
        .fini_array : {
          *(SORT_BY_INIT_PRIORITY(.fini_array.* .dtors.*))
          *(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)
        }
      } INSERT BEFORE .init_array;
      ```
      
      Reviewed By: psmith
      
      Differential Revision: https://reviews.llvm.org/D91187
      40a42f9f
    • Fangrui Song's avatar
      [ELF] Sort by input order within an input section description · 73d01a80
      Fangrui Song authored
      According to
      https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html#Input-Section-Basics
      for `*(.a .b)`, the order should match the input order:
      
      * for `ld 1.o 2.o`, sections from 1.o precede sections from 2.o
      * within a file, `.a` and `.b` appear in the section header table order
      
      This patch implements the behavior. The interaction with `SORT*` and --sort-section is:
      
      Matched sections are ordered by radix sort with the keys being `(SORT*, --sort-section, input order)`,
      where `SORT*` (if present) is most significant.
      
      > Note, multiple `SORT*` within an input section description has undocumented and
      > confusing behaviors in GNU ld:
      > https://sourceware.org/pipermail/binutils/2020-November/114083.html
      > Therefore multiple `SORT*` is not the focus for this patch but
      > this patch still strives to have an explainable behavior.
      
      As an example, we partition `SORT(a.*) b.* c.* SORT(d.*)`, into
      `SORT(a.*) | b.* c.* | SORT(d.*)` and perform sorting within groups. Sections
      matched by patterns between two `SORT*` are sorted by input order.  If
      --sort-alignment is given, they are sorted by --sort-alignment, breaking tie by
      input order.
      
      This patch also allows a section to be matched by multiple patterns, previously
      duplicated sections could occupy more space in the output and had erroneous zero bytes.
      
      The patch is in preparation for support for
      `*(SORT_BY_INIT_PRIORITY(.init_array.* .ctors.*)) *(.init_array .ctors)`,
      which will allow LLD to mix .ctors*/.init_array* like GNU ld (gold's --ctors-in-init-array)
      PR44698 and PR48096
      
      Reviewed By: grimar, psmith
      
      Differential Revision: https://reviews.llvm.org/D91127
      73d01a80
    • Fangrui Song's avatar
      [ELF] Support multiple SORT in an input section description · 2a9aed0e
      Fangrui Song authored
      The second `SORT` in `*(SORT(...) SORT(...))` is incorrectly parsed as a file pattern.
      Fix the bug by stopping at `SORT*` in `readInputSectionsList`.
      
      Reviewed By: grimar
      
      Differential Revision: https://reviews.llvm.org/D91180
      2a9aed0e
    • Baptiste Saleil's avatar
      [PowerPC] Prevent the use of MMA with P9 and earlier · 170e45ae
      Baptiste Saleil authored
      We want to allow using MMA on P10 CPU only. This patch prevents the use of MMA
      with the -mmma option on P9 CPUs and earlier.
      
      Differential Revision: https://reviews.llvm.org/D91200
      170e45ae
    • Raphael Isemann's avatar
      [lldb] Replace TestAbortExitCode with a debugserver specific test · d4b08ccb
      Raphael Isemann authored
      When I added TestAbortExitCode I actually planned this to be a generic test for the
      exit code functionality on POSIX systems. However due to all the different test setups we
      can have I don't think this worked out. Right now the test had to be made so permissive
      that it pretty much can't fail.
      
      Just to summarize, we would need to support the following situations:
      1. ToT debugserver (on macOS)
      2. lldb-server (on other platforms)
      3. Any old debugserver version when using the system debugserver (on macOS)
      
      This patch is removing TestAbortExitCode and adds a ToT debugserver specific test
      that checks the patch that motivated the whole exit code testing. There is already
      an exit-code test for lldb-server from what I can see and 3) is pretty much untestable
      as we don't know anything about the system debugserver.
      
      Reviewed By: kastiglione
      
      Differential Revision: https://reviews.llvm.org/D89305
      d4b08ccb
    • Zbigniew Sarbinowski's avatar
      [SystemZ][ZOS] Porting the time functions within libc++ to z/OS · 173b5116
      Zbigniew Sarbinowski authored
      This patch is one part of many steps required to build libc++ and libc++abi libraries on z/OS.  This particular deals with time related functions and consists of the following 3 parts.
      
      1) Initialization of :timeval within libc++ library need to be adjusted to work on z/OS.
      The following is z/OS definition from time.h which includes additional aggregate member.
      typedef signed int suseconds_t;
      struct timeval {
      time_t tv_sec;
      char tv_usec_pad[4];
      suseconds_t tv_usec;
      };
      
      In contracts the following is definition from time.h on Linux.
      
      typedef long int __suseconds_t;
      struct timeval
      {
      __time_t tv_sec;
      __suseconds_t tv_usec;
      };
      
      2) In addition, retrieving ::timespec within libc++ library needs to be adjusted to compensate the difference of some of the members of ::stat depending of the target host.
      Here are the 2 members in conflict on z/OS extracted from stat.h.
      struct stat {
      ...
      time_t st_atime;
      time_t st_mtime;
      ...
      };
      In contract here is Linux equivalent from stat.h.
      struct stat
      {
      ...
      struct timespec st_atim;
      struct timespec st_mtim;
      ...
      };
      
      3) On Linux both members are of type timespec whereas on z/OS an object of type timespec need to be constructed first before retrieving it within libc++ library.
      
      The libc++ header file __threading_support calls nanosleep, which is not available on z/OS.
      The equivalent functionality will be implemented by using both sleep() and usleep().
      
      Reviewed By: ldionne, #libc
      
      Differential Revision: https://reviews.llvm.org/D87940
      173b5116
    • Simon Pilgrim's avatar
      [KnownBits] Add KnownBits::makeConstant helper. NFCI. · 89967427
      Simon Pilgrim authored
      Helper for cases where we need to create a KnownBits from a (fully known) constant value.
      89967427
  2. Nov 12, 2020