1. Feb 16, 2021
    • Andrzej Warzynski's avatar
      [flang][driver] Add options for unparsing · 96d229c9
      Andrzej Warzynski authored
      This patch adds the following compiler frontend driver options:
        * -fdebug-unparse (f18 spelling: -funparse)
        * -fdebug-unparse-with-symbols (f18 spelling: -funparse-with-symbols)
      The new driver will only accept the new spelling. `f18` will accept both
      the original and the new spelling.
      
      A new base class for frontend actions is added: `PrescanAndSemaAction`.
      This is added to reduce code duplication that otherwise these new
      options would lead to. Implementation from
        * `ParseSyntaxOnlyAction::ExecutionAction`
      is moved to:
        * `PrescanAndSemaAction::BeginSourceFileAction`
      This implementation is now shared between:
        * PrescanAndSemaAction
        * ParseSyntaxOnlyAction
        * DebugUnparseAction
        * DebugUnparseWithSymbolsAction
      
      All tests that don't require other yet unimplemented options are
      updated. This way `flang-new -fc1` is used instead of `f18` when
      `FLANG_BUILD_NEW_DRIVER` is set to `On`. In order to facilitate this,
      `%flang_fc1` is added in the LIT configuration (lit.cfg.py).
      
      `asFortran` from f18.cpp is duplicated as `getBasicAsFortran` in
      FrontendOptions.cpp. At this stage it's hard to find a good place to
      share this method. I suggest that we revisit this once a switch from
      `f18` to `flang-new` is complete.
      
      Differential Revision: https://reviews.llvm.org/D96483
      96d229c9
    • Sander de Smalen's avatar
      [SCEVExpander] Migrate costAndCollectOperands to use InstructionCost. · 00fe10c6
      Sander de Smalen authored
      This patch changes costAndCollectOperands to use InstructionCost for
      accumulated cost values.
      
      isHighCostExpansion will return true if the cost has exceeded the budget.
      
      Reviewed By: CarolineConcatto, ctetreau
      
      Differential Revision: https://reviews.llvm.org/D92238
      00fe10c6
    • Adrian Kuegel's avatar
      Lower math.expm1 to intrinsics in the GPUToNVVM and GPUToROCDL conversions. · 07cc7718
      Adrian Kuegel authored
      This adds the lowering for expm1 for GPU backends.
      
      Differential Revision: https://reviews.llvm.org/D96756
      07cc7718
    • Andrzej Warzynski's avatar
      [flang][f18] Make -fdebug-dump-{symbols|parse-tree} imply -fsyntax-only · 548549e8
      Andrzej Warzynski authored
      The following _action_ options are always used with `-fsyntax-only`
      (also an _action_ option):
        * -fdebug-dump-symbols
        * -fdebug-dump-parse-tree
      This patch makes the above options imply `-fsyntax-only`.
      
      From the perspective of `f18` this change saves typing and is otherwise
      a non-functional change. But it will simplify things in the new driver,
      `flang-new`, in which only the last action option is taken into account
      and executed. In other words, the following would only run
      `-fsyntax-only`:
      ```
      flang-new -fdebug-dump-symbols -fsyntax-only <input>
      ```
      whereas this would only run `-fdebug-dump-symbols`:
      ```
      flang-new -fsyntax-only -fdebug-dump-symbols <input>
      ```
      
      Differential Revision: https://reviews.llvm.org/D96528
      548549e8
    • LLVM GN Syncbot's avatar
      [gn build] Port 9510b094 · 72af7012
      LLVM GN Syncbot authored
      72af7012
    • Nathan Ridge's avatar
      [clangd] Factor out the heuristic resolver code into its own class · 9510b094
      Nathan Ridge authored
      The patch also does some cleanup on the interface of the entry
      points from TargetFinder into the heuristic resolution code.
      
      Since the heuristic resolver is created in a place where the
      ASTContext is available, it can store the ASTContext and the
      NameFactory hack can be removed.
      
      Differential revision: https://reviews.llvm.org/D92290
      9510b094
    • Florian Hahn's avatar
      [VPlan] Manage scalarized values using VPValues. · 54a14c26
      Florian Hahn authored
      This patch updates codegen to use VPValues to manage the generated
      scalarized instructions.
      
      Reviewed By: gilr
      
      Differential Revision: https://reviews.llvm.org/D92285
      54a14c26
    • Adrian Kuegel's avatar
      Add Expm1 op to the math dialect. · 9f581815
      Adrian Kuegel authored
      Differential Revision: https://reviews.llvm.org/D96704
      9f581815
    • Nicolas Vasilache's avatar
      [mlir] Drop reliance of SliceAnalysis on specific ops. · d01ea0ed
      Nicolas Vasilache authored
      SliceAnalysis originally was developed in the context of affine.for within mlfunc.
      It predates the notion of region.
      This revision updates it to not hardcode specific ops like scf::ForOp.
      When rooted at an op, the behavior of the slice computation changes as it recurses into the regions of the op. This does not support gathering all values transitively depending on a loop induction variable anymore.
      Additional variants rooted at a Value are added to also support the existing behavior.
      
      Differential revision: https://reviews.llvm.org/D96702
      d01ea0ed
    • Sameer Sahasrabuddhe's avatar
      [NewPM] Introduce (GPU)DivergenceAnalysis in the new pass manager · 11bf7da6
      Sameer Sahasrabuddhe authored
      The GPUDivergenceAnalysis is now renamed to just "DivergenceAnalysis"
      since there is no conflict with LegacyDivergenceAnalysis. In the
      legacy PM, this analysis can only be used through the legacy DA
      serving as a wrapper. It is now made available as a pass in the new
      PM, and has no relation with the legacy DA.
      
      The new DA currently cannot handle irreducible control flow; its
      presence can cause the analysis to run indefinitely. The analysis is
      now modified to detect this and report all instructions in the
      function as divergent. This is super conservative, but allows the
      analysis to be used without hanging the compiler.
      
      Reviewed By: aeubanks
      
      Differential Revision: https://reviews.llvm.org/D96615
      11bf7da6
    • Jonas Devlieghere's avatar
      [debugserver] Correctly pass argv[0] to execl · 71811048
      Jonas Devlieghere authored
      The execl function takes both the executable and argv[0].
      71811048
    • Dave Lee's avatar
      [lldb] Remove very old misleading comment (NFC) · 4946f37d
      Dave Lee authored
      4946f37d
    • Dave Lee's avatar
      [lldb] Remove unused ThreadPlan tracer utilities (NFC) · 22f0aa0d
      Dave Lee authored
      Delete unused `EnableTracer()` and `SetTracer()` functions on `Thread`. By deleting
      these, their `ThreadPlan` counterparts also become unused.
      
      Then, by deleting `ThreadPlanStack::EnableTracer`, `EnableSingleStep` becomes unused.
      With no more callers to `EnableSingleStep`, the value `m_single_step` is always true and
      can be removed as well.
      
      Differential Revision: https://reviews.llvm.org/D96666
      22f0aa0d
    • Dave Lee's avatar
      [lldb] Lower GetRealStopInfo into ThreadPlanCallFunction (NFC) · 2a2464eb
      Dave Lee authored
      `GetRealStopInfo` has only one call site, and in that call site a reference to the
      concrete thread plan is available (`ThreadPlanCallUserExpression`), from which
      `GetRealStopInfo` can be called.
      
      Differential Revision: https://reviews.llvm.org/D96687
      2a2464eb
    • Dave Lee's avatar
      [lldb] Minor refinements to ThreadPlan::RestoreThreadState (NFC) · 65d91b40
      Dave Lee authored
      Correct `RestoreThreadState` to a `void` return type. Also, update the signature of its
      callee, `Thread::RestoreThreadStateFromCheckpoint`, by updating it to a `void` return
      type, and making it non-`virtual`.
      
      Differential Revision: https://reviews.llvm.org/D96688
      65d91b40
    • Akira Hatanaka's avatar
      [ObjC][ARC] Do not perform code motion on precise release calls · 32dc79c5
      Akira Hatanaka authored
      This fixes a bug where an object can get deallocated before reaching the
      end of its full formal lifetime.
      
      rdar://72110887
      rdar://74123176
      32dc79c5
    • Kazu Hirata's avatar
      [CodeGen] Use range-based for loops (NFC) · 22f00f61
      Kazu Hirata authored
      22f00f61
    • Kazu Hirata's avatar
      [Support] Use ListSeparator (NFC) · f0d5898f
      Kazu Hirata authored
      f0d5898f
    • Kazu Hirata's avatar
    • Craig Topper's avatar
      [RISCV] Add expicit i32/i64 types to RV32 or RV64 only isel patterns. NFC · 29b894a8
      Craig Topper authored
      This stops tablegen from generating patterns with the opposite type
      in the opposite HwMode. This just adds wasted bytes to the isel table.
      
      This reduces the isel table by about 1800 bytes.
      29b894a8
    • Matt Arsenault's avatar
      GlobalISel: Handle arguments partially passed on the stack · 392e0fcf
      Matt Arsenault authored
      The API is a bit awkward since you need to index into an array in the
      passed struct. I guess an alternative would be to pass all of the
      individual fields.
      392e0fcf
    • Matt Arsenault's avatar
      CodeGen: Move function to get subregister indexes to cover a LaneMask · 1b3d8dde
      Matt Arsenault authored
      Return the best covering index, and additional needed to complete the
      mask. This logically belongs in TargetRegisterInfo, although I ended
      up not needing it for why I originally split this out.
      1b3d8dde
    • Nicolas Vasilache's avatar
    • Arthur O'Dwyer's avatar
      [libc++] Change `std::numeric_limits` to just `numeric_limits` in <chrono>. · 5f58374b
      Arthur O'Dwyer authored
      The namespace is unnecessary, and libc++ style is not to include it on type names.
      (As opposed to function names, where qualification affects ADL; and in certain
      function signatures where `std::` and `_VSTD::` might be mangled differently.
      This is none of those situations.)
      5f58374b
    • Craig Topper's avatar
      [RISCV] Add support for fixed vector floating point setcc. · 7ba2e1c6
      Craig Topper authored
      This is annoying because the condition code legalization belongs
      to LegalizeDAG, but our custom handler runs in Legalize vector ops
      which occurs earlier.
      
      This adds some of the mask binary operations so that we can combine
      multiple compares that we need for expansion.
      
      I've also fixed up RISCVISelDAGToDAG.cpp to handle copies of masks.
      
      This patch contains a subset of the integer setcc patch as well.
      That patch is dependent on the integer binary ops patch. I'll rebase
      based on what order the patches go in.
      
      Reviewed By: frasercrmck
      
      Differential Revision: https://reviews.llvm.org/D96567
      7ba2e1c6
    • Craig Topper's avatar
      [RISCV][LegalizeTypes] Try to expand BITREVERSE before promoting if the... · eb75f250
      Craig Topper authored
      [RISCV][LegalizeTypes] Try to expand BITREVERSE before promoting if the promoted BITREVERSE would expand anyway.
      
      If we're going to end up expanding anyway, we should do it early
      so we don't create extra operations to handle the bytes added by
      promotion.
      
      Simlilar was done for BSWAP previously.
      
      Reviewed By: RKSimon
      
      Differential Revision: https://reviews.llvm.org/D96681
      eb75f250
    • Muhammad Omair Javaid's avatar
      [LLDB] Skip TestMultipleTargets.py on Arm/AArch64 Linux · c2123a82
      Muhammad Omair Javaid authored
      TestMultipleTargets.py fails randomly on Arm/AArch64 Linux buildbot with
      no reasonable clues. I am marking it skipped for avoiding LLDB buildbot
      failures due to this test.
      c2123a82
    • Louis Dionne's avatar
    • Sanjay Patel's avatar
      [ValueTracking] add scan limit for assumes · 378941f6
      Sanjay Patel authored
      In the motivating example from https://llvm.org/PR49171 and
      reduced test here, we would unroll and clone assumes so much
      that compile-time effectively became infinite while analyzing
      all of those assumes.
      378941f6
    • Dimitry Andric's avatar
      Define new/delete in libc++ when using libcxxrt · 32826101
      Dimitry Andric authored
      Always turn on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS, if libcxxrt is used
      as the C++ ABI library, since libcxxrt does not provide the full set
      ofnew and delete operators. In particular, the aligned versions of these
      operators are completely missing. This primarily addresses builds on
      FreeBSD, as this platform uses libcxxrt by default.
      
      Also, attempt to provide a FreeBSD.cmake cache file, with hopefully sane
      settings, partially copied from the Apple.cmake cache file. This needs
      more work, probably some additions to ci build scripts (although I am
      not aware of any 'official' FreeBSD build bots).
      
      Reviewed By: ldionne, #libc
      
      Differential Revision: https://reviews.llvm.org/D96720
      32826101
    • Sam McCall's avatar
      4d700fb0
    • Duncan P. N. Exon Smith's avatar
      TransformUtils: Fix metadata handling in CloneModule (and improve CloneFunctionInto) · 22a52dfd
      Duncan P. N. Exon Smith authored
      This commit fixes how metadata is handled in CloneModule to be sound,
      and improves how it's handled in CloneFunctionInto (although the latter
      is still awkward when called within a module).
      
      Ruiling Song pointed out in PR48841 that CloneModule was changed to
      unsoundly use the RF_ReuseAndMutateDistinctMDs flag (renamed in
      fa35c1f8 for clarity). This flag papered
      over a crash caused by other various changes made to CloneFunctionInto
      over the past few years that made it unsound to use cloning between
      different modules.
      
      (This commit partially addresses PR48841, fixing the repro from
      preprocessed source but not textual IR. MDNodeMapper::mapDistinctNode
      became unsound in df763188 and this
      commit does not address that regression.)
      
      RF_ReuseAndMutateDistinctMDs is designed for the IRMover to use,
      avoiding unnecessary clones of all referenced metadata when linking
      between modules (with IRMover, the source module is discarded after
      linking). It never makes sense to use when you're not discarding the
      source. This commit drops its incorrect use in CloneModule.
      
      Sadly, the right thing to do with metadata when cloning a function is
      complicated, and this patch doesn't totally fix it.
      
      The first problem is that there are two different types of referenceable
      metadata and it's not obvious what to with one of them when remapping.
      
      - `!0 = !{!1}` is metadata's version of a constant. Programatically it's
        called "uniqued" (probably a better term would be "constant") because,
        like `ConstantArray`, it's stored in uniquing tables. Once it's
        constructed, it's illegal to change its arguments.
      - `!0 = distinct !{!1}` is a bit closer to a global variable. It's legal
        to change the operands after construction.
      
      What should be done with distinct metadata when cloning functions within
      the same module?
      
      - Should new, cloned nodes be created?
      - Should all references point to the same, old nodes?
      
      The answer depends on whether that metadata is effectively owned by a
      function.
      
      And that's the second problem. Referenceable metadata's ownership model
      is not clear or explicit. Technically, it's all stored on an
      LLVMContext. However, any metadata that is `distinct`, that transitively
      references a `distinct` node, or that transitively references a
      GlobalValue is specific to a Module and is effectively owned by it. More
      specifically, some metadata is effectively owned by a specific Function
      within a module.
      
      Effectively function-local metadata was introduced somewhere around
      c10d0e5c, which made it illegal for two
      functions to share a DISubprogram attachment.
      
      When cloning a function within a module, you need to clone the
      function-local debug info and suppress cloning of global debug info (the
      status quo suppresses cloning some global debug info but not all). When
      cloning a function to a new/different module, you need to clone all of
      the debug info.
      
      Here's what I think we should do (eventually? soon? not this patch
      though):
      - Distinguish explicitly (somehow) between pure constant metadata owned
        by the LLVMContext, global metadata owned by the Module, and local
        metadata owned by a GlobalValue (such as a function).
      - Update CloneFunctionInto to trigger cloning of all "local" metadata
        (only), perhaps by adding a bit to RemapFlag. Alternatively, split
        out a separate function CloneFunctionMetadataInto to prime the
        metadata map that callers are updated to call ahead of time as
        appropriate.
      
      Here's the somewhat more isolated fix in this patch:
      - Converted the `ModuleLevelChanges` parameter to `CloneFunctionInto` to
        an enum called `CloneFunctionChangeType` that is one of
        LocalChangesOnly, GlobalChanges, DifferentModule, and ClonedModule.
      - The code maintaining the "functions uniquely own subprograms"
        invariant is now only active in the first two cases, where a function
        is being cloned within a single module. That's necessary because this
        code inhibits cloning of (some) "global" metadata that's effectively
        owned by the module.
      - The code maintaining the "all compile units must be explicitly
        referenced by !llvm.dbg.cu" invariant is now only active in the
        DifferentModule case, where a function is being cloned into a new
        module in isolation.
      - CoroSplit.cpp's call to CloneFunctionInto in CoroCloner::create
        uses LocalChangeOnly, since fa635d73
        only set `ModuleLevelChanges` to trigger cloning of local metadata.
      - CloneModule drops its unsound use of RF_ReuseAndMutateDistinctMDs
        and special handling of !llvm.dbg.cu.
      - Fixed some outdated header docs and left a couple of FIXMEs.
      
      Differential Revision: https://reviews.llvm.org/D96531
      22a52dfd
    • Benjamin Kramer's avatar
      [lto] Enable new PM when the PM config is non-empty · 715dc556
      Benjamin Kramer authored
      This restores the behavior before 964f8103, which broke 2 tests:
        LLVM :: tools/llvm-lto2/X86/pipeline.ll
        lld :: ELF/lto/ltopasses-custom.ll
      715dc556
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Add two TSFlags: IsAtomicNoRtn and IsAtomicRtn · 5cf9292c
      Stanislav Mekhanoshin authored
      We are using AtomicNoRet map in multiple places to determine
      if an instruction atomic, rtn or nortn atomic. This method
      does not work always since we have some instructions which
      only has rtn or nortn version.
      
      One such instruction is ds_wrxchg_rtn_b32 which does not have
      nortn version. This has caused changes in memory legalizer
      tests.
      
      Differential Revision: https://reviews.llvm.org/D96639
      5cf9292c
    • Fangrui Song's avatar
      [llvm-objcopy] Delete --build-id-link-{dir,input,output} · c465429f
      Fangrui Song authored
      The few options are niche. They solved a problem which was traditionally solved
      with more shell commands (`llvm-readelf -n` fetches the Build ID. Then
      `ln` is used to hard link the file to a directory derived from the Build ID.)
      
      Due to limitation, they are no longer used by Fuchsia and they don't appear to
      be used elsewhere (checked with Google Search and Debian Code Search). So delete
      them without a transition period.
      
      Announcement: https://lists.llvm.org/pipermail/llvm-dev/2021-February/148446.html
      
      Differential Revision: https://reviews.llvm.org/D96310
      c465429f
    • Johannes Doerfert's avatar
      [OpenMP] Delay more diagnostics of potentially non-emitted code · 1dd66e61
      Johannes Doerfert authored
      Even code in target and declare target regions might not be emitted.
      With this patch we delay more diagnostics and use laziness and linkage
      to determine if a function is emitted (for the device). Note that we
      still eagerly emit diagnostics for target regions, unfortunately, see
      the TODO for the reason.
      
      This hopefully fixes PR48933.
      
      Reviewed By: JonChesterfield
      
      Differential Revision: https://reviews.llvm.org/D95928
      1dd66e61
    • Johannes Doerfert's avatar
      [OpenMP] Attribute target diagnostics properly · f9286b43
      Johannes Doerfert authored
      Type errors in function declarations were not (always) diagnosed prior
      to this patch. Furthermore, certain remarks did not get associated
      properly which caused them to be emitted multiple times.
      
      Reviewed By: JonChesterfield
      
      Differential Revision: https://reviews.llvm.org/D95912
      f9286b43
    • Johannes Doerfert's avatar
      [OpenMP][NFC] Pre-commit test changes regarding PR48933 · 3b2f19d0
      Johannes Doerfert authored
      This will highlight the effective changes in subsequent commits.
      
      Reviewed By: ABataev
      
      Differential Revision: https://reviews.llvm.org/D95903
      3b2f19d0
    • Adrian Prantl's avatar
      Support emitting complex expressions that include entry values · 09b832e7
      Adrian Prantl authored
      This patch enables AsmPrinter support for complex expression with
      entry values. It shouldn't AsmPrinter's call whether these are safe or
      not but the pass who introduces the DW_OP_LLVM_entry_value. This patch
      on its own has no effect on clang.
      
      Differential Revision: https://reviews.llvm.org/D96559
      09b832e7
    • Fangrui Song's avatar