1. Dec 15, 2021
    • Fangrui Song's avatar
      [ELF] Adjust getOutputSectionName prefix order · 3deb82cd
      Fangrui Song authored
      Sorting the prefixes by decreasing frequency can improve performance.
      .gcc_except_table is relatively frequent, so move it ahead.
      .ctors and .dtors mostly disappear and should be the last.
      3deb82cd
    • Nikita Popov's avatar
      [CodeGen] Store ElementType in Address · abbc2e99
      Nikita Popov authored
      Explicitly track the pointer element type in Address, rather than
      deriving it from the pointer type, which will no longer be possible
      with opaque pointers. This just adds the basic facility, for now
      everything is still going through the deprecated constructors.
      
      I had to adjust one place in the LValue implementation to satisfy
      the new assertions: Global registers are represented as a
      MetadataAsValue, which does not have a pointer type. We should
      avoid using Address in this case.
      
      This implements a part of D103465.
      
      Differential Revision: https://reviews.llvm.org/D115725
      abbc2e99
    • Fangrui Song's avatar
      5816f185
    • Nikolas Klauser's avatar
      [libc++][NFC] Use _LIBCPP_DEBUG_ASSERT in <string> · af88bc15
      Nikolas Klauser authored
      Use `_LIBCPP_DEBUG_ASSERT` instead of `_LIBCPP_ASSERT` and guarding it with `LIBCPP_DEBUG_LEVEL == 2`
      
      Reviewed By: ldionne, #libc
      
      Spies: libcxx-commits
      
      Differential Revision: https://reviews.llvm.org/D115765
      af88bc15
    • Esme-Yi's avatar
      [DebugInfo][DWARF] emit DW_AT_accessibility attribute for class/struct/union types. · c0529efc
      Esme-Yi authored
      Summary:
      	This patch emits the DW_AT_accessibility attribute for
      class/struct/union types in the LLVM part.
      
      Reviewed By: dblaikie
      
      Differential Revision: https://reviews.llvm.org/D115606
      c0529efc
    • gysit's avatar
      [mlir][linalg] Remove RangeOp and RangeType. · 9912bed7
      gysit authored
      Remove the RangeOp and the RangeType that are not actively used anymore. After removing RangeType, the LinalgTypes header only includes the generated dialect header.
      
      Reviewed By: nicolasvasilache
      
      Differential Revision: https://reviews.llvm.org/D115727
      9912bed7
    • Matthias Springer's avatar
      [adt] Fix compiler warning in test · 7029a688
      Matthias Springer authored
      Differential Revision: https://reviews.llvm.org/D115589
      7029a688
    • Fangrui Song's avatar
      89661a0e
    • Logan Chien's avatar
      Print the sign of negative infinity · 9eb71608
      Logan Chien authored
      Differential Revision: https://reviews.llvm.org/D111917
      9eb71608
    • Craig Topper's avatar
      [RISCV] Add more curly braces to constexpr array initialization to hopefully appease gcc 5. · 4cd6dc5a
      Craig Topper authored
      Build bot failure found after D115668.
      4cd6dc5a
    • Fangrui Song's avatar
      [ELF] Use SmallVector for SharedFile and simplify parseVerdefs · c720b16a
      Fangrui Song authored
      SHT_GNU_verdef is typically small, so it's unnecessary to reserve the vector.
      
      While here, fix a hypothetical issue when SHT_GNU_verdef has non-increasing
      version indexes, which don't happen with GNU ld, gold, ld.lld's output.
      
      My x86-64 lld executable is 256 bytes smaller.
      c720b16a
    • Fangrui Song's avatar
      [ELF] Make InputFile smaller · 1ff1d50d
      Fangrui Song authored
      sizeof(ObjFile<ELF64LE>) is decreased from 344 to 272 on an ELF64 system.
      In a large link with 30000 ObjFiles, this may be 2+MiB saving.
      
      Change std::vector members to SmallVector, and std::string members to
      SmallString<0> (these members typically don't benefit from small string optimization).
      On Linux x86-64 the lld executable is ~6k smaller.
      1ff1d50d
    • Nico Weber's avatar
      d4f3af2f
    • Stephen Hines's avatar
      [compiler-rt][AArch64] Add a workaround for Exynos 9810 · cce4a725
      Stephen Hines authored
      Big.LITTLE Heterogeneous architectures, as described by ARM [1],
      require that the instruction set architecture of the big and little
      cores be compatible. However, the Samsung Exynos 9810 is known to
      have different ISAs in its core.
      According to [2], some cores are ARMv8.2 and others are ARMv8.0.
      
      Since LSE is for ARMv8.1 and later, it should be disabled
      for this broken CPU.
      
      [1] https://developer.arm.com/documentation/den0024/a/big-LITTLE-Technology
      [2] https://github.com/golang/go/issues/28431
      
      Patch by: Byoungchan Lee (byoungchan.lee@gmx.com)
      Reviewed By: srhines
      
      Differential Revision: https://reviews.llvm.org/D114523
      cce4a725
    • Lang Hames's avatar
      [llvm-jitlink] Update handling of library options. · 5255ca97
      Lang Hames authored
      Adds -L<search-path> and -l<library> options that are analogous to ld's
      versions.
      
      Each instance of -L<search-path> or -l<library> will apply to the most recent
      -jd option on the command line (-jd <name> creates a JITDylib with the given
      name). Library names will match against JITDylibs first, then llvm-jitlink will
      look through the search paths for files named <search-path>/lib<library>.dylib
      or <search-path>/lib<library>.a.
      
      The default "main" JITDylib will link against all JITDylibs created by -jd
      options, and all JITDylibs will link against the process symbols (unless
      -no-process-symbols is specified).
      
      The -dlopen option is renamed -preload, and will load dylibs into the JITDylib
      for the ORC runtime only.
      
      The effect of these changes is to make it easier to describe a non-trivial
      program layout to llvm-jitlink for testing purposes. E.g. the following
      invocation describes a program consisting of three JITDylibs: "main" (created
      implicitly) containing main.o, "Foo" containing foo1.o and foo2.o, and linking
      against library "bar" (not a JITDylib, so it must be a .dylib or .a on disk)
      and "Baz" (which is a JITDylib), and "Baz" containing baz.o.
      
      llvm-jitlink \
        main.o \
        -jd Foo foo1.o foo2.o -L${HOME}/lib -lbar -lBaz
        -jd Baz baz.o
      5255ca97
    • Nico Weber's avatar
      [clang] Use usual lit pattern for CLANG_DEFAULT_PIE_ON_LINUX and LLVM_WITH_Z3 · b45ad736
      Nico Weber authored
      See D28294 for context.
      
      Differential Revision: https://reviews.llvm.org/D115751
      b45ad736
    • Kirill Stoimenov's avatar
      [ASan] Added NO_EXEC_STACK_DIRECTIVE to assembly callback file. · da7e9e34
      Kirill Stoimenov authored
      This is present in our assembly files. It should fix decorate_proc_maps.cpp failures because of shadow memory being allocated as executable.
      
      Reviewed By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D115552
      da7e9e34
    • Wenlei He's avatar
      [llvm-profgen] Turn on preinliner by default · f6f0409f
      Wenlei He authored
      preinliner has been tuned on large server workloads and it's not ready to be turned on by default. this change also updates the thresholds based on tuning.
      
      Differential Revision: https://reviews.llvm.org/D115770
      f6f0409f
    • Sindhu Chittireddy's avatar
      Avoid setting tbaa on the store of return type of call to inline assembler. · 4706a297
      Sindhu Chittireddy authored
      In 32bit mode, attaching TBAA metadata to the store following the call
      to inline assembler results in describing the wrong type by making a
      fake lvalue(i.e., whatever the inline assembler happens to leave in
      EAX:EDX.) Even if inline assembler somehow describes the correct type,
      setting TBAA information on return type of call to inline assembler is
      likely not correct, since TBAA rules need not apply to inline assembler.
      
      Differential Revision: https://reviews.llvm.org/D115320
      4706a297
    • LLVM GN Syncbot's avatar
      [gn build] Port 4299d8d0 · 794b4df5
      LLVM GN Syncbot authored
      794b4df5
    • Sam McCall's avatar
      6917f87b
    • Lang Hames's avatar
      [ORC] Add MaterializationUnit::Interface parameter to ObjectLayer::add. · 4299d8d0
      Lang Hames authored
      Also moves object interface building functions out of Mangling.h and in to the
      new ObjectFileInterfaces.h header, and updates the llvm-jitlink tool to use
      custom object interfaces rather than a custom link layer.
      
      ObjectLayer::add overloads are added to match the old signatures (which
      do not take a MaterializationUnit::Interface). These overloads use the
      standard getObjectFileInterface function to build an interface.
      
      Passing a MaterializationUnit::Interface explicitly makes it easier to alter
      the effective interface of the object file being added, e.g. by changing symbol
      visibility/linkage, or renaming symbols (in both cases the changes will need to
      be mirrored by a JITLink pass at link time to update the LinkGraph to match the
      explicit interface). Altering interfaces in this way can be useful when lazily
      compiling (e.g. for renaming function bodies) or emulating linker options (e.g.
      demoting all symbols to hidden visibility to emulate -load_hidden).
      4299d8d0
    • LLVM GN Syncbot's avatar
      [gn build] Port 3f630cff · d4127c0d
      LLVM GN Syncbot authored
      d4127c0d
    • wlei's avatar
      [CSSPGO][llvm-profgen] Fix external address issues of perf reader (return to external addr part) · 0f53df86
      wlei authored
      Before we have an issue with artificial LBR whose source is a return, recalling that "an internal code(A) can return to external address, then from the external address call a new internal code(B), making an artificial branch that looks like a return from A to B can confuse the unwinder". We just ignore the LBRs after this artificial LBR which can miss some samples. This change aims at fixing this by correctly unwinding them instead of ignoring them.
      
      List some typical scenarios covered by this change.
      
      1)  multiple sequential call back happen in external address, e.g.
      
      ```
      [ext, call, foo] [foo, return, ext] [ext, call, bar]
      ```
      Unwinder should avoid having foo return from bar. Wrong call stack is like [foo, bar]
      
      2) the call stack before and after external call should be correctly unwinded.
      ```
       {call stack1}                                            {call stack2}
       [foo, call, ext]  [ext, call, bar]  [bar, return, ext]  [ext, return, foo ]
      ```
      call stack 1 should be the same to call stack2. Both shouldn't be truncated
      
      3) call stack should be truncated after call into external code since we can't do inlining with external code.
      
      ```
       [foo, call, ext]  [ext, call, bar]  [bar, call, baz] [baz, return, bar ] [bar, return, ext]
      ```
      the call stack of code in baz should not include foo.
      
      ### Implementation:
      
      We leverage artificial frame to fix #2 and #3: when we got a return artificial LBR, push an extra artificial frame to the stack. when we pop frame, check if the parent is an artificial frame to pop(fix #2). Therefore, call/ return artificial LBR is just the same as regular LBR which can keep the call stack.
      
      While recording context on the trie, artificial frame is used as a tag indicating that we should truncate the call stack(fix #3).
      
      To differentiate #1 and #2, we leverage `getCallAddrFromFrameAddr`.  Normally the target of the return should be the next inst of a call inst and `getCallAddrFromFrameAddr` will return the address of call inst. Otherwise, getCallAddrFromFrameAddr will return to 0 which is the case of #1.
      
      Reviewed By: hoy, wenlei
      
      Differential Revision: https://reviews.llvm.org/D115550
      0f53df86
    • wlei's avatar
      [llvm-profgen] Fix to use getUntrackedCallsites outside the loop · 30c3aba9
      wlei authored
      Unwinder is hoisted out in https://reviews.llvm.org/D115550, so fix the useage of getUntrackedCallsites.
      
      Reviewed By: hoy, wenlei
      
      Differential Revision: https://reviews.llvm.org/D115760
      30c3aba9
    • wlei's avatar
      [CSSPGO][llvm-profgen] Fix external address issues of perf reader (leading external LBR part) · 3dcb60db
      wlei authored
      We can have the sampling just hit into the external addresses, in that case, both the top stack frame and the latest LBR target are external addresses. For example:
      ```
      	        ffffffff
       0x4006c8/0xffffffff/P/-/-/0  0x40069b/0x400670/M/-/-/0
      
       	          ffffffff
      	          40067e
      0xffffffff/0xffffffff/P/-/-/0  0x4006c8/0xffffffff/P/-/-/0  0x40069b/0x400670/M/-/-/0
      ```
      Before we will ignore the entire samples. However, we found there exists some internal LBRs in the remaining part of sample, the range between them is still a valid range, we will lose some valid LBRs. Those LBRs will be unwinded based on a empty(context-less) call stack.
      
      This change tries to fix it, instead of ignoring the entire sample, we only ignore the leading external addresses.
      
      Note that the first outgoing LBR is useful since there is a valid range between it's source and next LBR's target.
      
      Reviewed By: hoy, wenlei
      
      Differential Revision: https://reviews.llvm.org/D115538
      3dcb60db
    • wlei's avatar
      [llvm-profgen] Skip disassembling for PLT section · 32205717
      wlei authored
      Skip disassembling .plt section, then .plt section code will be treated as external code.
      
      Reviewed By: hoy, wenlei
      
      Differential Revision: https://reviews.llvm.org/D115699
      32205717
    • Hongtao Yu's avatar
      [CSSPGO] Warn instead of error out for modules that are not probed. · d7b7b649
      Hongtao Yu authored
      Modules that are not compiled with pseudo probe enabled can still be compiled with a sample profile input, such as in LTO postlink where other modules are probed. Since the profile is unrelated to the current modules, we should warn instead of error out the compilation.
      
      Reviewed By: wenlei
      
      Differential Revision: https://reviews.llvm.org/D115642
      d7b7b649
    • Fangrui Song's avatar
    • Fangrui Song's avatar
      Reland D114783/D115603 [ELF] Split scanRelocations into scanRelocations/postScanRelocations · cf783be8
      Fangrui Song authored
      (Fixed an issue about GOT on a copy relocated alias.)
      (Fixed an issue about not creating r_addend=0 IRELATIVE for unreferenced non-preemptible ifunc.)
      
      The idea is to make scanRelocations mark some actions are needed (GOT/PLT/etc)
      and postpone the real work to postScanRelocations. It gives some flexibility:
      
      * Make it feasible to support .plt.got (PR32938): we need to know whether GLOB_DAT and JUMP_SLOT are both needed.
      * Make non-preemptible IFUNC handling slightly cleaner: avoid setting/clearing sym.gotInIgot
      * -z nocopyrel: report all copy relocation places for one symbol
      * Make GOT deduplication feasible
      * Make parallel relocation scanning feasible (if we can avoid all stateful operations and make Symbol attributes atomic), but parallelism may not be the appealing choice
      
      Since this patch moves a large chunk of code out of ELFT templates. My x86-64
      executable is actually a few hundred bytes smaller.
      
      For ppc32-ifunc-nonpreemptible-pic.s: I remove absolute relocation references to non-preemptible ifunc
      because absolute relocation references are incorrect in -fpie mode.
      
      Reviewed By: peter.smith, ikudrin
      
      Differential Revision: https://reviews.llvm.org/D114783
      cf783be8
    • Fangrui Song's avatar
      [ELF][test] Test unreferenced non-preemptible ifunc · 04cf411c
      Fangrui Song authored
      Add missing coverage exposed by D114783.
      There should be no associated IRELATIVE, otherwise (a) glibc ld.so may
      crash (b) it wastes space (c) unused IPLT causes confusion.
      04cf411c
    • David Blaikie's avatar
      DebugInfo: Fix test to match comment · 51776eca
      David Blaikie authored
      This produced a few verifier warnings that came up while I was
      investigating something else here. Change the assembly to match the
      comment so it's warning free. Doesn't seem necessary to change the
      CHECKs for the test since it's just a bug in the test, not in the code
      under test.
      51776eca
    • David Blaikie's avatar
      DebugInfo: Sink string form validation down from verifier to form parsing · 92f2d02b
      David Blaikie authored
      Avoid duplicating the string decoding - improve the error messages down
      in form parsing (& produce an Expected<const char*> instead of
      Optional<const char*> to communicate the extra error details)
      92f2d02b
    • Lang Hames's avatar
      [ORC] Add early-out to OL_applyQueryPhase1. · 3ce1e942
      Lang Hames authored
      If all symbols in a lookup match before we reach the end of the search order
      then bail out of the search-order loop early.
      
      This should reduce unnecessary contention on the session lock and improve
      readability of the debug logs.
      3ce1e942
    • David Blaikie's avatar
      DebugInfo: Migrate callers from getAsCString to dwarf::toString · 71e5488a
      David Blaikie authored
      This makes a bunch of these call sites independent of a follow-up change
      I'm making to have getAsCString return Expected<const char*> for more
      descriptive error messages so that the failures there can be
      communicated up to DWARFVerifier (or other callers who want to provide
      more verbose diagnostics) so DWARFVerifier doesn't have to re-implement
      the string lookup logic and error checking.
      71e5488a
    • Hongtao Yu's avatar
      [CSSPGO] Use nested context-sensitive profile. · 5740bb80
      Hongtao Yu authored
      CSSPGO currently employs a flat profile format for context-sensitive profiles. Such a flat profile allows for precisely manipulating contexts that is either inlined or not inlined. This is a benefit over the nested profile format used by non-CS AutoFDO. A downside of this is the longer build time due to parsing the indexing the full CS contexts.
      
      For a CS flat profile, though only the context profiles relevant to a module are loaded when that module is compiled, the cost to figure out what profiles are relevant is noticeably high when there're many contexts,  since the sample reader will need to scan all context strings anyway. On the contrary, a nested function profile has its related inline subcontexts isolated from other unrelated contexts. Therefore when compiling a set of functions, unrelated contexts will never need to be scanned.
      
      In this change we are exploring using nested profile format for CSSPGO. This is expected to work based on an assumption that with a preinliner-computed profile all contexts are precomputed and expected to be inlined by the compiler. Contexts not expected to be inlined will be cut off and returned to corresponding base profiles (for top-level outlined functions). This naturally forms a nested profile where all nested contexts are expected to be inlined. The compiler will less likely optimize on derived contexts that are not precomputed.
      
      A CS-nested profile will look exactly the same with regular nested profile except that each nested profile can come with an attributes. With pseudo probes,  a nested profile shown as below can also have a CFG checksum.
      
      ```
      
      main:1968679:12
       2: 24
       3: 28 _Z5funcAi:18
       3.1: 28 _Z5funcBi:30
       3: _Z5funcAi:1467398
        0: 10
        1: 10 _Z8funcLeafi:11
        3: 24
        1: _Z8funcLeafi:1467299
         0: 6
         1: 6
         3: 287884
         4: 287864 _Z3fibi:315608
         15: 23
         !CFGChecksum: 138828622701
         !Attributes: 2
        !CFGChecksum: 281479271677951
        !Attributes: 2
      ```
      
      Specific work included in this change:
      - A recursive profile converter to convert CS flat profile to nested profile.
      - Extend function checksum and attribute metadata to be stored in nested way for text profile and extbinary profile.
      - Unifiy sample loader inliner path for CS and preinlined nested profile.
       - Changes in the sample loader to support probe-based nested profile.
      
      I've seen promising results regarding build time. A nested profile can result in a 20% shorter build time than a CS flat profile while keep an on-par performance. This is with -duplicate-contexts-into-base=1.
      
      Test Plan:
      
      Reviewed By: wenlei
      
      Differential Revision: https://reviews.llvm.org/D115205
      5740bb80
    • Fangrui Song's avatar
      Revert D114783 [ELF] Split scanRelocations into scanRelocations/postScanRelocations · ea15b862
      Fangrui Song authored
      May cause a failure for non-preemptible `bcmp` in a glibc -static link.
      ea15b862
    • Stephan T. Lavavej's avatar
      [NFC] Fix typos in release notes. · 8bd106a8
      Stephan T. Lavavej authored
      Reviewed By: ldionne, Mordante, MaskRay
      
      Differential Revision: https://reviews.llvm.org/D115685
      8bd106a8
    • Konstantin Varlamov's avatar
      [libc++][ranges] Implement ranges::uninitialized_default_construct{,_n}. · 3f630cff
      Konstantin Varlamov authored
      Defined in [`specialized.algorithms`](wg21.link/specialized.algorithms).
      
      Also:
      - refactor the existing non-range implementation so that most of it
        can be shared between the range-based and non-range-based algorithms;
      - remove an existing test for the non-range version of
        `uninitialized_default_construct{,_n}` that likely triggered undefined
        behavior (it read the values of built-ins after default-initializing
        them, essentially reading uninitialized memory).
      
      Reviewed By: #libc, Quuxplusone, ldionne
      
      Differential Revision: https://reviews.llvm.org/D115315
      3f630cff
    • Jon Chesterfield's avatar
      [amdgpu] Drop lowering of LDS used by global variables · 624f12d3
      Jon Chesterfield authored
      Approximately revert D103431.
      
      LDS variables are allocated at kernel launch and deallocated at kernel exit.
      The address is therefore kernel execution dependent. Global variables are
      initialized by values written to .data, which can't be done for a LDS variable
      as there is no kernel running, or by a global constructor. Initializing the
      global to the address of some LDS allocated by a global constructor is possible
      but indistinguishable from undef.
      
      Assigning the address of a LDS variable to a global should be a sema error. It
      isn't for openmp, haven't checked other languages. Failing that it could be set
      to undef, perhaps in this pass.
      
      Reviewed By: rampitec
      
      Differential Revision: https://reviews.llvm.org/D115413
      624f12d3