1. Jun 26, 2018
    • 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
    • Jessica Paquette's avatar
      [MachineOutliner] NFC - simplify -moutline/-mno-outline logic · b9d5ee56
      Jessica Paquette authored
      It's a bit cleaner to use `hasFlag` instead of nested ifs. This
      just refactors the -moutline/-mno-outline logic to use that.
      
      llvm-svn: 335549
      b9d5ee56
    • Francis Visoiu Mistrih's avatar
      [OrcMCJIT] Fix test after r335508 causing it to fail on green dragon · 48c4885f
      Francis Visoiu Mistrih authored
      http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/46572/console
      
      LLVM ERROR: unsupported relocation with subtraction expression, symbol
      '__GLOBAL_OFFSET_TABLE_' can not be undefined in a subtraction
      expression
      
      Do the same thing as MCJIT/eh-lg-pic.ll.
      
      llvm-svn: 335548
      48c4885f
    • Eric Christopher's avatar
      Fix unsigned/signed comparison failure in unittest. · cd731002
      Eric Christopher authored
      llvm-svn: 335547
      cd731002
    • Yunlian Jiang's avatar
      Add an option to support debug fission on implicit ThinLTO. · 87c88cc4
      Yunlian Jiang authored
      Summary:
      This adds an option -gsplit-dwarf=<arg>. LLVM can create .dwo files in the given directory
      during the implicit ThinLTO link stage.
      
      Reviewers: tejohnson, dblaikie, pcc
      
      Reviewed By: pcc
      
      Subscribers: steven_wu, aprantl, JDevlieghere, yunlian, probinson, mehdi_amini, inglorion, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D44788
      
      llvm-svn: 335546
      87c88cc4
    • Sanjay Patel's avatar
      [InstCombine] cleanup udiv folds; NFCI · 38a86d31
      Sanjay Patel authored
      This removes a "UDivFoldAction" in favor of a simple constant
      matcher. In theory, the existing code could do more matching,
      but I don't see any evidence or need for it. I've left a TODO
      about using ValueTracking in case we see any regressions.
      
      llvm-svn: 335545
      38a86d31
    • Sanjay Patel's avatar
      [InstCombine] add/move tests for udiv; NFC · 0c90400b
      Sanjay Patel authored
      llvm-svn: 335544
      0c90400b
    • Bruno Cardoso Lopes's avatar
      Fix tests from r335542 to use %hmaptool · e2252d5c
      Bruno Cardoso Lopes authored
      llvm-svn: 335543
      e2252d5c
    • Bruno Cardoso Lopes's avatar
      Warning for framework include violation from Headers to PrivateHeaders · 1b3b69fb
      Bruno Cardoso Lopes authored
      Framework vendors usually layout their framework headers in the
      following way:
      
      Foo.framework/Headers -> "public" headers
      Foo.framework/PrivateHeader -> "private" headers
      
      Since both headers in both directories can be found with #import
      <Foo/some-header.h>, it's easy to make mistakes and include headers in
      Foo.framework/PrivateHeader from headers in Foo.framework/Headers, which
      usually configures a layering violation on Darwin ecosystems. One of the
      problem this causes is dep cycles when modules are used, since it's very
      common for "private" modules to include from the "public" ones; adding
      an edge the other way around will trigger cycles.
      
      Add a warning to catch those cases such that:
      
      ./A.framework/Headers/A.h:1:10: warning: public framework header includes private framework header 'A/APriv.h'
      #include <A/APriv.h>
               ^
      
      rdar://problem/38712182
      
      llvm-svn: 335542
      1b3b69fb
    • Alexander Polyakov's avatar
      Implement new methods for handling an error in MI commands. · 9bca7483
      Alexander Polyakov authored
      Summary:
      The new methods take SBError object and call handler,
      specified by user, depending on SBError status.
      
      Reviewers: aprantl, clayborg, labath
      
      Reviewed By: aprantl, clayborg
      
      Subscribers: ki.stfu, lldb-commits
      
      Differential Revision: https://reviews.llvm.org/D48295
      
      llvm-svn: 335541
      9bca7483
    • Benjamin Kramer's avatar
      [Instrumentation] Remove unused include · 16497748
      Benjamin Kramer authored
      It's also a layering violation.
      
      llvm-svn: 335528
      16497748
    • Sanjay Patel's avatar
      [InstCombine] fold sdiv with sext bool divisor · 6a96d90a
      Sanjay Patel authored
      llvm-svn: 335527
      6a96d90a
    • Sanjay Patel's avatar
      [InstCombine] add tests for sdiv with sext bool divisor; NFC · 46f9b8c3
      Sanjay Patel authored
      llvm-svn: 335526
      46f9b8c3
    • Vlad Tsyrklevich's avatar
      UBSan blacklist workaround for bot timeouts · d0fa44fe
      Vlad Tsyrklevich authored
      Summary: Workaround for PR37929
      
      Reviewers: eugenis, vitalybuka
      
      Reviewed By: eugenis
      
      Subscribers: llvm-commits, kcc
      
      Differential Revision: https://reviews.llvm.org/D48566
      
      llvm-svn: 335525
      d0fa44fe
    • David Carlier's avatar
      [UBsan] Enable ubsan minimal unit tests on OpenBSD · 7a0bf90d
      David Carlier authored
      OpenBSD needs lld linker for sanitisers.
      Disabling lint checking as some symbols cannot be defined and block the proper unit tests launch.
      
      Reviewers: lebedev.ri, vitalybuka
      
      Reviewed By: vitalybuka
      
      Differential Revision: https://reviews.llvm.org/D48528
      
      llvm-svn: 335524
      7a0bf90d
    • Vedant Kumar's avatar
      [ubsan] Mark a test case as unsupported on Windows · 487bef37
      Vedant Kumar authored
      __ubsan_on_report isn't defined as weak, and redefining it in a test is
      not supported on Windows.
      
      See the error message here: https://reviews.llvm.org/D48446
      
      llvm-svn: 335523
      487bef37
    • Florian Hahn's avatar
      Revert r335513: [SCEVExp] Advance found insertion point · b10b141a
      Florian Hahn authored
      llvm-svn: 335522
      b10b141a
    • Craig Topper's avatar
      [LoopIdiomRecognize] Fix a couple places where it appears we were... · 27847868
      Craig Topper authored
      [LoopIdiomRecognize] Fix a couple places where it appears we were unintenionally making copies of DebugLoc.
      
      llvm-svn: 335521
      27847868
    • Florian Hahn's avatar
      Force vector width for scev-expander-debug.ll test · 0b3ed574
      Florian Hahn authored
      llvm-svn: 335520
      0b3ed574
    • Matt Morehouse's avatar
      [CMake] Run libFuzzer tests with check-all. · 3077c824
      Matt Morehouse authored
      Reviewers: kcc
      
      Reviewed By: kcc
      
      Subscribers: llvm-commits, mgorny
      
      Differential Revision: https://reviews.llvm.org/D48200
      
      llvm-svn: 335519
      3077c824
    • Craig Topper's avatar
      [X86] Simplify intrinsic table binary search to not require a temporary struct. · 913abc8b
      Craig Topper authored
      std::lower_bound doesn't require the thing to search for to be the same type as the table entries. We just need to define an appropriate comparison function that can take an table entry and an intrinsic number.
      
      llvm-svn: 335518
      913abc8b
    • Craig Topper's avatar
      614f1924