1. Jan 14, 2019
    • Jeremy Morse's avatar
      [DebugInfo] Remove un-necessary logic from HoistThenElseCodeToIf · f216da7e
      Jeremy Morse authored
      Following PR39807, the way in which SimplifyCFG hoists common code on
      branch paths was fixed in r347782. However this left extra code hanging
      around HoistThenElseCodeToIf that wasn't necessary and needlessly
      complicated matters -- we no longer need to look up through the 'if'
      basic block to find a location for hoisted 'select' insts, we can instead
      use the location chosen by applyMergedLocation.
      
      This patch deletes that extra logic, and updates a regression test to
      reflect the new logic (selects get the merged location, not a previous
      insts location).
      
      Differential Revision: https://reviews.llvm.org/D55272
      
      llvm-svn: 351058
      f216da7e
    • Simon Pilgrim's avatar
      [DAGCombiner] Add add saturation constant folding tests. · 67610926
      Simon Pilgrim authored
      Exposes an issue with sadd_sat for computeOverflowKind, so I've disabled it for now.
      
      llvm-svn: 351057
      67610926
    • Diana Picus's avatar
      [ARM GlobalISel] Import MOVi32imm into GlobalISel · 8987d006
      Diana Picus authored
      Make it possible for TableGen to produce code for selecting MOVi32imm.
      This allows reasonably recent ARM targets to select a lot more constants
      than before.
      
      We achieve this by adding GISelPredicateCode to arm_i32imm. It's
      impossible to use the exact same code for both DAGISel and GlobalISel,
      since one uses "Subtarget->" and the other "STI." to refer to the
      subtarget. Moreover, in GlobalISel we don't have ready access to the
      MachineFunction, so we need to add a bit of code for obtaining it from
      the instruction that we're selecting. This is also the reason why it
      needs to remain a PatLeaf instead of the more specific IntImmLeaf.
      
      llvm-svn: 351056
      8987d006
    • Simon Pilgrim's avatar
      3d42815c
    • David Stuttard's avatar
      [AMDGPU] Add support for TFE/LWE in image intrinsics. 2nd try · f77079f8
      David Stuttard authored
      TFE and LWE support requires extra result registers that are written in the
      event of a failure in order to detect that failure case.
      The specific use-case that initiated these changes is sparse texture support.
      
      This means that if image intrinsics are used with either option turned on, the
      programmer must ensure that the return type can contain all of the expected
      results. This can result in redundant registers since the vector size must be a
      power-of-2.
      
      This change takes roughly 6 parts:
      1. Modify the instruction defs in tablegen to add new instruction variants that
      can accomodate the extra return values.
      2. Updates to lowerImage in SIISelLowering.cpp to accomodate setting TFE or LWE
      (where the bulk of the work for these instruction types is now done)
      3. Extra verification code to catch cases where intrinsics have been used but
      insufficient return registers are used.
      4. Modification to the adjustWritemask optimisation to account for TFE/LWE being
      enabled (requires extra registers to be maintained for error return value).
      5. An extra pass to zero initialize the error value return - this is because if
      the error does not occur, the register is not written and thus must be zeroed
      before use. Also added a new (on by default) option to ensure ALL return values
      are zero-initialized that is required for sparse texture support.
      6. Disable the inst_combine optimization in the presence of tfe/lwe (later TODO
      for this to re-enable and handle correctly).
      
      There's an additional fix now to avoid a dmask=0
      
      For an image intrinsic with tfe where all result channels except tfe
      were unused, I was getting an image instruction with dmask=0 and only a
      single vgpr result for tfe. That is incorrect because the hardware
      assumes there is at least one vgpr result, plus the one for tfe.
      
      Fixed by forcing dmask to 1, which gives the desired two vgpr result
      with tfe in the second one.
      
      The TFE or LWE result is returned from the intrinsics using an aggregate
      type. Look in the test code provided to see how this works, but in essence IR
      code to invoke the intrinsic looks as follows:
      
      %v = call {<4 x float>,i32} @llvm.amdgcn.image.load.1d.v4f32i32.i32(i32 15,
                                            i32 %s, <8 x i32> %rsrc, i32 1, i32 0)
      %v.vec = extractvalue {<4 x float>, i32} %v, 0
      %v.err = extractvalue {<4 x float>, i32} %v, 1
      
      This re-submit of the change also includes a slight modification in
      SIISelLowering.cpp to work-around a compiler bug for the powerpc_le
      platform that caused a buildbot failure on a previous submission.
      
      Differential revision: https://reviews.llvm.org/D48826
      
      Change-Id: If222bc03642e76cf98059a6bef5d5bffeda38dda
      
      
      Work around for ppcle compiler bug
      
      Change-Id: Ie284cf24b2271215be1b9dc95b485fd15000e32b
      llvm-svn: 351054
      f77079f8
    • Anastasia Stulova's avatar
      [OpenCL] Set generic addr space of 'this' in special class members. · d1986d1b
      Anastasia Stulova authored
      Set address spaces of 'this' param correctly for implicit special
      class members.
      
      This also changes initialization conversion sequence to separate
      address space conversion from other qualifiers in case of binding
      reference to a temporary. In this case address space conversion  
      should happen after the binding (unlike for other quals). This is
      needed to materialize it correctly in the alloca address space.
      
      Initial patch by Mikael Nilssoni!
      
      Differential Revision: https://reviews.llvm.org/D56066
      
      llvm-svn: 351053
      d1986d1b
    • Kadir Cetinkaya's avatar
      [clangd] Fix a reference invalidation · 560b853c
      Kadir Cetinkaya authored
      Summary: Fix for the breakage in http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/52811/consoleFull#-42777206a1ca8a51-895e-46c6-af87-ce24fa4cd561
      
      Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D56656
      
      llvm-svn: 351052
      560b853c
    • Sam McCall's avatar
      [clangd] Unlink VFS working dir from OS working dir. · 2dccf135
      Sam McCall authored
      A lot of our previous FS manipulation was thread-unsafe in practice with
      the RealFS implementation.
      
      This switches to a different RealFS mode where path-manipulation is used
      to simulate multiple working dirs.
      r351050 both added this mode and removed the cache. If we want to
      move back to the old implementation we need to put the cache back.
      
      llvm-svn: 351051
      2dccf135
    • Sam McCall's avatar
      [VFS] Allow multiple RealFileSystem instances with independent CWDs. · c2b310ae
      Sam McCall authored
      Summary:
      Previously only one RealFileSystem instance was available, and its working
      directory is shared with the process. This doesn't work well for multithreaded
      programs that want to work with relative paths - the vfs::FileSystem is assumed
      to provide the working directory, but a thread cannot control this exclusively.
      
      The new vfs::createPhysicalFileSystem() factory copies the process's working
      directory initially, and then allows it to be independently modified.
      
      This implementation records the working directory path, and glues it to relative
      paths to provide the correct absolute path to the sys::fs:: functions.
      This will give different results in unusual situations (e.g. the CWD is moved).
      
      The main alternative is the use of openat(), fstatat(), etc to ask the OS to
      resolve paths relative to a directory handle which can be kept open. This is
      more robust. There are two reasons not to do this initially:
      1. these functions are not available on all supported Unixes, and are somewhere
         between difficult and unavailable on Windows. So we need a path-based
         fallback anyway.
      2. this would mean also adding support at the llvm::sys::fs level, which is a
         larger project. My clearest idea is an OS-specific `BaseDirectory` object
         that can be optionally passed to functions there. Eventually this could be
         backed by either paths or a fd where openat() is supported.
         This is a large project, and demonstrating here that a path-based fallback
         works is a useful prerequisite.
      
      There is some subtlety to the path-manipulation mechanism:
        - when setting the working directory, both Specified=makeAbsolute(path) and
          Resolved=realpath(path) are recorded. These may differ in the presence of
          symlinks.
        - getCurrentWorkingDirectory() and makeAbsolute() use Specified - this is
          similar to the behavior of $PWD and sys::path::current_path
        - IO operations like openFileForRead use Resolved. This is similar to the
          behavior of an openat() based implementation, that doesn't see changes
          in symlinks.
      There may still be combinations of operations and FS states that yield unhelpful
      behavior. This is hard to avoid with symlinks and FS abstractions :(
      
      The caching behavior of the current working directory is removed in this patch.
      getRealFileSystem() is now specified to link to the process CWD, so the caching
      is incorrect.
      The user who needed this so far is clangd, which will immediately switch to
      createPhysicalFileSystem().
      
      Reviewers: ilya-biryukov, bkramer, labath
      
      Subscribers: ioeric, kadircet, kristina, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D56545
      
      llvm-svn: 351050
      c2b310ae
    • Francis Visoiu Mistrih's avatar
      Replace "no-frame-pointer-*" function attributes with "frame-pointer" · b7cef81f
      Francis Visoiu Mistrih authored
      Part of the effort to refactoring frame pointer code generation. We used
      to use two function attributes "no-frame-pointer-elim" and
      "no-frame-pointer-elim-non-leaf" to represent three kinds of frame
      pointer usage: (all) frames use frame pointer, (non-leaf) frames use
      frame pointer, (none) frame use frame pointer. This CL makes the idea
      explicit by using only one enum function attribute "frame-pointer"
      
      Option "-frame-pointer=" replaces "-disable-fp-elim" for tools such as
      llc.
      
      "no-frame-pointer-elim" and "no-frame-pointer-elim-non-leaf" are still
      supported for easy migration to "frame-pointer".
      
      tests are mostly updated with
      
      // replace command line args ‘-disable-fp-elim=false’ with ‘-frame-pointer=none’
      grep -iIrnl '\-disable-fp-elim=false' * | xargs sed -i '' -e "s/-disable-fp-elim=false/-frame-pointer=none/g"
      
      // replace command line args ‘-disable-fp-elim’ with ‘-frame-pointer=all’
      grep -iIrnl '\-disable-fp-elim' * | xargs sed -i '' -e "s/-disable-fp-elim/-frame-pointer=all/g"
      
      Patch by Yuanfang Chen (tabloid.adroit)!
      
      Differential Revision: https://reviews.llvm.org/D56351
      
      llvm-svn: 351049
      b7cef81f
    • Sam McCall's avatar
      [clang-tidy] update FunctionSizeCheck for D56444 · d37be4b7
      Sam McCall authored
      Reviewers: JonasToth, aaron.ballman
      
      Subscribers: xazax.hun, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D56552
      
      llvm-svn: 351048
      d37be4b7
    • Sam McCall's avatar
      [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on. · e60151c9
      Sam McCall authored
      Summary:
      This fixes ASTContext's parent map for nodes in such classes (e.g. operator()).
      https://bugs.llvm.org/show_bug.cgi?id=39949
      
      This also changes the observed shape of the AST for implicit RAVs.
      - this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes,
      functionDecl() matches the call operator, and the parent chain is body -> call
      operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr.
      - this appears not to matter for the ASTImporterLookupTable builder
      - this doesn't matter for the other RAVs in-tree.
      
      In order to do this, we remove the TraverseLambdaBody hook. The problem is it's
      hard/weird to ensure this hook is called when traversing via the implicit class.
      There were just two users of this hook in-tree, who use it to skip bodies.
      I replaced these with explicitly traversing the captures only. Another approach
      would be recording the bodies when the lambda is visited, and then recognizing
      them later.
      I'd be open to suggestion on how to preserve this hook, instead.
      
      Reviewers: aaron.ballman, JonasToth
      
      Subscribers: cfe-commits, rsmith, jdennett
      
      Differential Revision: https://reviews.llvm.org/D56444
      
      llvm-svn: 351047
      e60151c9
    • Petar Avramovic's avatar
      [MIPS GlobalISel] Add pre legalizer combiner pass · 7d370a36
      Petar Avramovic authored
      Introduce GlobalISel pre legalizer pass for MIPS.
      It will be used to cope with instructions that require
      combining before legalization.
      
      Differential Revision: https://reviews.llvm.org/D56269
      
      llvm-svn: 351046
      7d370a36
    • Max Kazantsev's avatar
      [BasicBlockUtils] Generalize DeleteDeadBlock to deal with multiple dead blocks · 1f73310e
      Max Kazantsev authored
      Utility function `DeleteDeadBlock` expects that all predecessors of a block being
      deleted are already deleted, with the exception of single-block loop. It makes it
      hard to use for deletion of a set of blocks that may contain cyclic dependencies.
      The is no correct order of invocations of this function that does not produce
      dangling pointers on already deleted blocks.
      
      This patch introduces a generalized version of this function `DeleteDeadBlocks`
      that allows us to remove multiple blocks at once, even if there are cycles among
      them. The only requirement is that no block being deleted should have a predecessor
      that is not being deleted. 
      
      The logic of `DeleteDeadBlocks` is following:
        for each block
          create relevant DT updates;
          remove all instructions (replace with undef if needed);
          replace terminator with unreacheable;
        apply DT updates;
        for each block
          delete block;
      
      Therefore, `DeleteDeadBlock` becomes a particular case of
      the general algorithm called for a single block.
      
      Differential Revision: https://reviews.llvm.org/D56120
      Reviewed By: skatkov
      
      llvm-svn: 351045
      1f73310e
    • Daniel Cederman's avatar
      [Sparc] Add Sparc V8 support · 17121adf
      Daniel Cederman authored
      Summary:
      Adds the register class implementation for Sparc.
      Adds support for DW_CFA_GNU_window_save.
      Adds save and restore context functionality.
      
      Adds getArch() function to each Registers_ class to be able to separate
      between DW_CFA_AARCH64_negate_ra_state and DW_CFA_GNU_window_save which
      are both represented by the same constant.
      
      On Sparc the return address is the address of the call instruction, so
      an offset needs to be added when returning to skip the call instruction
      and its delay slot. If the function returns a struct it is also necessary
      to skip one extra instruction on Sparc V8.
      
      Reviewers: jyknight, mclow.lists, mstorsjo, compnerd
      
      Reviewed By: jyknight, compnerd
      
      Subscribers: jgorbe, mgorny, christof, llvm-commits, fedor.sergeev, JDevlieghere, ldionne, libcxx-commits
      
      Differential Revision: https://reviews.llvm.org/D55763
      
      llvm-svn: 351044
      17121adf
    • Dmitry Venikov's avatar
      [llvm-symbolizer] Add -addresses, -a as aliases for -print-address · 5c1768fc
      Dmitry Venikov authored
      Summary: Provides -addresses, -a as aliases for -print-address. Motivation: https://bugs.llvm.org/show_bug.cgi?id=40067.
      
      Reviewers: jhenderson, ruiu, rnk, fjricci
      
      Reviewed By: jhenderson
      
      Subscribers: rupprecht, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D56635
      
      llvm-svn: 351043
      5c1768fc
    • Thomas Preud'homme's avatar
      Fix defines.txt · ca28a465
      Thomas Preud'homme authored
      Support arbitrary suffix when matching FileCheck executable name in
      defines.txt to successfully match FileCheck.EXE on Microsoft Windows.
      
      llvm-svn: 351042
      ca28a465
    • Sam McCall's avatar
      [clangd] Index main-file symbols (bug 39761) · 0e93b076
      Sam McCall authored
      Patch by Nathan Ridge!
      
      Differential Revision: https://reviews.llvm.org/D55185
      
      llvm-svn: 351041
      0e93b076
    • Diana Picus's avatar
      [asan] Add fallback for Thumb after r350139 · 2e3aaed7
      Diana Picus authored
      This reverts r350806 which marked some tests as UNSUPPORTED on ARM and
      instead reintroduces the old code path only for Thumb, since that seems
      to be the only target that broke.
      
      It would still be nice to find the root cause of the breakage, but with
      the branch point for LLVM 8.0 scheduled for next week it's better to put
      things in a stable state while we investigate.
      
      Differential Revision: https://reviews.llvm.org/D56594
      
      llvm-svn: 351040
      2e3aaed7
    • Thomas Preud'homme's avatar
      Detect incorrect FileCheck variable CLI definition · 84f4ff51
      Thomas Preud'homme authored
      Summary:
      While the backend code of FileCheck relies on definition of variable
      from the command-line to have an equal sign '=' and a variable name
      before that, the frontend does not actually enforce it. This leads to
      FileCheck crashing when invoked with invalid syntax for the -D option.
      
      This patch adds the missing validation in the frontend. It also makes
      the -D option an AlwaysPrefix option to be able to detect -D=FOO as
      being a define without variable and -D as missing its value.
      
      Copyright:
      - Linaro (changes in version 2 of revision D55940)
      - GraphCore (changes in later versions)
      
      Reviewers: jdenny
      
      Subscribers: JonChesterfield, hiraditya, kristina, probinson,
      llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D55940
      
      llvm-svn: 351039
      84f4ff51
    • Thomas Preud'homme's avatar
      Add support for prefix-only CLI options · bc5e6ee8
      Thomas Preud'homme authored
      Summary:
      Add support for options that always prefix their value, giving an error
      if the value is in the next argument or if the option is given a value
      assignment (ie. opt=val). This is the desired behavior for the -D option
      of FileCheck for instance.
      
      Copyright:
      - Linaro (changes in version 2 of revision D55940)
      - GraphCore (changes in later versions and introduced when creating
        D56549)
      
      Reviewers: jdenny
      
      Subscribers: llvm-commits, probinson, kristina, hiraditya,
      JonChesterfield
      
      Differential Revision: https://reviews.llvm.org/D56549
      
      llvm-svn: 351038
      bc5e6ee8
    • Stefan Granitz's avatar
      [CMake] LLVM exports utility targets since r350959, so we can use them without... · 4b7e12f2
      Stefan Granitz authored
      [CMake] LLVM exports utility targets since r350959, so we can use them without standalone-checks now
      
      llvm-svn: 351037
      4b7e12f2
    • Craig Topper's avatar
      49488407
    • Craig Topper's avatar
      e7b4ea47
    • Craig Topper's avatar
      [X86] Add new test file that was supposed to go with r351028. · 61493635
      Craig Topper authored
      llvm-svn: 351034
      61493635
    • Craig Topper's avatar
      [X86] Update type profile for DBPSADBW to indicate the immediate is an i8 not just any int. · ab077dda
      Craig Topper authored
      Removes some type checks from X86GenDAGISel.inc
      
      llvm-svn: 351033
      ab077dda
    • Craig Topper's avatar
      [X86] Remove unused intrinsic handlers. NFC · c8cd8558
      Craig Topper authored
      llvm-svn: 351032
      c8cd8558
    • Craig Topper's avatar
      075fcc11
    • Nico Weber's avatar
      lld/include/lld/Core/TODO.txt · 6a5d94cc
      Nico Weber authored
      - fix minor grammar stuff (I'm not a native speaker either, but it's hopefully a net improvement)
      - mention that lld/coff is used in production
      - update AArch64, ARM to production quality
      - remove lld/include/lld/Core/TODO.txt which looks outdated
      
      Differential Revision: https://reviews.llvm.org/D56600
      
      llvm-svn: 351030
      6a5d94cc
    • Craig Topper's avatar
      [X86] Remove mask parameter from vpshufbitqmb intrinsics. Change result to a vXi1 vector. · 689b3b71
      Craig Topper authored
      We'll do the scalar<->vXi1 conversions with bitcasts in IR.
      
      Fixes PR40258
      
      llvm-svn: 351029
      689b3b71
    • Craig Topper's avatar
      [X86] Remove mask parameter from vpshufbitqmb intrinsics. Change result to a vXi1 vector. · 3f3b8ef4
      Craig Topper authored
      The input mask can be represented with an AND in IR.
      
      Fixes PR40258
      
      llvm-svn: 351028
      3f3b8ef4
    • Petr Hosek's avatar
      [libcxx] Mark do_open, do_get and do_close parameters unused when catopen is missing · 2fefe153
      Petr Hosek authored
      When catopen is missing, do_open, do_get and do_close end up being
      no-op, and as such their parameters will be unused which triggers a
      warning/error when building with -Wunused-parameter.
      
      Differential Revision: https://reviews.llvm.org/D56023
      
      llvm-svn: 351027
      2fefe153
    • Simon Pilgrim's avatar
      [DAGCombiner] If add_sat(x,y) can't overflow -> add(x,y) · 56ba1db9
      Simon Pilgrim authored
      NOTE: We need more powerful signed overflow detection in computeOverflowKind
      llvm-svn: 351026
      56ba1db9
    • Simon Pilgrim's avatar
      Fix unused variable warning. NFCI. · 888fa868
      Simon Pilgrim authored
      llvm-svn: 351025
      888fa868
    • Simon Pilgrim's avatar
      [DAGCombiner] Some very basic add/sub saturation combines. · 897d4c6f
      Simon Pilgrim authored
      Handle combines with zero and constant canonicalization for adds.
      
      llvm-svn: 351024
      897d4c6f
    • Simon Pilgrim's avatar
      [X86] Add some basic add/sub saturation combine tests. · 9961c55e
      Simon Pilgrim authored
      The actual combines will be added in a future commit.
      
      llvm-svn: 351023
      9961c55e
    • Craig Topper's avatar
      [LegalizeDAG] Remove 'NeedInvert' code from expansion of BR_CC. Replace with an assert. · 4978de36
      Craig Topper authored
      I accidentally triggered this code while doing some experiments and it doesn't look lke it could possibly work.
      
      It calls 'getNOT' on a node that should be a CondCode.
      
      I think to do this right we would need to swap the branch target and the fallthrough target. But that's not easy to do. Or we could create an explicit SetCC and feed that into a new BR_CC?
      
      llvm-svn: 351022
      4978de36
    • Nikita Popov's avatar
      [X86] Rename overly verbose method; NFC · 0400e504
      Nikita Popov authored
      As suggested on D56636.
      
      llvm-svn: 351021
      0400e504
    • James Y Knight's avatar
      Remove TypeBuilder.h, and fix the few locations using it. · c0044118
      James Y Knight authored
      This shortcut mechanism for creating types was added 10 years ago, but
      has seen almost no uptake since then, neither internally nor in
      external projects.
      
      The very small number of characters saved by using it does not seem
      worth the mental overhead of an additional type-creation API, so,
      delete it.
      
      Differential Revision: https://reviews.llvm.org/D56573
      
      llvm-svn: 351020
      c0044118
  2. Jan 13, 2019
    • Roman Lebedev's avatar
      [OpenMP] Fix LIBOMP_USE_DEBUGGER=ON build (PR38612) · 06e39505
      Roman Lebedev authored
      Summary:
      Two things:
      1. Those two variables had the wrong sigdness, which was resulting in "sign mismatch in comparison" warning.
      2. The whole `kmp_debugger.cpp` wasn't being built, or rather, it was being built as-if `USE_DEBUGGER` was off,
         thus, nothing provided the definition of `__kmp_omp_debug_struct_info`, `__kmp_debugging`.
         Makes sense, because `USE_DEBUGGER` is set in `kmp_config.h`, which is not included explicitly.
         It is included by `kmp.h`, but that one is only included inside of the `#if USE_DEBUGGER` block..
         I *think* this is the only source file with this issue,
         everything else seem to `#include` either `kmp.h` or `kmp_config.h`.
         The alternative solution would be to add `add_compile_options(-include kmp_config.h)` in CMake.
      
      I did verify that `__kmp_omp_debug_struct_info` becomes available with this patch.
      
      Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38612 | PR38612 ]].
      
      Reviewers: AndreyChurbanov, jlpeyton, Hahnfeld
      
      Reviewed By: jlpeyton
      
      Subscribers: guansong, jfb, openmp-commits
      
      Tags: #openmp
      
      Differential Revision: https://reviews.llvm.org/D55783
      
      llvm-svn: 351019
      06e39505