1. Sep 18, 2018
    • whitequark's avatar
      [OCaml] Add OCaml APIs for Invoke arguments and destinations · c296d176
      whitequark authored
      Summary:
      This patch adds OCaml APIs for LLVMGetNormalDest and LLVMGetUnwindDest
      on InvokeInsts, as well as LLVMGetNumArgOperands on CallInsts and
      InvokeInsts.
      
      Reviewers: whitequark
      
      Reviewed By: whitequark
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52204
      
      llvm-svn: 342433
      c296d176
    • Ryan Prichard's avatar
      [ELF] Set Out::TlsPhdr earlier for encoding packed reloc tables · 1c33d14b
      Ryan Prichard authored
      Summary:
      For --pack-dyn-relocs=android, finalizeSections calls
      LinkerScript::assignAddresses and
      AndroidPackedRelocationSection::updateAllocSize in a loop,
      where assignAddresses lays out the ELF image, then updateAllocSize
      determines the size of the Android packed relocation table by encoding it.
      Encoding the table requires knowing the values of relocation addends.
      
      To get the addend of a TLS relocation, updateAllocSize can call getSymVA
      on a TLS symbol before setPhdrs has initialized Out::TlsPhdr, producing an
      error:
      
          <file> has an STT_TLS symbol but doesn't have an SHF_TLS section
      
      Fix the problem by initializing Out::TlsPhdr immediately after the program
      headers are created. The segment's p_vaddr field isn't initialized until
      setPhdrs, so use FirstSec->Addr, which is what setPhdrs would use.
      FirstSec will typically refer to the .tdata or .tbss output section, whose
      (tentative) address was computed by assignAddresses.
      
      Android currently avoids this problem because it uses emutls and doesn't
      support ELF TLS. This problem doesn't apply to --pack-dyn-relocs=relr
      because SHR_RELR only handles relative relocations without explicit addends
      or info.
      
      Fixes https://bugs.llvm.org/show_bug.cgi?id=37841.
      
      Reviewers: ruiu, pcc, chh, javed.absar, espindola
      
      Subscribers: emaste, arichardson, llvm-commits, srhines
      
      Differential Revision: https://reviews.llvm.org/D51671
      
      llvm-svn: 342432
      1c33d14b
    • Volodymyr Sapsai's avatar
      Revert "[ARM] Cleanup ARM CGP isSupportedValue" · 703ab84c
      Volodymyr Sapsai authored
      This reverts r342395 as it caused error
      
      > Argument value type does not match pointer operand type!
      >   %0 = atomicrmw volatile xchg i8* %_Value1, i32 1 monotonic, !dbg !25
      >  i8in function atomic_flag_test_and_set
      > fatal error: error in backend: Broken function found, compilation aborted!
      
      on bot http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/
      
      More details are available at https://reviews.llvm.org/D52080
      
      llvm-svn: 342431
      703ab84c
    • Reid Kleckner's avatar
      Work around grep vs. CRLF issue in Thumb2 test by matching excess whitespace · d38f9a6c
      Reid Kleckner authored
      There seems to be a separate command line tokenization issue that
      prevents just ':\s*$' from working, since then the pattern argument
      isn't quoted, and grep.exe misinterprets the backslash somehow.
      
      llvm-svn: 342430
      d38f9a6c
    • whitequark's avatar
      [OCaml] Add GlobalIFunc value kind to OCaml API · d299b2c3
      whitequark authored
      Summary:
      The GlobalIFunc value kind has not yet been added to the OCaml
      API. This patch only extends the enum, so that e.g. classify_value
      will not crash. No support for manipulating or building GlobalIFuncs
      is added at this point.
      
      Reviewers: whitequark, deadalnix
      
      Reviewed By: whitequark
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52198
      
      llvm-svn: 342429
      d299b2c3
    • whitequark's avatar
      [OCaml] Add Token type to kind enum in OCaml API · 17c7040b
      whitequark authored
      Summary:
      The token type has not yet been added to the OCaml API. This
      patch only extends the enum, so that e.g. classify_type will not
      crash. No support for manipulating or building tokens is added at this
      point.
      
      Reviewers: whitequark
      
      Reviewed By: whitequark
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52197
      
      llvm-svn: 342428
      17c7040b
    • whitequark's avatar
      [OCaml] Add missing instruction opcodes to OCaml API · 4923d54c
      whitequark authored
      Summary:
      The OCaml bindings have become out of date and several opcodes have
      been added to the C API without corresponding additions to the OCaml
      API.
      
      Reviewers: whitequark, mgorny
      
      Reviewed By: whitequark
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52196
      
      llvm-svn: 342427
      4923d54c
    • Saleem Abdulrasool's avatar
      build: fix standalone builds for compiler-rt on Darwin · f5ebd70a
      Saleem Abdulrasool authored
      When building static fat libraries, we need to ensure that we use libtool rather
      than llvm-ar to create the library.  Duplicate the rules from LLVM to ensure
      that we correctly build the fat libraries when building compiler-rt standalone.
      This also requires that we duplicate the workaround for the `DYLD_LIBRARY_PATH`
      for SIP.  Additionally, ensure that we set the `CMAKE_*_ARCHIVE_FINISH` variable
      to ensure that we do not try to use `ranlib` on that target.
      
      llvm-svn: 342425
      f5ebd70a
    • Shafik Yaghmour's avatar
      Revert "[DataFormatters] Add formatter for C++17 std::variant" · 2ee93d28
      Shafik Yaghmour authored
      This reverts commit r342421.
      
      Because it breaks build bot http://green.lab.llvm.org/green/job/lldb-cmake-clang-5.0.2//418/console
      
      llvm-svn: 342424
      2ee93d28
    • Matt Morehouse's avatar
      [libFuzzer] Avoid fuzzer symbols being hidden. · 1e1f3c82
      Matt Morehouse authored
      Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1490845#c5.
      
      Patch By: Mike Hommey
      
      llvm-svn: 342423
      1e1f3c82
    • Alina Sbirlea's avatar
      [EarlyCSEwMemorySSA] Add MSSA verification and tests to make EarlyCSE failures easier to track. · a782a70a
      Alina Sbirlea authored
      Summary:
      EarlyCSE can make IR changes that will leave MemorySSA with accesses claiming to be optimized, but for which a subsequent MemorySSA run will yield a different optimized result.
      Due to relying on AA queries, we can't fix this in general, unless we recompute MemorySSA.
      Adding some tests to track this and a basic verify for future potential failures.
      
      Reviewers: george.burgess.iv, gberry
      
      Subscribers: sanjoy, jlebar, Prazek, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D51960
      
      llvm-svn: 342422
      a782a70a
    • Shafik Yaghmour's avatar
      [DataFormatters] Add formatter for C++17 std::variant · 854a3509
      Shafik Yaghmour authored
      rdar://problem/43691454
      
      Patch by Shafik Yaghmour.
      
      Differential Revision: https://reviews.llvm.org/D51520
      
      llvm-svn: 342421
      854a3509
    • Zachary Turner's avatar
      Add #include <cassert> · 50f6a9ce
      Zachary Turner authored
      This should fix the broken builds on some bots.
      
      llvm-svn: 342420
      50f6a9ce
    • Jim Ingham's avatar
      Add docs for scripted breakpoint resolvers · 25256c7f
      Jim Ingham authored
      Differential Revision: https://reviews.llvm.org/D52065
      
      llvm-svn: 342419
      25256c7f
    • Aaron Puchert's avatar
      Thread safety analysis: Run more tests with capability attributes [NFC] · e33105e8
      Aaron Puchert authored
      Summary:
      We run the tests for -Wthread-safety-{negative,verbose} with the new
      attributes as well as the old ones. Also put the macros in a header so
      that we don't have to copy them all around.
      
      The warn-thread-safety-parsing.cpp test checks for warnings depending on
      the actual attribute name, so it can't undergo the same treatment.
      
      Together with D49275 this should fix PR33754.
      
      Reviewers: aaron.ballman, delesley, grooverdan
      
      Reviewed By: aaron.ballman
      
      Subscribers: cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D52141
      
      llvm-svn: 342418
      e33105e8
    • Shuai Wang's avatar
      [clang-tidy] Fix tests for performance-for-range-copy · 13f5dd52
      Shuai Wang authored
      Test failed as D52120 made ExprMutationAnalyzer smarter, fixed by:
      - Add move-ctor for `Mutable` to make it actually movable.
      - Properly implement `remove_reference`.
      
      The failed test case is:
      void negativeVarIsMoved() {
        for (auto M : View<Iterator<Mutable>>()) {
          auto Moved = std::move(M);
        }
      }
      Before D52120, `std::move(M)` itself is considered as a mutation to `M`,
      while after D52120 it's only considered as a cast to rvalue, the
      move-assignment is what causes the actual mutation. The test case didn't
      mock things properly so the intended move-assignement was actually a
      copy-assignment.
      
      llvm-svn: 342417
      13f5dd52
    • Simon Atanasyan's avatar
      [mips] Fix MIPS N32 ABI triples support · 9265dca8
      Simon Atanasyan authored
      Add support mips64(el)-linux-gnuabin32 triples, and set them to N32.
      Debian architecture name mipsn32/mipsn32el are also added. Set
      UseIntegratedAssembler for N32 if we can detect it.
      
      Patch by YunQiang Su.
      
      Differential revision: https://reviews.llvm.org/D51408
      
      llvm-svn: 342416
      9265dca8
    • Zachary Turner's avatar
      [PDB] Make the native reader support enumerators. · bdf0381e
      Zachary Turner authored
      Previously we would dump the names of enum types, but not their
      enumerator values.  This adds support for enumerator values.  In
      doing so, we have to introduce a general purpose mechanism for
      caching symbol indices of field list members.  Unlike global
      types, FieldList members do not have a TypeIndex.  So instead,
      we identify them by the pair {TypeIndexOfFieldList, IndexInFieldList}.
      
      llvm-svn: 342415
      bdf0381e
    • Zachary Turner's avatar
      [PDB] Make the native reader support modified types. · 4727ac23
      Zachary Turner authored
      Previously for cv-qualified types, we would just ignore them
      and they would never get printed.  Now we can enumerate them
      and cache them like any other symbol type.
      
      llvm-svn: 342414
      4727ac23
    • George Karpenkov's avatar
      [analyzer] ExplodedGraph printing fixes · 8639c5d5
      George Karpenkov authored
      Fixes a number of issues:
      
       - Global variables are not used for communication
       - Trait should be defined on a graph, not on a node
       - Defining the trait on a graph allows us to use a correct allocator,
         no longer crashing while printing trimmed graphs
      
      Differential Revision: https://reviews.llvm.org/D52183
      
      llvm-svn: 342413
      8639c5d5
    • Nirav Dave's avatar
      [MC] Avoid inlining constant symbols with variants. · b1f9e4d2
      Nirav Dave authored
      Summary:
      Defer unnecessary early inlining of constants to symbol
      variants. Fixes PR38945.
      
      Reviewers: nickdesaulniers, rnk
      
      Subscribers: nemanjai, hiraditya, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52188
      
      llvm-svn: 342412
      b1f9e4d2
    • Sean Fertile's avatar
      [PPC64] Support relaxing R_PPC64_TLSGD16 in TlsGdtoLe relaxation. · 72435e57
      Sean Fertile authored
      A General-dynamic tls access can be written using a R_PPC64_TLSGD16 relocation
      if the target got entry is within 16 bits of the TOC-base. This patch adds
      support for R_PPC64_TLSGD16 by relaxing it the same as a R_PPC64_GOT_TLSGD16_LO.
      
      Differential Revision: https://reviews.llvm.org/D52055
      
      llvm-svn: 342411
      72435e57
    • Sean Fertile's avatar
      [PPC64] Helpers for read/write an instr while relocating a half16 type. [NFC] · eed3e43e
      Sean Fertile authored
      There are a growing number of places when we either want to read or write an
      instruction when handling a half16 relocation type. On big-endian the buffer
      pointer is pointing into the middle of the word we want and on little-endian it
      is pointing to the start of the word. These 2 helpers are to simplify reading
      and writing in these contexts.
      
      Differential Revision: https://reviews.llvm.org/D52115
      
      llvm-svn: 342410
      eed3e43e
    • Shuai Wang's avatar
      [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer. · 4305993c
      Shuai Wang authored
      Summary:
      This is a follow up of D52008 and should make the analyzer being able to handle perfect forwardings in real world cases where forwardings are done through multiple layers of function calls with `std::forward`.
      
      Fixes PR38891.
      
      Reviewers: lebedev.ri, JonasToth, george.karpenkov
      
      Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D52120
      
      llvm-svn: 342409
      4305993c
    • Shuai Wang's avatar
      Fix build failure caused by D52157 · 02bfd89c
      Shuai Wang authored
      llvm-svn: 342408
      02bfd89c
    • Shuai Wang's avatar
      [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr · e0248aec
      Shuai Wang authored
      Reviewers: aaron.ballman
      
      Subscribers: cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D52157
      
      llvm-svn: 342407
      e0248aec
    • Michael Kruse's avatar
      [Loopinfo] Remove one latch-case in getLoopID. NFC. · 534c87df
      Michael Kruse authored
      getLoopID has different control flow for two cases: If there is a
      single loop latch and for any other number of loop latches (0 and more
      than one). The latter case should return the same result if there is
      only a single latch. We can save the preceding redundant search for a
      latch by handling both cases with the same code.
      
      Differential Revision: https://reviews.llvm.org/D52118
      
      llvm-svn: 342406
      534c87df
    • Jessica Paquette's avatar
      [MachineOutliner][NFC] Don't map more illegal instrs than you have to · bd72988c
      Jessica Paquette authored
      We were mapping an instruction every time we saw something we couldn't map
      before this. Since each illegal mapping is unique, we only have to do this once.
      
      This makes it so that we don't map illegal instructions when the previous
      mapped instruction was illegal.
      
      In CTMark (AArch64), this results in 240 fewer instruction mappings on
      average over 619 files in total. The largest improvement is 12576 fewer
      mappings in one file, and the smallest is 0. The median improvement is 101
      fewer mappings.
      
      llvm-svn: 342405
      bd72988c
    • Davide Italiano's avatar
      Revert "[IRInterpreter] Minor cleanups, add comments. NFCI." · d405d279
      Davide Italiano authored
      This breaks buildbots.
      
      llvm-svn: 342404
      d405d279
    • Shuai Wang's avatar
      [clang-tidy] Remove duplicated logic in UnnecessaryValueParamCheck and use... · 4b845299
      Shuai Wang authored
      [clang-tidy] Remove duplicated logic in UnnecessaryValueParamCheck and use FunctionParmMutationAnalyzer instead.
      
      Reviewers: alexfh, JonasToth, george.karpenkov
      
      Subscribers: xazax.hun, kristof.beyls, chrib, a.sidorin, Szelethus, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D52158
      
      llvm-svn: 342403
      4b845299
    • Keno Fischer's avatar
      [X86ISel] Implement byval lowering for Win64 calling convention · c8ccaed3
      Keno Fischer authored
      Summary:
      The IR reference for the `byval` attribute states:
      
      ```
      This indicates that the pointer parameter should really be passed by value
      to the function. The attribute implies that a hidden copy of the pointee is
      made between the caller and the callee, so the callee is unable to modify
      the value in the caller. This attribute is only valid on LLVM pointer arguments.
      ```
      
      However, on Win64, this attribute is unimplemented and the raw pointer is
      passed to the callee instead. This is problematic, because frontend authors
      relying on the implicit hidden copy (as happens for every other calling
      convention) will see the passed value silently (if mutable memory) or
      loudly (by means of a crash) modified because the callee treats the
      location as scratch memory space it is allowed to mutate.
      
      At this point, it's worth taking a step back to understand the context.
      In most calling conventions, aggregates that are too large to be passed
      in registers, instead get *copied* to the stack at a fixed (computable
      from the signature) offset of the stack pointer. At the LLVM, we hide
      this hidden copy behind the byval attribute. The caller passes a pointer
      to the desired data and the callee receives a pointer, but these pointers
      are not the same. In particular, the pointer that the callee receives
      points to temporary stack memory allocated as part of the call lowering.
      In most calling conventions, this pointer is never realized in registers
      or memory. The temporary memory is simply defined by an implicit
      offset from the stack pointer at function entry.
      
      Win64, uniquely, works differently. The structure is still passed in
      memory, but instead of being stored at an implicit memory offset, the
      caller computes a pointer to the temporary memory and passes it to
      the callee as a regular pointer (taking up a register, or if all
      registers are taken up, an additional stack slot). Presumably, this
      was done to allow eliding the copy when passing aggregates through
      several functions on the stack.
      
      This explains why ignoring the `byval` attribute mostly works on Win64.
      The argument simply gets passed as a pointer and as long as we're ok
      with the callee trampling all over that memory, there are no ill effects.
      However, it does contradict the documentation of the `byval` attribute
      which specifies that there is to be an implicit copy.
      
      Frontends can of course work around this by never emitting the `byval`
      attribute for Win64 and creating `alloca`s for the requisite temporary
      stack slots (and that does appear to be what frontends are doing).
      However, the presence of the `byval` attribute is not a trap for
      frontend authors, since it seems to work, but silently modifies the
      passed memory contrary to documentation.
      
      I see two solutions:
      - Disallow the `byval` attribute in the verifier if using the Win64
        calling convention.
      - Make it work by simply emitting a temporary stack copy as we would
        with any other calling convention (frontends can of course always
        not use the attribute if they want to elide the copy).
      
      This patch implements the second option (make it work), though I would
      be fine with the first also.
      
      Ref: https://github.com/JuliaLang/julia/issues/28338
      
      Reviewers: rnk
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D51842
      
      llvm-svn: 342402
      c8ccaed3
    • Nico Weber's avatar
      lld-link: Also demangle undefined dllimported symbols. · 5ffd8ced
      Nico Weber authored
      dllimported symbols go through an import stub that's called __imp_ followed by
      the name the stub points to. Make that work.
      
      Differential Revision: https://reviews.llvm.org/D52145
      
      llvm-svn: 342401
      5ffd8ced
    • Stanislav Mekhanoshin's avatar
      [AMDGPU] Initialize instruction itinerary from GCNSubtarget · 06d3b413
      Stanislav Mekhanoshin authored
      I need to use it in the GCN codegen.
      
      Differential Revision: https://reviews.llvm.org/D52123
      
      llvm-svn: 342400
      06d3b413
  2. Sep 17, 2018
    • Alexander Kornienko's avatar
      Revert "[DWARF] reposting r342048, which was reverted in r342056 due to... · e74e0f11
      Alexander Kornienko authored
      Revert "[DWARF] reposting r342048, which was reverted in r342056 due to buildbot errors. Adjusted 2 test cases for ARM and darwin and fixed a bug with the original change in dsymutil."
      
      This reverts commit r342218. Due to a number of failures under TSAN. An isolated
      test case is being worked on.
      
      llvm-svn: 342399
      e74e0f11
    • Xin Tong's avatar
      [CVP] Handle instructions with no user. No need to create CVPLattice state.... · 8a505c64
      Xin Tong authored
      [CVP] Handle instructions with no user. No need to create CVPLattice state. This handles terminator instructions and more.
      
      Summary:
      I tested this patch by compiling sqlite3.ll (clang -O3 -mllvm -disable-llvm-optzns sqlite3.c.)
      
       opt -called-value-propagation sqlite3.ll -time-passes -f -o out.ll
      
       I get 10+% speedup for the pass. I expect some of the gain come from skipping terminator instructions.
      
          === BEFORE THE PATCH ===
          ===-------------------------------------------------------------------------===
                                ... Pass execution timing report ...
          ===-------------------------------------------------------------------------===
            Total Execution Time: 0.5562 seconds (0.5582 wall clock)
      
             ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
             0.2485 ( 46.4%)   0.0120 ( 57.7%)   0.2605 ( 46.8%)   0.2615 ( 46.8%)  Bitcode Writer
             0.1607 ( 30.0%)   0.0079 ( 37.7%)   0.1685 ( 30.3%)   0.1693 ( 30.3%)  Called Value Propagation
             0.1262 ( 23.6%)   0.0009 (  4.5%)   0.1271 ( 22.9%)   0.1275 ( 22.8%)  Module Verifier
             0.5353 (100.0%)   0.0209 (100.0%)   0.5562 (100.0%)   0.5582 (100.0%)  Total
      
          === AFTER THE PATCH ===
          ===-------------------------------------------------------------------------===
                                ... Pass execution timing report ...
          ===-------------------------------------------------------------------------===
            Total Execution Time: 0.5338 seconds (0.5355 wall clock)
      
             ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
             0.2498 ( 48.6%)   0.0118 ( 59.3%)   0.2615 ( 49.0%)   0.2629 ( 49.1%)  Bitcode Writer
             0.1377 ( 26.8%)   0.0075 ( 37.8%)   0.1452 ( 27.2%)   0.1455 ( 27.2%)  Called Value Propagation
             0.1264 ( 24.6%)   0.0006 (  3.0%)   0.1270 ( 23.8%)   0.1271 ( 23.7%)  Module Verifier
             0.5139 (100.0%)   0.0199 (100.0%)   0.5338 (100.0%)   0.5355 (100.0%)  Total
      
      Reviewers: davide, mssimpso
      
      Reviewed By: davide
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D49108
      
      llvm-svn: 342398
      8a505c64
    • Amara Emerson's avatar
      Revert "Revert r342183 "[DAGCombine] Fix crash when store merging created an... · 91c29135
      Amara Emerson authored
      Revert "Revert r342183 "[DAGCombine] Fix crash when store merging created an extract_subvector with invalid index.""
      
      Fixed the assertion failure.
      
      llvm-svn: 342397
      91c29135
    • Jonas Devlieghere's avatar
      [DebugInfo] Remove redundant argument. [NFC] · 9d7cecfc
      Jonas Devlieghere authored
      Removes the redundant UnitType parameter from verifyUnitContents. I also
      fixed  some formatting issues as I was touching the file.
      
      llvm-svn: 342396
      9d7cecfc
    • Sam Parker's avatar
      [ARM] Cleanup ARM CGP isSupportedValue · 481cdab9
      Sam Parker authored
      isSupportedValue explicitly checked and accepted many types of value,
      primarily for debugging reasons. Remove most of these checks and do a
      bit of refactoring now that the pass is more stable. This also enables
      ZExts to be sources, but this has very little practical benefit at the
      moment extend instructions will still be introduced.
      
      Differential Revision: https://reviews.llvm.org/D52080
      
      llvm-svn: 342395
      481cdab9
    • Simon Pilgrim's avatar
      Fix "not all control paths return a value" MSVC warning. NFCI. · a2fd56c3
      Simon Pilgrim authored
      llvm-svn: 342394
      a2fd56c3
    • Jonas Toth's avatar
      [clang-tidy] fix PR37913, templated exception factory diagnosed correctly · b1efe51d
      Jonas Toth authored
      Summary:
      PR37913 documents wrong behaviour for a templated exception factory function.
      The check does misidentify dependent types as not derived from std::exception.
      
      The fix to this problem is to ignore dependent types, the analysis works correctly
      on the instantiated function.
      
      Reviewers: aaron.ballman, alexfh, hokein, ilya-biryukov
      
      Reviewed By: alexfh
      
      Subscribers: lebedev.ri, nemanjai, mgorny, kbarton, xazax.hun, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D48714
      
      llvm-svn: 342393
      b1efe51d