1. Aug 30, 2019
  2. Aug 29, 2019
    • Jinsong Ji's avatar
      [PowerPC][NFC] Update fp-int-conversions-direct-moves.ll using script · 8b0317ad
      Jinsong Ji authored
      Also add -ppc-asm-full-reg-names,-ppc-vsr-nums-as-vr.
      
      llvm-svn: 370375
      8b0317ad
    • Pavel Labath's avatar
      Fix GetDIEForDeclContext so it only returns entries matching the provided context · f07b4aff
      Pavel Labath authored
      Currently, we return all the entries such that their decl_ctx pointer >= decl_ctx provided.
      Instead, we should return only the ones that decl_ctx pointer == decl_ctx provided.
      
      Differential Revision: https://reviews.llvm.org/D66357
      Patch by Guilherme Andrade <guiandrade@google.com>.
      
      llvm-svn: 370374
      f07b4aff
    • Pavel Labath's avatar
      Remove DWARFExpression::LocationListSize · ef82098a
      Pavel Labath authored
      Summary:
      The only reason for this function's existance is so that we could pass
      the correct size into the DWARFExpression constructor. However, there is
      no harm in passing the entire data extractor into the DWARFExpression,
      since the same code is performing the size determination as well as the
      subsequent parse. So, if we get malformed input or there's a bug in the
      parser, we'd compute the wrong size anyway.
      
      Additionally, reducing the number of entry points into the location list
      parsing machinery makes it easier to switch the llvm debug_loc(lists)
      parsers.
      
      While inside, I added a couple of tests for invalid location list
      handling.
      
      Reviewers: JDevlieghere, clayborg
      
      Subscribers: aprantl, javed.absar, kristof.beyls, lldb-commits
      
      Differential Revision: https://reviews.llvm.org/D66789
      
      llvm-svn: 370373
      ef82098a
    • Shaurya Gupta's avatar
    • Haojian Wu's avatar
      [clangd] Update out-of-date links in readme, NFC. · 1a28e118
      Haojian Wu authored
      llvm-svn: 370371
      1a28e118
    • Roman Lebedev's avatar
      [NFC][SimplifyCFG] 'Safely extract low bits' pattern will also benefit from... · 05ef4951
      Roman Lebedev authored
      [NFC][SimplifyCFG] 'Safely extract low bits' pattern will also benefit from -phi-node-folding-threshold=3
      
      This is the naive implementation of x86 BZHI/BEXTR instruction:
      it takes input and bit count, and extracts low nbits up to bit width.
      I.e. unlike shift it does not have any UB when nbits >= bitwidth.
      Which means we don't need a while PHI here, simple select will do.
      And if it's a select, it should then be trivial to fix codegen
      to select it to BEXTR/BZHI.
      
      See https://bugs.llvm.org/show_bug.cgi?id=34704
      
      llvm-svn: 370369
      05ef4951
    • Michael Kruse's avatar
      [ScopBuilder] Remove superfluous while loop in buildDomains. NFC. · 6220ce60
      Michael Kruse authored
      The while loop iterating parent loop in ScopBuilder::buildDomains is
      unnecessary because either L or LD are later unused, this is a simple
      patch removing it.
      
      Patch by bin.narwal <bin.narwal@gmail.com>
      
      Differential Revision: https://reviews.llvm.org/D66698
      
      llvm-svn: 370368
      6220ce60
    • Kadir Cetinkaya's avatar
      [clangd][NFC] Update background-index command line description · 1c4cd496
      Kadir Cetinkaya authored
      Summary:
      We didn't change this in D64019 just in case we revert it back.
      Deleting it now.
      
      Reviewers: hokein, sammccall
      
      Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D66943
      
      llvm-svn: 370367
      1c4cd496
    • Simon Pilgrim's avatar
      [DAGCombine] Fix shadow variable warnings. NFCI. · ea677418
      Simon Pilgrim authored
      llvm-svn: 370365
      ea677418
    • Pavel Labath's avatar
      DWARFDebugLoc: Make parsing and error reporting more robust · bd546e59
      Pavel Labath authored
      Summary:
      While examining this class for possible use in lldb, I noticed two
      things:
      - it spits out parsing errors directly to stderr
      - the loclists parser can incorrectly return valid location lists when
        parsing malformed (truncated) data
      
      I improve the stderr situation by making the parseOneLocationList
      functions return Expected<T>s. The errors are still dumped to stderr by
      their callers, so this is only a partial fix, but it is enough for my
      use case, as I intend to parse the locations lists one by one.
      
      I fix the behavior in the truncated scenario by using the newly
      introduced DataExtractor Cursor API.
      
      I also add tests for handling the error cases, as they currently have no
      coverage.
      
      Reviewers: dblaikie, JDevlieghere, probinson
      
      Subscribers: lldb-commits, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D63591
      
      llvm-svn: 370363
      bd546e59
    • Dmitri Gribenko's avatar
      Removed a function declaration that doesn't have a definition · e1f73e92
      Dmitri Gribenko authored
      llvm-svn: 370361
      e1f73e92
    • Luis Marques's avatar
      [RISCV] Fix callee-saved-gprs.ll test ABIs · cf3b3939
      Luis Marques authored
      llvm-svn: 370359
      cf3b3939
    • Joerg Sonnenberger's avatar
      Allow replaceAndRecursivelySimplify to list unsimplified visitees. · 799c9669
      Joerg Sonnenberger authored
      This is part of D65280 and split it to avoid ABI changes on the 9.0
      release branch.
      
      llvm-svn: 370355
      799c9669
    • Simon Atanasyan's avatar
      [mips] Inline emitStoreWithSymOffset and emitLoadWithSymOffset methods. NFC · b23857c1
      Simon Atanasyan authored
      Both methods `MipsTargetStreamer::emitStoreWithSymOffset` and
      `MipsTargetStreamer::emitLoadWithSymOffset` are almost the same and
      differ argument names only. These methods are used in the single place
      so it's better to inline their code and remove original methods.
      
      llvm-svn: 370354
      b23857c1
    • Simon Atanasyan's avatar
      [mips] Fix expanding `lw/sw $reg1, symbol($reg2)` instruction · 3464b91e
      Simon Atanasyan authored
      When a "base" in the `lw/sw $reg1, symbol($reg2)` instruction is
      a register and generated code is position independent, backend
      does not add the "base" value to the symbol address.
      ```
      lw     $reg1, %got(symbol)($gp)
      lw/sw  $reg1, 0($reg1)
      ```
      
      This patch fixes the bug and adds the missed `addu` instruction by
      passing `BaseReg` into the `loadAndAddSymbolAddress` routine and handles
      the case when the `BaseReg` is the zero register to escape redundant
      `move reg, reg` instruction:
      ```
      lw     $reg1, %got(symbol)($gp)
      addu   $reg1, $reg1, $reg2
      lw/sw  $reg1, 0($reg1)
      ```
      
      Differential Revision: https://reviews.llvm.org/D66894
      
      llvm-svn: 370353
      3464b91e
    • Roman Lebedev's avatar
      [InstSimplify] Drop leftover "division-by-zero guard" around... · c5847868
      Roman Lebedev authored
      [InstSimplify] Drop leftover "division-by-zero guard" around `@llvm.umul.with.overflow` inverted overflow bit
      
      Summary:
      Now that with D65143/D65144 we've produce `@llvm.umul.with.overflow`,
      and with D65147 we've flattened the CFG, we now can see that
      the guard may have been there to prevent division by zero is redundant.
      We can simply drop it:
      ```
      ----------------------------------------
      Name: no overflow or zero
        %iszero = icmp eq i4 %y, 0
        %umul = smul_overflow i4 %x, %y
        %umul.ov = extractvalue {i4, i1} %umul, 1
        %umul.ov.not = xor %umul.ov, -1
        %retval.0 = or i1 %iszero, %umul.ov.not
        ret i1 %retval.0
      =>
        %iszero = icmp eq i4 %y, 0
        %umul = smul_overflow i4 %x, %y
        %umul.ov = extractvalue {i4, i1} %umul, 1
        %umul.ov.not = xor %umul.ov, -1
        %retval.0 = or i1 %iszero, %umul.ov.not
        ret i1 %umul.ov.not
      
      Done: 1
      Optimization is correct!
      ```
      Note that this is inverted from what we have in a previous patch,
      here we are looking for the inverted overflow bit.
      And that inversion is kinda problematic - given this particular
      pattern we neither hoist that `not` closer to `ret` (then the pattern
      would have been identical to the one without inversion,
      and would have been handled by the previous patch), neither
      do the opposite transform. But regardless, we should handle this too.
      I've filled [[ https://bugs.llvm.org/show_bug.cgi?id=42720 | PR42720 ]].
      
      Reviewers: nikic, spatel, xbolva00, RKSimon
      
      Reviewed By: spatel
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65151
      
      llvm-svn: 370351
      c5847868
    • Roman Lebedev's avatar
      [InstSimplify] Drop leftover "division-by-zero guard" around... · aaf6ab44
      Roman Lebedev authored
      [InstSimplify] Drop leftover "division-by-zero guard" around `@llvm.umul.with.overflow` overflow bit
      
      Summary:
      Now that with D65143/D65144 we've produce `@llvm.umul.with.overflow`,
      and with D65147 we've flattened the CFG, we now can see that
      the guard may have been there to prevent division by zero is redundant.
      We can simply drop it:
      ```
      ----------------------------------------
      Name: no overflow and not zero
        %iszero = icmp ne i4 %y, 0
        %umul = umul_overflow i4 %x, %y
        %umul.ov = extractvalue {i4, i1} %umul, 1
        %retval.0 = and i1 %iszero, %umul.ov
        ret i1 %retval.0
      =>
        %iszero = icmp ne i4 %y, 0
        %umul = umul_overflow i4 %x, %y
        %umul.ov = extractvalue {i4, i1} %umul, 1
        %retval.0 = and i1 %iszero, %umul.ov
        ret %umul.ov
      
      Done: 1
      Optimization is correct!
      ```
      
      Reviewers: nikic, spatel, xbolva00
      
      Reviewed By: spatel
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65150
      
      llvm-svn: 370350
      aaf6ab44
    • Roman Lebedev's avatar
      [SimplifyCFG] FoldTwoEntryPHINode(): don't bailout on i1 PHI's if we can hoist... · 9f35d2b5
      Roman Lebedev authored
      [SimplifyCFG] FoldTwoEntryPHINode(): don't bailout on i1 PHI's if we can hoist a 'not' from incoming values
      
      Summary:
      As it can be seen in the tests in D65143/D65144, even though we have formed an '@llvm.umul.with.overflow'
      and got rid of potential for division-by-zero, the control flow remains, we still have that branch.
      
      We have this condition:
      ```
        // Don't fold i1 branches on PHIs which contain binary operators
        // These can often be turned into switches and other things.
        if (PN->getType()->isIntegerTy(1) &&
            (isa<BinaryOperator>(PN->getIncomingValue(0)) ||
             isa<BinaryOperator>(PN->getIncomingValue(1)) ||
             isa<BinaryOperator>(IfCond)))
          return false;
      ```
      which was added back in rL121764 to help with `select` formation i think?
      
      That check prevents us to flatten the CFG here, even though we know
      we no longer need that guard and will be able to drop everything
      but the '@llvm.umul.with.overflow' + `not`.
      
      As it can be seen from tests, we end here because the `not` is being
      sinked into the PHI's incoming values by InstCombine,
      so we can't workaround this by hoisting it to after PHI.
      
      Thus i suggest that we relax that check to not bailout if we'd get to hoist the `not`.
      
      Reviewers: craig.topper, spatel, fhahn, nikic
      
      Reviewed By: spatel
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65147
      
      llvm-svn: 370349
      9f35d2b5
    • Roman Lebedev's avatar
      [InstCombine] Fold '((%x * %y) u/ %x) != %y' to '@llvm.umul.with.overflow' +... · 473a063a
      Roman Lebedev authored
      [InstCombine] Fold '((%x * %y) u/ %x) != %y' to '@llvm.umul.with.overflow' + overflow bit extraction
      
      Summary:
      `((%x * %y) u/ %x) != %y` is one of (3?) common ways to check that
      some unsigned multiplication (will not) overflow.
      Currently, we don't catch it. We could:
      ```
      $ /repositories/alive2/build-Clang-unknown/alive -root-only ~/llvm-patch1.ll
      Processing /home/lebedevri/llvm-patch1.ll..
      
      ----------------------------------------
      Name: no overflow
        %o0 = mul i4 %y, %x
        %o1 = udiv i4 %o0, %x
        %r = icmp ne i4 %o1, %y
        ret i1 %r
      =>
        %n0 = umul_overflow i4 %x, %y
        %o0 = extractvalue {i4, i1} %n0, 0
        %o1 = udiv %o0, %x
        %r = extractvalue {i4, i1} %n0, 1
        ret %r
      
      Done: 1
      Optimization is correct!
      
      ----------------------------------------
      Name: no overflow
        %o0 = mul i4 %y, %x
        %o1 = udiv i4 %o0, %x
        %r = icmp eq i4 %o1, %y
        ret i1 %r
      =>
        %n0 = umul_overflow i4 %x, %y
        %o0 = extractvalue {i4, i1} %n0, 0
        %o1 = udiv %o0, %x
        %n1 = extractvalue {i4, i1} %n0, 1
        %r = xor %n1, -1
        ret i1 %r
      
      Done: 1
      Optimization is correct!
      
      ```
      
      Reviewers: nikic, spatel, efriedma, xbolva00, RKSimon
      
      Reviewed By: nikic
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65144
      
      llvm-svn: 370348
      473a063a
    • Roman Lebedev's avatar
      [InstCombine] Fold '(-1 u/ %x) u< %y' to '@llvm.umul.with.overflow' + overflow bit extraction · fb38b7aa
      Roman Lebedev authored
      Summary:
      `(-1 u/ %x) u< %y` is one of (3?) common ways to check that
      some unsigned multiplication (will not) overflow.
      Currently, we don't catch it. We could:
      ```
      ----------------------------------------
      Name: no overflow
        %o0 = udiv i4 -1, %x
        %r = icmp ult i4 %o0, %y
      =>
        %o0 = udiv i4 -1, %x
        %n0 = umul_overflow i4 %x, %y
        %r = extractvalue {i4, i1} %n0, 1
      
      Done: 1
      Optimization is correct!
      
      ----------------------------------------
      Name: no overflow, swapped
        %o0 = udiv i4 -1, %x
        %r = icmp ugt i4 %y, %o0
      =>
        %o0 = udiv i4 -1, %x
        %n0 = umul_overflow i4 %x, %y
        %r = extractvalue {i4, i1} %n0, 1
      
      Done: 1
      Optimization is correct!
      
      ----------------------------------------
      Name: overflow
        %o0 = udiv i4 -1, %x
        %r = icmp uge i4 %o0, %y
      =>
        %o0 = udiv i4 -1, %x
        %n0 = umul_overflow i4 %x, %y
        %n1 = extractvalue {i4, i1} %n0, 1
        %r = xor %n1, -1
      
      Done: 1
      Optimization is correct!
      
      ----------------------------------------
      Name: overflow
        %o0 = udiv i4 -1, %x
        %r = icmp ule i4 %y, %o0
      =>
        %o0 = udiv i4 -1, %x
        %n0 = umul_overflow i4 %x, %y
        %n1 = extractvalue {i4, i1} %n0, 1
        %r = xor %n1, -1
      
      Done: 1
      Optimization is correct!
      ```
      
      As it can be observed from tests, while simply forming the `@llvm.umul.with.overflow`
      is easy, if we were looking for the inverted answer, then more work needs to be done
      to cleanup the now-pointless control-flow that was guarding against division-by-zero.
      This is being addressed in follow-up patches.
      
      Reviewers: nikic, spatel, efriedma, xbolva00, RKSimon
      
      Reviewed By: nikic, xbolva00
      
      Subscribers: hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D65143
      
      llvm-svn: 370347
      fb38b7aa
    • Simon Pilgrim's avatar
      Fix variable ‘IsInitCapturePack’ set but not used warning. NFCI. · 51a5f202
      Simon Pilgrim authored
      llvm-svn: 370345
      51a5f202
    • Simon Pilgrim's avatar
      Fix MSVC "not all control paths return a value" warning. NFCI. · 46b346ea
      Simon Pilgrim authored
      llvm-svn: 370343
      46b346ea
    • Dmitri Gribenko's avatar
      Removed `AnyFunctionDecl`, it is unused. · 8537c1ec
      Dmitri Gribenko authored
      llvm-svn: 370341
      8537c1ec
    • Dmitri Gribenko's avatar
      Removed two function declarations that don't have definitions · 1d694f3e
      Dmitri Gribenko authored
      llvm-svn: 370340
      1d694f3e
    • Roman Lebedev's avatar
      [CostModel] Model all `extractvalue`s as free. · cc95a45f
      Roman Lebedev authored
      Summary:
      As disscussed in https://reviews.llvm.org/D65148#1606412,
      `extractvalue` don't actually generate any code,
      so we should treat them as free.
      
      Reviewers: craig.topper, RKSimon, jnspaulsson, greened, asb, t.p.northover, jmolloy, dmgreen
      
      Reviewed By: jmolloy
      
      Subscribers: javed.absar, hiraditya, llvm-commits
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D66098
      
      llvm-svn: 370339
      cc95a45f
    • Dmitri Gribenko's avatar
      [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored... · 349ef2f2
      Dmitri Gribenko authored
      [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored clients to use it instead of inventing their own solution
      
      Subscribers: jkorous, arphaman, kadircet, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D66879
      
      llvm-svn: 370338
      349ef2f2
    • Dmitri Gribenko's avatar
      [Index] Stopped wrapping FrontendActions in libIndex and its users · 8d32053f
      Dmitri Gribenko authored
      Exposed a new function, createIndexingASTConsumer, that creates an
      ASTConsumer. ASTConsumers compose well.
      
      Removed wrapping functionality from createIndexingAction.
      
      llvm-svn: 370337
      8d32053f
    • Dmitri Gribenko's avatar
      [Index] Moved the IndexDataConsumer::finish call into the IndexASTConsumer from IndexAction · 9cc92c15
      Dmitri Gribenko authored
      Doing so removes the last reason to expose a FrontendAction from
      libIndex.
      
      llvm-svn: 370336
      9cc92c15
    • Alexander Potapenko's avatar
      [CodeGen]: don't treat structures returned in registers as memory inputs · 1b5e38a6
      Alexander Potapenko authored
      Summary:
      The "=r" output constraint for a structure variable passed to inline asm
      shouldn't be converted to "=*r", as this changes the asm directive
      semantics and prevents DSE optimizations.
      Instead, preserve the constraints and return such structures as integers
      of corresponding size, which are converted back to structures when
      storing the result.
      
      Fixes PR42672.
      
      Subscribers: cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D65234
      
      llvm-svn: 370335
      1b5e38a6
    • Jeremy Morse's avatar
      [DebugInfo] LiveDebugValues: correctly discriminate kinds of variable locations · ca0e4b36
      Jeremy Morse authored
      The missing line added by this patch ensures that only spilt variable
      locations are candidates for being restored from the stack. Otherwise,
      register or constant-value information can be interpreted as a spill
      location, through a union.
      
      The added regression test replicates a scenario where this occurs: the
      stack load from [rsp] causes the register-location DBG_VALUE to be
      "restored" to rsi, when it should be left alone. See PR43058 for details.
      
      Un x-fail a test that was suffering from this from a previous patch.
      
      Differential Revision: https://reviews.llvm.org/D66895
      
      llvm-svn: 370334
      ca0e4b36
    • Simon Pilgrim's avatar
      Fix signed/unsigned comparison warning. NFCI. · 6c2fc64e
      Simon Pilgrim authored
      llvm-svn: 370333
      6c2fc64e
    • Simon Pilgrim's avatar
      Fix shadow variable warning. NFCI. · 27f43e6b
      Simon Pilgrim authored
      llvm-svn: 370332
      27f43e6b
    • George Rimar's avatar
      [yaml2obj] - Allow placing local symbols after globals. · de0bc448
      George Rimar authored
      This allows us to produce broken binaries with local
      symbols placed after global in '.dynsym'/'.symtab'
      
      Also, simplifies the code.
      
      Differential revision: https://reviews.llvm.org/D66799
      
      llvm-svn: 370331
      de0bc448
    • George Rimar's avatar
      [llvm-readobj/llvm-readelf] - Report a proper warning when dumping a broken dynamic relocation. · 72e95846
      George Rimar authored
      When we have a dynamic relocation with a broken symbol's st_name,
      tools report a useless error: "Invalid data was encountered while parsing the file".
      
      After this change we report a warning + "<corrupt>" as a symbol name.
      
      Differential revision: https://reviews.llvm.org/D66734
      
      llvm-svn: 370330
      72e95846
    • David Green's avatar
      [ARM] MVE Masked loads and stores · 942c2e37
      David Green authored
      Masked loads and store fit naturally with MVE, the instructions being easily
      predicated. This adds lowering for the simple cases of masked loads and stores.
      It does not yet deal with widening/narrowing or pre/post inc.
      
      The llvm masked load intrinsic will accept a "passthru" value, dictating the
      values used for the zero masked lanes. In MVE the instructions write 0 to the
      zero predicated lanes, so we need to match a passthru that isn't 0 (or undef)
      with a select instruction to pull in the correct data after the load.
      
      We also need to do something with unaligned loads/stores. Currently this uses a
      similar method used in big endian, using an VLDRB.8 (and potentially a VREV in
      BE). This does mean that the predicate mask is converted from, for example, a
      v4i1 to a v16i1. The VLDR instructions are defined as using the first bit of
      the relevant mask lane, so this could potentially load different results if the
      predicate is little odd. As the input is a v4i1 however, I believe this is OK
      and all the bits required should be set in the predicate, making the VLDRB.8
      load the same data.
      
      Differential Revision: https://reviews.llvm.org/D66534
      
      llvm-svn: 370329
      942c2e37
    • Jeremy Morse's avatar
      [DebugInfo] LiveDebugValues should always revisit backedges if it skips them · 313d2ce9
      Jeremy Morse authored
      The "join" method in LiveDebugValues does not attempt to join unseen
      predecessor blocks if their out-locations aren't yet initialized, instead
      the block should be re-visited later to see if any locations have changed
      validity. However, because the set of blocks were all being "process"'d
      once before "join" saw them, that logic in "join" was actually ignoring
      legitimate out-locations on the first pass through. This meant that some
      invalidated locations were not removed from the head of loops, allowing
      illegal locations to persist.
      
      Fix this by removing the run of "process" before the main join/process loop
      in ExtendRanges. Now the unseen predecessors that "join" skips truly are
      uninitialized, and we come back to the block at a later time to re-run
      "join", see the @baz function added.
      
      This also fixes another fault where stack/register transfers in the entry
      block (or any other before-any-loop-block) had their tranfers initially
      ignored, and were then never revisited. The MIR test added tests for this
      behaviour.
      
      XFail a test that exposes another bug; a fix for this is coming in D66895.
      
      Differential Revision: https://reviews.llvm.org/D66663
      
      llvm-svn: 370328
      313d2ce9