1. Jun 26, 2018
    • Simon Pilgrim's avatar
    • Andrea Di Biagio's avatar
    • Florian Hahn's avatar
      [IPSCCP] Change dead blocks to unreachable after visiting all executable blocks. · 4a69b0bb
      Florian Hahn authored
      changeToUnreachable may remove PHI nodes from executable blocks we found values
      for and we would fail to replace them. By changing dead blocks to unreachable after
      we replaced constants in all executable blocks, we ensure such PHI nodes are replaced
      by their known value before.
      
      Fixes PR37780.
      
      Reviewers: efriedma, davide
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D48421
      
      llvm-svn: 335588
      4a69b0bb
    • Simon Pilgrim's avatar
      Fix MSVC "signed/unsigned mismatch" warning. NFCI. · dcf5bd27
      Simon Pilgrim authored
      llvm-svn: 335587
      dcf5bd27
    • Bernard Ogden's avatar
      [AArch64] Tighten up directives tests · 56c6e701
      Bernard Ogden authored
      Move expected-fail cases from directive-cpu.s to
      directive-cpu-err.s. This allows us to remove the 'not' from the
      llvm-mc invocation in directive-cpu.s so that this test will fail
      in unexpected error cases. It also means that we are not relying
      on all stderr coming before any stdout, which seems fragile.
      
      Also make use of CHECK-NEXT to ensure that multiline error messages
      really are occuring together.
      
      And add a test to verify that .cpu with an arch version as extension
      is rejected.
      
      Differential Revision: https://reviews.llvm.org/D47873
      
      llvm-svn: 335586
      56c6e701
    • Bernard Ogden's avatar
      [AArch64] Clean up LSE directive tests · 15aa0db0
      Bernard Ogden authored
      These were specifying an architecture version with .cpu directive,
      which is invalid. As the error for this case outputs the problem
      instruction we were still matching the expectations of FileCheck.
      
      This patch fixes up the LSE tests to do what they seem to intend. A
      follow-up patch will tighten up the directive tests.
      
      Differential Revision: https://reviews.llvm.org/D47872
      
      llvm-svn: 335585
      15aa0db0
    • Simon Pilgrim's avatar
      Fix MSVC "not all control paths return a value" warnings. NFCI. · 9b3b0fe7
      Simon Pilgrim authored
      llvm-svn: 335584
      9b3b0fe7
    • George Rimar's avatar
      [ELF] - Change the way of sorting local symbols. · 8f53b6d7
      George Rimar authored
      rLLD329787 added the stable sorting to SymbolTableBaseSection::postThunkContents.
      
      I profiled the Mozilla (response-O0.txt) from lld-speed-test package and found
      std::stable_sort is showing up in profile results and consuming the 3.1% of the total
      CPU time in the RelWithDebug build. Total time of postThunkContents is 3.54%, 238ms.
      
      This change reduces postTimeContents time to 50ms, making it to take 0.73% of Total CPU time.
      
      So, instead of sorting the local part I suggest to just rebuild it.
      That is what this patch does.
      
      Differential revision: https://reviews.llvm.org/D45519
      
      llvm-svn: 335583
      8f53b6d7
    • Clement Courbet's avatar
      [llvm-exegesis] Get the BenchmarkRunner from the ExegesisTarget. · 4860b984
      Clement Courbet authored
      Summary:
      This allows targets to override code generation for some instructions.
      As an example of override, this also moves ad-hoc instruction filtering
      for X86 into the X86 ExegesisTarget.
      
      Reviewers: gchatelet
      
      Subscribers: mgorny, tschuett, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48587
      
      llvm-svn: 335582
      4860b984
    • Andrei Elovikov's avatar
      [NFC] Prefer (void) to LLVM_ATTRIBUTE_UNUSED for unused var in GlobalISElemitter.cpp. · 36cbbff4
      Andrei Elovikov authored
      Reviewers: dsanders, craig.topper
      
      Reviewed By: dsanders
      
      Subscribers: rovka, kristof.beyls, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48534
      
      llvm-svn: 335581
      36cbbff4
    • Bjorn Pettersson's avatar
      Improve ConvertDebugDeclareToDebugValue · 550517bc
      Bjorn Pettersson authored
      Summary:
      This is a follow-up to r334830 and r335031.
      
      In the valueCoversEntireFragment check we now also handle
      the situation when there is a variable length array (VLA)
      involved, and the length of the array has been reduced to
      a constant.
      
      The ConvertDebugDeclareToDebugValue functions that are related
      to PHI nodes and load instructions now avoid inserting dbg.value
      intrinsics when the value does not, for certain, cover the
      variable/fragment that should be described.
      In r334830 we assumed that the value always covered the entire
      var/fragment and we had assertions in the code to show that
      assumption. However, those asserts failed when compiling code
      with VLAs, so we removed the asserts in r335031. Now when we
      know that the valueCoversEntireFragment check can fail also for
      PHI/Load instructions we avoid to insert the faulty dbg.value
      intrinsic in such situations. Compared to the Store instruction
      scenario we simply drop the dbg.value here (as the variable does
      not change its value due to PHI/Load, so an earlier dbg.value
      describing the variable should still be valid).
      
      Reviewers: aprantl, vsk, efriedma
      
      Reviewed By: aprantl
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48547
      
      llvm-svn: 335580
      550517bc
    • Gil Rapaport's avatar
      [InstCombine] (A + 1) + (B ^ -1) --> A - B · da2e2caa
      Gil Rapaport authored
      Turn canonicalized subtraction back into (-1 - B) and combine it with (A + 1) into (A - B).
      This is similar to the folding already done for (B ^ -1) + Const into (-1 + Const) - B.
      
      Differential Revision: https://reviews.llvm.org/D48535
      
      llvm-svn: 335579
      da2e2caa
    • Craig Topper's avatar
      [X86] Don't use getScalarShiftAmountTy to get the immediate type for target... · 08dae168
      Craig Topper authored
      [X86] Don't use getScalarShiftAmountTy to get the immediate type for target specific VSHLDQ/VSRLDQ nodes.
      
      These opcodes have a fixed type of i8 for their immediate and shouldn't have anything to do with the scalar shift amount used by target independent shift nodes.
      
      llvm-svn: 335578
      08dae168
    • Vedant Kumar's avatar
    • Dan Gohman's avatar
      [WebAssembly] Fix lowering of varargs functions with non-legal fixed arguments. · 910ba33d
      Dan Gohman authored
      CallLoweringInfo's NumFixedArgs field gives the number of fixed arguments
      before legalization. The ISD::OutputArg "Outs" array holds legalized
      arguments, so when indexing into it to find the non-fixed arguemn, we need
      to use the number of arguments after legalization.
      
      Fixes PR37934.
      
      llvm-svn: 335576
      910ba33d
    • Craig Topper's avatar
      [X86] Use XOR for SUB (C, X) during isel if will help fold an immediate · c42ed4e3
      Craig Topper authored
      Summary:
      Same idea as D48529, but restricted to X86 and done very late to avoid any surprises where subtract might be better for DAG combining.
      
      This seems like the safest way to do this trick. And we consider doing it as a DAG combine later.
      
      Reviewers: spatel, RKSimon
      
      Reviewed By: spatel
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48557
      
      llvm-svn: 335575
      c42ed4e3
    • Dan Gohman's avatar
      [WebAssembly] Fix a typo in a comment. · fd2f7aeb
      Dan Gohman authored
      llvm-svn: 335574
      fd2f7aeb
    • Peter Collingbourne's avatar
      Mark mfcall.cpp as UNSUPPORTED: win32. · f99bc0b2
      Peter Collingbourne authored
      llvm-svn: 335573
      f99bc0b2
    • Vedant Kumar's avatar
      [ubsan] Relax nullability-return for blocks with deduced types · 03dd150a
      Vedant Kumar authored
      When the return type of an ObjC-style block literals is deduced, pick
      the candidate type with the strictest nullability annotation applicable
      to every other candidate.
      
      This suppresses a UBSan false-positive in situations where a too-strict
      nullability would be deduced, despite the fact that the returned value
      would be implicitly cast to _Nullable.
      
      rdar://41317163
      
      llvm-svn: 335572
      03dd150a
    • Vedant Kumar's avatar
      Modernize a function, NFC. · 2a46384c
      Vedant Kumar authored
      llvm-svn: 335571
      2a46384c
    • Teresa Johnson's avatar
      [ThinLTO] Add string saver onto index for value names · 51905533
      Teresa Johnson authored
      Summary:
      Adds a string saver to the ModuleSummaryIndex so it can store value
      names in the case of adding a ValueInfo for a GUID when we don't
      have the name stored in a Module string table. This is motivated
      by the upcoming summary parser patch, where we will read value names
      from the summary entry and want to store them, even when a Module
      is not available.
      
      Currently this allows us to store the name in the legacy bitcode case,
      and I have added a test to show that.
      
      Reviewers: pcc, dexonsmith
      
      Subscribers: mehdi_amini, inglorion, eraman, steven_wu, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D47842
      
      llvm-svn: 335570
      51905533
    • Peter Collingbourne's avatar
      Implement CFI for indirect calls via a member function pointer. · e44acadf
      Peter Collingbourne authored
      Similarly to CFI on virtual and indirect calls, this implementation
      tries to use program type information to make the checks as precise
      as possible.  The basic way that it works is as follows, where `C`
      is the name of the class being defined or the target of a call and
      the function type is assumed to be `void()`.
      
      For virtual calls:
      - Attach type metadata to the addresses of function pointers in vtables
        (not the functions themselves) of type `void (B::*)()` for each `B`
        that is a recursive dynamic base class of `C`, including `C` itself.
        This type metadata has an annotation that the type is for virtual
        calls (to distinguish it from the non-virtual case).
      - At the call site, check that the computed address of the function
        pointer in the vtable has type `void (C::*)()`.
      
      For non-virtual calls:
      - Attach type metadata to each non-virtual member function whose address
        can be taken with a member function pointer. The type of a function
        in class `C` of type `void()` is each of the types `void (B::*)()`
        where `B` is a most-base class of `C`. A most-base class of `C`
        is defined as a recursive base class of `C`, including `C` itself,
        that does not have any bases.
      - At the call site, check that the function pointer has one of the types
        `void (B::*)()` where `B` is a most-base class of `C`.
      
      Differential Revision: https://reviews.llvm.org/D47567
      
      llvm-svn: 335569
      e44acadf
    • Craig Topper's avatar
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and... · 689e363f
      Craig Topper authored
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
      
      This recommits r335562 and 335563 as a single commit.
      
      The frontend will surround the intrinsic with the appropriate marshalling to/from a scalar type to match the sigature of the builtin that software expects.
      
      By exposing the vXi1 type directly in the llvm intrinsic we make it available to optimizers much earlier. This can enable the scalar marshalling code to be optimized away.
      
      llvm-svn: 335568
      689e363f
    • Teresa Johnson's avatar
      [ThinLTO] Add per-module indexes to combined index consistently · 9766fd64
      Teresa Johnson authored
      Summary:
      Without this change we only add module paths to the combined index when
      there is a module hash or at least one global value. Make this more
      consistent by adding the module to the index whenever there is a summary
      section, and it is a per-module summary (had a MODULE_CODE_SOURCE_FILENAME
      record).
      
      Since we will no longer add module paths lazily, add a new interface to get
      the module info from the index that asserts it is already added.
      
      Fixes PR37899.
      
      Reviewers: Vlad, pcc
      
      Subscribers: mehdi_amini, inglorion, steven_wu, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48511
      
      llvm-svn: 335567
      9766fd64
    • Craig Topper's avatar
      Revert r335562 and 335563 "[X86] Redefine avx512 packed fpclass intrinsics to... · 6f4fdfa9
      Craig Topper authored
      Revert r335562 and 335563 "[X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction."
      
      These were supposed to have been squashed to a single commit.
      
      llvm-svn: 335566
      6f4fdfa9
    • Lang Hames's avatar
      [ORC] Add a symbolAliases function to the Core APIs. · ce72161d
      Lang Hames authored
      symbolAliases can be used to define symbol aliases within a VSO.
      
      llvm-svn: 335565
      ce72161d
    • Craig Topper's avatar
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and... · 4ef61aec
      Craig Topper authored
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
      
      Additional IR is emitted to convert between scalar and vXi1 type to match the expected software inferface for the builtin that clang exposes.
      
      llvm-svn: 335564
      4ef61aec
    • Craig Topper's avatar
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and... · c2ee4a50
      Craig Topper authored
      [X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
      
      The frontend will surround the intrinsic with the appropriate marshalling to/from a scalar type to match the sigature of the builtin that software expects.
      
      By exposing the vXi1 type directly in the llvm intrinsic we make it available to optimizers much earlier. This can enable the scalar marshalling code to be optimized away.
      
      llvm-svn: 335563
      c2ee4a50
    • Craig Topper's avatar
      foo · 9b4322ce
      Craig Topper authored
      llvm-svn: 335562
      9b4322ce
    • Fangrui Song's avatar
      [gdb] Escape unprintable bytes in SmallString and StringRef · 6a906374
      Fangrui Song authored
      llvm-svn: 335561
      6a906374
    • Teresa Johnson's avatar
      [ThinLTO] Compute GUID directly from GV when building per-module index · 7bea1aad
      Teresa Johnson authored
      Summary:
      I discovered when writing the summary parsing support that the
      per-module index builder and writer are computing the GUID from the
      value name alone (ignoring the linkage type). This was ok since those
      GUID were not emitted in the bitcode, and there are never multiple
      conflicting names in a single module.
      
      However, I don't see a reason for making the GUID computation different
      for the per-module case. It also makes things simpler on the parsing
      side to have the GUID computation consistent. So this patch changes the
      summary analysis phase and the per-module summary writer to compute the
      GUID using the facility on the GlobalValue.
      
      Reviewers: pcc, dexonsmith
      
      Subscribers: llvm-commits, inglorion
      
      Differential Revision: https://reviews.llvm.org/D47844
      
      llvm-svn: 335560
      7bea1aad
    • Artem Dergachev's avatar
      [analyzer] Track null and undef values through expressions with cleanups. · 57790c56
      Artem Dergachev authored
      ExprWithCleanups wraps full-expressions that require temporary destructors
      and highlights the moment of time in which these destructors need to be called
      (i.e., "at the end of the full-expression...").
      
      Such expressions don't necessarily return an object; they may return anything,
      including a null or undefined value.
      
      When the analyzer tries to understand where the null or undefined value came
      from in order to present better diagnostics to the user, it will now skip
      any ExprWithCleanups it encounters and look into the expression itself.
      
      Differential Revision: https://reviews.llvm.org/D48204
      
      llvm-svn: 335559
      57790c56
    • Eric Christopher's avatar
      Add a warning if someone attempts to add extra section flags to sections · b7a52bb2
      Eric Christopher authored
      with well defined semantics like .rodata.
      
      llvm-svn: 335558
      b7a52bb2
    • Tim Shen's avatar
      [APInt] Add helpers for rounding u/sdivs. · 802c31cc
      Tim Shen authored
      Reviewers: sanjoy, craig.topper
      
      Subscribers: jlebar, hiraditya, bixia, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48498
      
      llvm-svn: 335557
      802c31cc
    • Jason Molenda's avatar
      A little cleanup in ObjectFileMachO::GetSDKVersion. · 32a91425
      Jason Molenda authored
      This method does one of two things:
      
      1. finds a minimum os deployment version # in a Mach-O load
      command and saves the three parts in the m_sdk_version, or
      
      2. finds no valid min os version # load command, pushes a 
      sentinel value on the m_sdk_version vector so we don't search
      the same load commands multiple times.
      
      There was a little bug when we found a load command with 
      a version of 0.0.0 - the method would not add anything to
      the m_sdk_version vector but would declare that a success.
      It would not push the sentinel value to the vector.
      There was code later in the method which assumed that
      the vector always had a sentinel value, at least, and that
      code could crash when this method was called back when
      evaluating a Swift expression.  (these version #'s are 
      fetched lazily so it wouldn't happen when the object file
      was parsed, only when doing an expression that needed
      the version #).
      
      <rdar://problem/41372699> 
      
      llvm-svn: 335556
      32a91425
    • Artem Dergachev's avatar
      [analyzer] Fix invalidation on C++ const methods with arrow syntax. · f74ef4b1
      Artem Dergachev authored
      Conservative evaluation of a C++ method call would invalidate the object,
      as long as the method is not const or the object has mutable fields.
      
      When checking for mutable fields, we need to scan the type of the object on
      which the method is called, which may be more specific than the type of the
      object on which the method is defined, hence we look up the type from the
      this-argument expression.
      
      If arrow syntax or implicit-this syntax is used, this-argument expression
      has pointer type, not record type, and lookup accidentally failed for that
      reason. Obtain object type correctly.
      
      Differential Revision: https://reviews.llvm.org/D48460
      
      llvm-svn: 335555
      f74ef4b1
    • Fangrui Song's avatar
      [gdb] Add pretty printer for Expected · a157b8be
      Fangrui Song authored
      Reviewers: dblaikie
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D48512
      
      llvm-svn: 335554
      a157b8be
    • Chandler Carruth's avatar
      [PM/LoopUnswitch] Teach the new unswitch to handle nontrivial · 1652996f
      Chandler Carruth authored
      unswitching of switches.
      
      This works much like trivial unswitching of switches in that it reliably
      moves the switch out of the loop. Here we potentially clone the entire
      loop into each successor of the switch and re-point the cases at these
      clones.
      
      Due to the complexity of actually doing nontrivial unswitching, this
      patch doesn't create a dedicated routine for handling switches -- it
      would duplicate far too much code. Instead, it generalizes the existing
      routine to handle both branches and switches as it largely reduces to
      looping in a few places instead of doing something once. This actually
      improves the results in some cases with branches due to being much more
      careful about how dead regions of code are managed. With branches,
      because exactly one clone is created and there are exactly two edges
      considered, somewhat sloppy handling of the dead regions of code was
      sufficient in most cases. But with switches, there are much more
      complicated patterns of dead code and so I've had to move to a more
      robust model generally. We still do as much pruning of the dead code
      early as possible because that allows us to avoid even cloning the code.
      
      This also surfaced another problem with nontrivial unswitching before
      which is that we weren't as precise in reconstructing loops as we could
      have been. This seems to have been mostly harmless, but resulted in
      pointless LCSSA PHI nodes and other unnecessary cruft. With switches, we
      have to get this *right*, and everything benefits from it.
      
      While the testing may seem a bit light here because we only have two
      real cases with actual switches, they do a surprisingly good job of
      exercising numerous edge cases. Also, because we share the logic with
      branches, most of the changes in this patch are reasonably well covered
      by existing tests.
      
      The new unswitch now has all of the same fundamental power as the old
      one with the exception of the single unsound case of *partial* switch
      unswitching -- that really is just loop specialization and not
      unswitching at all. It doesn't fit into the canonicalization model in
      any way. We can add a loop specialization pass that runs late based on
      profile data if important test cases ever come up here.
      
      Differential Revision: https://reviews.llvm.org/D47683
      
      llvm-svn: 335553
      1652996f
    • Alexander Polyakov's avatar
      Fix windows build for r335541. · 32447ff5
      Alexander Polyakov authored
      I didn't include <functional> header and used std::function.
      
      llvm-svn: 335552
      32447ff5
    • Craig Topper's avatar
      [X86] Update fpclass intrinsic tests to chain their calls to the intrinsic... · 53a41858
      Craig Topper authored
      [X86] Update fpclass intrinsic tests to chain their calls to the intrinsic rather than joining them with add.
      
      The test cases try to test masked and unmasked isntructions at the same time. Previously the masked version relies on an extra fucntion parameter. Then the two results were combined with 'add'.
      
      This patch gets rid of the second parameter and just passes the result of the first intrinsic into the mask argument of the second call. Then there's no need for an 'add'.
      
      This configuration works a lot better with an upcoming patch to redefine the intrinsics to use vXi1 types for the output and mask argument.
      
      llvm-svn: 335551
      53a41858