1. Dec 14, 2019
    • Xin-Xin Wang's avatar
      [clang] Move CLANG_BOOTSTRAP_CMAKE_ARGS above PASSTHROUGH_VARIABLES · 61c8ee6a
      Xin-Xin Wang authored
      I want to pass some CMake cache files in CLANG_BOOTSTRAP_CMAKE_ARGS as
      `-C <cache file>.cmake` arguments. I want to be able to use the values
      of the bootstrap passthrough variables in the cache files, so the cache
      file arguments need to be after passthrough variables. This should be
      safe because the values of passthrough variables are all constants and
      can't refer to values in CLANG_BOOTSTRAP_CMAKE_ARGS.
      
      Differential Revision: https://reviews.llvm.org/D71428
      61c8ee6a
    • Fangrui Song's avatar
      [AArch64] Save FP for leaf functions when disabling frame pointer elimination · a0aa58da
      Fangrui Song authored
      The change allows clang -mno-omit-leaf-frame-pointer to disable frame
      pointer elimination. This behavior matches X86 and Mips, and also GCC
      AArch64.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D71168
      a0aa58da
    • Fangrui Song's avatar
      [Driver] Default to -momit-leaf-frame-pointer for AArch64 · 074323c8
      Fangrui Song authored
      This matches https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
      
      > -momit-leaf-frame-pointer
      > -mno-omit-leaf-frame-pointer
      >
      >   Omit or keep the frame pointer in leaf functions. The former behavior is the default.
      
      -mno-omit-leaf-frame-pointer is currently a no-op because
      TargetOptions::DisableFramePointerElim is only considered for non-leaf
      functions.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D71167
      074323c8
    • Richard Smith's avatar
      c5b890e9
    • Richard Smith's avatar
    • Stephan T. Lavavej's avatar
      [libcxx] [test] Include missing headers. (NFC) · 5688f168
      Stephan T. Lavavej authored
      libcxx/test/std/containers/sequences/array/at.pass.cpp
      Need to include <stdexcept> for std::out_of_range.
      
      libcxx/test/std/localization/locale.categories/category.time/*
      Need to include <ios> for std::ios.
      5688f168
    • Artem Dergachev's avatar
      [analyzer] CStringChecker: Fix a crash on unknown value passed to strlcat. · f450dd63
      Artem Dergachev authored
      Checkers should always account for unknown values.
      
      Also use a slightly more high-level API that naturally avoids the problem.
      f450dd63
    • Sean Fertile's avatar
      [PowerPC] Add Support for indirect calls on AIX. · 93faa237
      Sean Fertile authored
      Extends the desciptor-based indirect call support for 32-bit codegen,
      and enables indirect calls for AIX.
      
      In-depth Description:
      In a function descriptor based ABI, a function pointer points at a
      descriptor structure as opposed to the function's entry point. The
      descriptor takes the form of 3 pointers: 1 for the function's entry
      point, 1 for the TOC anchor of the module containing the function
      definition, and 1 for the environment pointer:
      
      struct FunctionDescriptor {
        void *EntryPoint;
        void *TOCAnchor;
        void *EnvironmentPointer;
      };
      
      An indirect call has several steps of loading the the information from
      the descriptor into the proper registers for setting up the call. Namely
      it has to:
      
      1) Save the caller's TOC pointer into the TOC save slot in the linkage
         area, and then load the callee's TOC pointer into the TOC register
         (GPR 2 on AIX).
      
      2) Load the function descriptor's entry point into the count register.
      
      3) Load the environment pointer into the environment pointer register
         (GPR 11 on AIX).
      
      4) Perform the call by branching on count register.
      
      5) Restore the caller's TOC pointer after returning from the indirect call.
      
      A couple important caveats to the above:
      
      - There is no way to directly load a value from memory into the count register.
        Instead we populate the count register by loading the entry point address into
        a gpr and then moving the gpr to the count register.
      
      - The TOC restore has to come immediately after the branch on count register
        instruction (i.e., the 1st instruction executed after we return from the
        call). This is an implementation limitation. We could, in theory, schedule
        the restore elsewhere as long as no uses of the TOC pointer fall in between
        the call and the restore; however, to keep it simple, we insert a pseudo
        instruction that represents both the indirect branch instruction and the
        load instruction that restores the caller's TOC from the linkage area. As
        they flow through the compiler as a single pseudo instruction, nothing can be
        inserted between them and the caller's TOC is then valid at any use.
      
      Differtential Revision: https://reviews.llvm.org/D70724
      93faa237
    • Julian Lettner's avatar
      [lit] Small cleanups. NFCI · cf252240
      Julian Lettner authored
      Remove unnecessary (argument same as default), cleanup imports, use
      "pythonic" names for variables, and general formatting.
      cf252240
    • Michael Kruse's avatar
      [OpenMP][Docs] Claim loop tiling. · 2a789dd0
      Michael Kruse authored
      2a789dd0
    • Fangrui Song's avatar
    • Roman Tereshin's avatar
      [Legalizer] Making artifact combining order-independent · 8731799f
      Roman Tereshin authored
      Legalization algorithm is complicated by two facts:
      1) While regular instructions should be possible to legalize in
         an isolated, per-instruction, context-free manner, legalization
         artifacts can only be eliminated in pairs, which could be deeply, and
         ultimately arbitrary nested: { [ () ] }, where which paranthesis kind
         depicts an artifact kind, like extend, unmerge, etc. Such structure
         can only be fully eliminated by simple local combines if they are
         attempted in a particular order (inside out), or alternatively by
         repeated scans each eliminating only one innermost pair, resulting in
         O(n^2) complexity.
      2) Some artifacts might in fact be regular instructions that could (and
         sometimes should) be legalized by the target-specific rules. Which
         means failure to eliminate all artifacts on the first iteration is
         not a failure, they need to be tried as instructions, which may
         produce more artifacts, including the ones that are in fact regular
         instructions, resulting in a non-constant number of iterations
         required to finish the process.
      
      I trust the recently introduced termination condition (no new artifacts
      were created during as-a-regular-instruction-retrial of artifacts not
      eliminated on the previous iteration) to be efficient in providing
      termination, but only performing the legalization in full if and only if
      at each step such chains of artifacts are successfully eliminated in
      full as well.
      
      Which is currently not guaranteed, as the artifact combines are applied
      only once and in an arbitrary order that has to do with the order of
      creation or insertion of artifacts into their worklist, which is a no
      particular order.
      
      In this patch I make a small change to the artifact combiner, making it
      to re-insert into the worklist immediate (modulo a look-through copies)
      artifact users of each vreg that changes its definition due to an
      artifact combine.
      
      Here the first scan through the artifacts worklist, while not
      being done in any guaranteed order, only needs to find the innermost
      pair(s) of artifacts that could be immediately combined out. After that
      the process follows def-use chains, making them shorter at each step, thus
      combining everything that can be combined in O(n) time.
      
      Reviewers: volkan, aditya_nandakumar, qcolombet, paquette, aemerson, dsanders
      
      Reviewed By: aditya_nandakumar, paquette
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71448
      8731799f
    • Roman Tereshin's avatar
      [Legalizer] Refactoring out legalizeMachineFunction · 18bf9670
      Roman Tereshin authored
      and introducing new unittests/CodeGen/GlobalISel/LegalizerTest.cpp
      relying on it to unit test the entire legalizer algorithm (including the
      top-level main loop).
      
      See also https://reviews.llvm.org/D71448
      18bf9670
    • Roman Tereshin's avatar
    • Vedant Kumar's avatar
      [ubsan] Enable testing of .m files · ed83942b
      Vedant Kumar authored
      This allows `.m` test files, like the existing Misc/bool.m, to be
      tested.
      ed83942b
    • Jonas Devlieghere's avatar
      [lldb/SWIG] Modulerize lldb.swig so parts of it can be reused. · 3a6da112
      Jonas Devlieghere authored
      This groups the headers and interfaces in separate files that can be
      included by other swig files for different languages.
      3a6da112
    • Fangrui Song's avatar
      [Driver] Use .init_array for all gcc installations and simplify Generic_ELF... · e4fce659
      Fangrui Song authored
      [Driver] Use .init_array for all gcc installations and simplify Generic_ELF -fno-use-init-array rules
      
      D39317 made clang use .init_array when no gcc installations is found.
      This change changes all gcc installations to use .init_array .
      
      GCC 4.7 by default stopped providing .ctors/.dtors compatible crt files,
      and stopped emitting .ctors for __attribute__((constructor)).
      .init_array should always work.
      
      FreeBSD rules are moved to FreeBSD.cpp to make Generic_ELF rules clean.
      
      Reviewed By: rnk
      
      Differential Revision: https://reviews.llvm.org/D71434
      e4fce659
    • Alexey Bataev's avatar
      [OPENMP]Fix skipping of functions body. · 8035bb4a
      Alexey Bataev authored
      When parsing the code with OpenMP and the function's body must be
      skipped, need to skip also OpenMP annotation tokens. Otherwise the
      counters for braces/parens are unbalanced and parsing fails.
      8035bb4a
    • Jonas Devlieghere's avatar
    • Jonas Devlieghere's avatar
      [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON · 4e26cf2c
      Jonas Devlieghere authored
      This matches the naming scheme used by LLVM and all the other optional
      dependencies in LLDB.
      
      Differential revision: https://reviews.llvm.org/D71482
      4e26cf2c
    • Alex Richardson's avatar
      [LSAN] Increase stack space for guard-page.c test · 9cb7a1be
      Alex Richardson authored
      Summary:
      When running the tests on a Ubuntu 18.04 machine this test is crashing for
      me inside the runtime linker. My guess is that it is trying to save more
      registers (possibly large vector ones) and the current stack space is not
      sufficient.
      
      Reviewers: samsonov, kcc, eugenis
      
      Reviewed By: eugenis
      
      Subscribers: eugenis, merge_guards_bot, #sanitizers, llvm-commits
      
      Tags: #sanitizers, #llvm
      
      Differential Revision: https://reviews.llvm.org/D71461
      9cb7a1be
    • Alex Richardson's avatar
      [NFC] Use SelectionDAG::getMemBasePlusOffset() instead of getNode(ISD::ADD) · 11448eeb
      Alex Richardson authored
      Summary:
      To find potential opportunities to use getMemBasePlusOffset() I looked at
      all ISD::ADD uses found with the regex getNode\(ISD::ADD,.+,.+Ptr
      in lib/CodeGen/SelectionDAG. If this patch is accepted I will convert
      the files in the individual backends too.
      
      The motivation for this change is our out-of-tree CHERI backend
      (https://github.com/CTSRD-CHERI/llvm-project). We use a separate register
      type to store pointers (128-bit capabilities, which are effectively
      unforgeable and monotonic fat pointers). These capabilities permit a
      reduced set of operations and therefore use a separate ValueType (iFATPTR).
      to represent pointers implemented as capabilities.
      Therefore, we need to avoid using ISD::ADD for our patterns that operate
      on pointers and need to use a function that chooses ISD::ADD or a new
      ISD::PTRADD opcode depending on the value type.
      
      We originally added a new DAG.getPointerAdd() function, but after this
      patch series we can modify the implementation of getMemBasePlusOffset()
      instead. Avoiding direct uses of ISD::ADD for pointer types will
      significantly reduce the amount of assertion/instruction selection
      failures for us in future upstream merges.
      
      Reviewers: spatel
      
      Reviewed By: spatel
      
      Subscribers: merge_guards_bot, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71207
      11448eeb
    • Alex Richardson's avatar
      [NFC] Implement SelectionDAG::getObjectPtrOffset() using getMemBasePlusOffset() · fc83f53a
      Alex Richardson authored
      Summary:
      This change is preparatory work to use this helper functions in more places.
      In order to make this change, getMemBasePlusOffset() has been extended to
      also take a SDNodeFlags parameter.
      
      The motivation for this change is our out-of-tree CHERI backend
      (https://github.com/CTSRD-CHERI/llvm-project). We use a separate register
      type to store pointers (128-bit capabilities, which are effectively
      unforgeable and monotonic fat pointers). These capabilities permit a
      reduced set of operations and therefore use a separate ValueType (iFATPTR).
      to represent pointers implemented as capabilities.
      Therefore, we need to avoid using ISD::ADD for our patterns that operate
      on pointers and need to use a function that chooses ISD::ADD or a new
      ISD::PTRADD opcode depending on the value type.
      
      We originally added a new DAG.getPointerAdd() function, but after this
      patch series we can modify the implementation of getMemBasePlusOffset()
      instead. Avoiding direct uses of ISD::ADD for pointer types will
      significantly reduce the amount of assertion/instruction selection
      failures for us in future upstream merges.
      
      Reviewers: spatel
      
      Reviewed By: spatel
      
      Subscribers: merge_guards_bot, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71206
      fc83f53a
    • Alex Richardson's avatar
      [NFC] Add a SDValue overload for SelectionDAG::getMemBasePlusOffset() · ea8888d1
      Alex Richardson authored
      Summary:
      This change is preparatory work to use this helper functions in more places.
      Currently the function only allows integer constants offsets, but there
      are cases where we can use an existing SDValue parameter.
      
      The motivation for this change is our out-of-tree CHERI backend
      (https://github.com/CTSRD-CHERI/llvm-project). We use a separate register
      type to store pointers (128-bit capabilities, which are effectively
      unforgeable and monotonic fat pointers). These capabilities permit a
      reduced set of operations and therefore use a separate ValueType (iFATPTR).
      to represent pointers implemented as capabilities.
      Therefore, we need to avoid using ISD::ADD for our patterns that operate
      on pointers and need to use a function that chooses ISD::ADD or a new
      ISD::PTRADD opcode depending on the value type.
      
      We originally added a new DAG.getPointerAdd() function, but after this
      patch series we can modify the implementation of getMemBasePlusOffset()
      instead. Avoiding direct uses of ISD::ADD for pointer types will
      significantly reduce the amount of assertion/instruction selection
      failures for us in future upstream merges.
      
      Reviewers: spatel, craig.topper
      
      Reviewed By: spatel, craig.topper
      
      Subscribers: craig.topper, merge_guards_bot, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71205
      ea8888d1
    • Alex Richardson's avatar
      [NFC] Change SelectionDAG::getMemBasePlusOffset() to use int64_t · d9bb70ac
      Alex Richardson authored
      Summary:
      This change is preparatory work to use this helper functions in more places.
      Currently the function only allows positive offsets, but there are cases
      where we want to subtract an offset from an existing pointer.
      
      The motivation for this change is our out-of-tree CHERI backend
      (https://github.com/CTSRD-CHERI/llvm-project). We use a separate register
      type to store pointers (128-bit capabilities, which are effectively
      unforgeable and monotonic fat pointers). These capabilities permit a
      reduced set of operations and therefore use a separate ValueType (iFATPTR).
      to represent pointers implemented as capabilities.
      Therefore, we need to avoid using ISD::ADD for our patterns that operate
      on pointers and need to use a function that chooses ISD::ADD or a new
      ISD::PTRADD opcode depending on the value type.
      
      We originally added a new DAG.getPointerAdd() function, but after this
      patch series we can modify the implementation of getMemBasePlusOffset()
      instead. Avoiding direct uses of ISD::ADD for pointer types will
      significantly reduce the amount of assertion/instruction selection
      failures for us in future upstream merges.
      
      Reviewers: spatel
      
      Reviewed By: spatel
      
      Subscribers: merge_guards_bot, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71204
      d9bb70ac
    • Alexey Bataev's avatar
      Revert "[libomptarget] Move resource id functions into target specific code, implement for amdgcn" · dd8a7fcd
      Alexey Bataev authored
      This reverts commit dbb3fec8 since it
      breaks the NVPTX tests.
      dd8a7fcd
    • Akira Hatanaka's avatar
      Call objc_retainBlock before passing a block as a variadic argument · a0a67061
      Akira Hatanaka authored
      Copy the block to the heap before passing it to the callee in case the
      block escapes in the callee.
      
      rdar://problem/55683462
      
      Differential Revision: https://reviews.llvm.org/D71431
      a0a67061
    • Eric Christopher's avatar
      5623bd52
    • Eric Fiselier's avatar
    • Med Ismail Bennani's avatar
      LanguageRuntime: Simplify NSException::GetSummary() output · 2c91d5ba
      Med Ismail Bennani authored
      Summary:
      Right now, NSException::GetSummary() has the following output:
      "name: $exception_name - reason: $exception_reason"
      
      It would be better to simplify the output by removing the name and only
      showing the exception's reason. This way, annotations would look nicer in
      the editor, and would be a shorter summary in the Variables Inspector.
      
      Accessing the exception's name can still be done by expanding the
      NSException object in the Variables Inspector.
      
      rdar://54770115
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      
      Subscribers: lldb-commits
      
      Tags: #lldb
      
      Differential Revision: https://reviews.llvm.org/D71311
      
      
      
      Signed-off-by: default avatarMed Ismail Bennani <medismail.bennani@gmail.com>
      2c91d5ba
    • Erich Keane's avatar
      Correct gcc vector splat conversion from float to int-vector · 348f22ea
      Erich Keane authored
      In looking into some other code, I came across this issue where a
      float converted to a gcc integer vector via a splat causes it to miss
      the float-to-integral cast, which causes some REALLY strange codegen
      bugs.
      
      The AST looked like:
      `-ImplicitCastExpr <col:13>
      'gcc_int_2':'__attribute__((__vector_size__(2 * sizeof(int)))) int' <VectorSplat>
              `-ImplicitCastExpr <col:13> 'float' <LValueToRValue>
                        `-DeclRefExpr <col:13> 'float' lvalue ParmVar
                        0x556f16a5dc90 'f' 'float'
      
      Despite the type of the VectorSplat cast as printed, it ended up
      becoming a vector of float, which caused non-matching instructions. For
      example, IntVector + a float constant resulted in:
      
      add <2 x i32> %8, <2 x float> <float 3.000000e+00, float 3.000000e+00>
      
      This patch corrects the conversion so that the float is first converted
      to an integral, THEN splatted.
      348f22ea
    • Sam Elliott's avatar
      [RISCV] Move DebugLoc Copy into CompressInstEmitter · a0f43b00
      Sam Elliott authored
      Summary:
      This copy ensures that debug location information is kept for
      compressed instructions. There are places where both compressInstruction and
      uncompressInstruction are called that were not doing this copy, discarding some
      debug info.
      
      This change merely moves the copy into the generated file, so you cannot forget
      to copy the location over when compressing or uncompressing.
      
      Reviewers: asb, luismarques
      
      Reviewed By: luismarques
      
      Subscribers: sameer.abuasal, aprantl, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D67493
      a0f43b00
    • Francesco Petrogalli's avatar
      Revert "[VectorUtils] Introduce the Vector Function Database (VFDatabase)." · 19f73f0d
      Francesco Petrogalli authored
      This reverts commit 0be81968.
      
      The VFDatabase needs some rework to be able to handle vectorization
      and subsequent scalarization of intrinsics in out-of-tree versions of
      the compiler. For more details, see the discussion in
      https://reviews.llvm.org/D67572.
      19f73f0d
    • Fangrui Song's avatar
      [profile] Fix a crash when -fprofile-remapping-file= triggers an error · 193da743
      Fangrui Song authored
      Reviewed By: wmi
      
      Differential Revision: https://reviews.llvm.org/D71485
      193da743
    • Sanjay Patel's avatar
    • Sanjay Patel's avatar
      [DAGCombiner] fold shift-trunc-shift to shift-mask-trunc (2nd try) · 2f0c7fd2
      Sanjay Patel authored
      The initial attempt (rG89633320) botched the logic by reversing
      the source/dest types. Added x86 tests for additional coverage.
      The vector tests show a potential improvement (fold vector load
      instead of broadcasting), but that's a known/existing problem.
      
      This fold is done in IR by instcombine, and we have a special
      form of it already here in DAGCombiner, but we want the more
      general transform too:
      https://rise4fun.com/Alive/3jZm
      
      Name: general
      Pre: (C1 + zext(C2) < 64)
      %s = lshr i64 %x, C1
      %t = trunc i64 %s to i16
      %r = lshr i16 %t, C2
      =>
      %s2 = lshr i64 %x, C1 + zext(C2)
      %a = and i64 %s2, zext((1 << (16 - C2)) - 1)
      %r = trunc %a to i16
      
      Name: special
      Pre: C1 == 48
      %s = lshr i64 %x, C1
      %t = trunc i64 %s to i16
      %r = lshr i16 %t, C2
      =>
      %s2 = lshr i64 %x, C1 + zext(C2)
      %r = trunc %s2 to i16
      
      ...because D58017 exposes a regression without this fold.
      2f0c7fd2
    • Hiroshi Yamauchi's avatar
      [PGO][PGSO] Enable size optimizations in code gen / target passes for cold code. · ed50e606
      Hiroshi Yamauchi authored
      Summary: Split off of D67120.
      
      Reviewers: davidxl
      
      Subscribers: hiraditya, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D71288
      ed50e606
    • Mitch Phillips's avatar
    • Momchil Velikov's avatar
      [ARM] Fix in ICE when retrieving the number of micro-ops for vlldm/vlstm · 8e8e3181
      Momchil Velikov authored
      The big switch in `ARMBaseInstrInfo::getNumMicroOps` is missing cases for
      `VLLDM` and `VLSTM`, which are currently defined with itineraries having a
      dynamic count of micro-ops.
      
      Assuming an optimistic case in which these instruction do not actually perform
      loads or stores, and with the idea that Armv8-m cores are supposed to use the
      new style scheduling models, this patch just sets the itinerary for those two
      instructions to `NoItinerary`.
      
      Differential Revision: https://reviews.llvm.org/D71266
      8e8e3181
    • Nico Weber's avatar
      b5059421