1. Nov 04, 2015
    • James Molloy's avatar
      [SimplifyCFG] Merge conditional stores · 4de84dde
      James Molloy authored
      We can often end up with conditional stores that cannot be speculated. They can come from fairly simple, idiomatic code:
      
        if (c & flag1)
          *a = x;
        if (c & flag2)
          *a = y;
        ...
      
      There is no dominating or post-dominating store to a, so it is not legal to move the store unconditionally to the end of the sequence and cache the intermediate result in a register, as we would like to.
      
      It is, however, legal to merge the stores together and do the store once:
      
        tmp = undef;
        if (c & flag1)
          tmp = x;
        if (c & flag2)
          tmp = y;
        if (c & flag1 || c & flag2)
          *a = tmp;
      
      The real power in this optimization is that it allows arbitrary length ladders such as these to be completely and trivially if-converted. The typical code I'd expect this to trigger on often uses binary-AND with constants as the condition (as in the above example), which means the ending condition can simply be truncated into a single binary-AND too: 'if (c & (flag1|flag2))'. As in the general case there are bitwise operators here, the ladder can often be optimized further too.
      
      This optimization involves potentially increasing register pressure. Even in the simplest case, the lifetime of the first predicate is extended. This can be elided in some cases such as using binary-AND on constants, but not in the general case. Threading 'tmp' through all branches can also increase register pressure.
      
      The optimization as in this patch is enabled by default but kept in a very conservative mode. It will only optimize if it thinks the resultant code should be if-convertable, and additionally if it can thread 'tmp' through at least one existing PHI, so it will only ever in the worst case create one more PHI and extend the lifetime of a predicate.
      
      This doesn't trigger much in LNT, unfortunately, but it does trigger in a big way in a third party test suite.
      
      llvm-svn: 252051
      4de84dde
    • Stephen Canon's avatar
    • Kuba Brecka's avatar
      [tsan] Handle libdispatch worker threads on OS X · a1186b82
      Kuba Brecka authored
      On OS X, GCD worker threads are created without a call to pthread_create. We need to properly register these threads with ThreadCreate and ThreadStart. This patch uses a libpthread API (`pthread_introspection_hook_install`) to get notifications about new threads and about threads that are about to be destroyed.
      
      Differential Revision: http://reviews.llvm.org/D14328
      
      llvm-svn: 252049
      a1186b82
    • Filipe Cabecinhas's avatar
      Error out when faced with value names containing '\0' · a2b0ac40
      Filipe Cabecinhas authored
      Bug found with afl-fuzz.
      
      llvm-svn: 252048
      a2b0ac40
    • Aaron Ballman's avatar
      43059108
    • Aaron Ballman's avatar
      Silence an extra semicolon warning; NFC. · 5db085d6
      Aaron Ballman authored
      llvm-svn: 252046
      5db085d6
    • Erik Verbruggen's avatar
      Initialize member field. · 4e7b87e9
      Erik Verbruggen authored
      llvm-svn: 252045
      4e7b87e9
    • Kuba Brecka's avatar
      [tsan] Shadow memory setup for OS X · 88bccf03
      Kuba Brecka authored
      Updating the shadow memory initialization in `tsan_platform_mac.cc` to also initialize the meta shadow and to mprotect the memory ranges that need to be avoided.
      
      Differential Revision: http://reviews.llvm.org/D14324
      
      llvm-svn: 252044
      88bccf03
    • Michael Kuperstein's avatar
      [ELF] elfiamcu triple should imply e_machine == EM_IAMCU · a3b79dd7
      Michael Kuperstein authored
      Differential Revision: http://reviews.llvm.org/D14109
      
      llvm-svn: 252043
      a3b79dd7
    • Michael Kuperstein's avatar
      [X86] DAGCombine should not introduce FILD in soft-float mode · b34de722
      Michael Kuperstein authored
      The x86 "sitofp i64 to double" dag combine, in 32-bit mode, lowers sitofp 
      directly to X86ISD::FILD (or FILD_FLAG). This should not be done in soft-float mode.
      
      llvm-svn: 252042
      b34de722
    • Angel Garcia Gomez's avatar
      Improve modernize-make-unique matcher. · 3d7d9228
      Angel Garcia Gomez authored
      Summary: "std::unique_ptr<int>" is not the same type as "std::unique_ptr<int, std::default_delete<int>>", unless we insert a "hasCanonicalType" in the middle. Probably it also happens in other cases related to default template argument.
      
      Reviewers: klimek
      
      Subscribers: alexfh, cfe-commits
      
      Differential Revision: http://reviews.llvm.org/D14291
      
      llvm-svn: 252041
      3d7d9228
    • James Molloy's avatar
      Revert "[PatternMatch] Switch to use ValueTracking::matchSelectPattern" · 8bfc772d
      James Molloy authored
      This was breaking the modules build and is being reverted while we reach consensus on the right way to solve this layering problem. This reverts commit r251785.
      
      llvm-svn: 252040
      8bfc772d
    • Pawel Bylica's avatar
      Fix unit tests on Windows: handle env vars with non-ASCII chars. · 85ca2949
      Pawel Bylica authored
      Summary: On Windows we have to take UTF16 encoded env vars and convert them to UTF8. This patch fixes CopyEnvironment helper function used by process unit tests.
      
      Reviewers: yaron.keren
      
      Subscribers: yaron.keren, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D14278
      
      llvm-svn: 252039
      85ca2949
    • Sanjoy Das's avatar
      [OperandBundles] Refactor; NFCI. · bf9d76d6
      Sanjoy Das authored
      Extract out a helper function `operandBundleFromBundleOpInfo`.
      
      llvm-svn: 252038
      bf9d76d6
    • Sanjoy Das's avatar
      [OperandBundles] Refactor; NFCI · 3c95d5d2
      Sanjoy Das authored
      Intended to make later changes simpler.  Exposes
      `getBundleOperandsStartIndex` and `getBundleOperandsEndIndex`, and uses
      them for the computation in `getNumTotalBundleOperands`.
      
      llvm-svn: 252037
      3c95d5d2
    • David Majnemer's avatar
      [Sema] Implement __make_integer_seq · d9b1a4fb
      David Majnemer authored
      This new builtin template allows for incredibly fast instantiations of
      templates like std::integer_sequence.
      
      Performance numbers follow:
      My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz.
      
      __make_integer_seq<std::integer_sequence, int, 90000> takes 0.25
      seconds.
      
      std::make_integer_sequence<int, 90000> takes unbound time, it is still
      running.  Clang is consuming gigabytes of memory.
      
      Differential Revision: http://reviews.llvm.org/D13786
      
      llvm-svn: 252036
      d9b1a4fb
    • Enrico Granata's avatar
      Option letter o was already in use; use an uppercase E instead · 40d3570c
      Enrico Granata authored
      llvm-svn: 252035
      40d3570c
    • Eugene Zelenko's avatar
      Fix Clang-tidy modernize-use-override warnings, other minor fixes. · 6e43b499
      Eugene Zelenko authored
      Differential revision: http://reviews.llvm.org/D14310
      
      llvm-svn: 252034
      6e43b499
    • Philip Reames's avatar
      [LVI] Update a comment to clarify what's actually happening and why · aeefae0c
      Philip Reames authored
      llvm-svn: 252033
      aeefae0c
    • Philip Reames's avatar
      [CVP] Fold return values if possible · 814fb601
      Philip Reames authored
      In my previous change to CVP (251606), I made CVP much more aggressive about trying to constant fold comparisons. This patch is a reversal in direction. Rather than being agressive about every compare, we restore the non-block local restriction for most, and then try hard for compares feeding returns.
      
      The motivation for this is two fold:
       * The more I thought about it, the less comfortable I got with the possible compile time impact of the other approach. There have been no reported issues, but after talking to a couple of folks, I've come to the conclusion the time probably isn't justified.
       * It turns out we need to know the context to leverage the full power of LVI. In particular, asking about something at the end of it's block (the use of a compare in a return) will frequently get more precise results than something in the middle of a block. This is an implementation detail, but it's also hard to get around since mid-block queries have to reason about possible throwing instructions and don't get to use most of LVI's block focused infrastructure. This will become particular important when combined with http://reviews.llvm.org/D14263.
      
      Differential Revision: http://reviews.llvm.org/D14271
      
      llvm-svn: 252032
      814fb601
    • Jim Ingham's avatar
      Add a few useful methods to ThreadSafeDense{Map,Set}. Not used yet. · 5d072930
      Jim Ingham authored
      llvm-svn: 252031
      5d072930
    • Zachary Turner's avatar
      Revert "Python 3 - Don't add the _d suffix to the symlink on Windows." · ff836df6
      Zachary Turner authored
      This reverts commit e59c95ca936f5a0a8abb987b8605fd8bf82b03b6.
      
      This was a mistake on my part.  The real problem was with my
      environment.  I was using a release interpreter to try to load
      my debug extension module.  I noticed this after I finally managed
      to get into my extension module's init method, and then it segfaulted
      with heap errors due to mismatched CRT (debug vs. release)
      
      llvm-svn: 252030
      ff836df6
    • Jim Ingham's avatar
      Fix a shadowed ivar in SearchFilterByModuleListAndCU. · fe617b1e
      Jim Ingham authored
      llvm-svn: 252029
      fe617b1e
    • Igor Laevsky's avatar
      [StatepointLowering] Remove distinction between call and invoke safepoints · 35fe6920
      Igor Laevsky authored
      There is no point in having invoke safepoints handled differently than the
      call safepoints. All relevant decisions could be made by looking at whether
      or not gc.result and gc.relocate lay in a same basic block. This change will
       allow to lower call safepoints with relocates and results in a different 
      basic blocks. See test case for example.
      
      Differential Revision: http://reviews.llvm.org/D14158
      
      llvm-svn: 252028
      35fe6920
    • Alexey Samsonov's avatar
      Fix the test case for Windows. · 24519d98
      Alexey Samsonov authored
      llvm-svn: 252027
      24519d98
    • Zachary Turner's avatar
      Python 3 - Don't add the _d suffix to the symlink on Windows. · b20ef356
      Zachary Turner authored
      In Python 2, a debug extension module required an _d suffix, so
      for example the extension module `_lldb` would be backed by the file
      `_lldb_d.pyd` if built in debug mode, and `_lldb.pyd` if built in
      release mode.  In Python 2, although undocumented, this seems to
      no longer be the case, and even for a debug extension module, the
      interpreter will only look for the `_lldb.pyd` name.
      
      llvm-svn: 252026
      b20ef356
    • Zachary Turner's avatar
      Python 3 - Use universal_newlines when calling subprocess.check_output · bbc5b46a
      Zachary Turner authored
      By default in Python 3, check_output() returns a program's output as
      an encoded byte sequence.  This means it returns a Py3 `bytes` object,
      which cannot be compared to a string since it's a different fundamental
      type.
      
      Although it might not be correct from a purist standpoint, from a
      practical one we can assume that all output is encoded in the default
      locale, in which case using universal_newlines=True will decode it
      according to the current locale.  Anyway, universal_newlines also
      has the nice behavior that it converts \r\n to \n on Windows platforms
      so this makes parsing code easier, should we need that.  So it seems
      like a win/win.
      
      llvm-svn: 252025
      bbc5b46a
    • Jim Ingham's avatar
      Actually implement Section::GetSectionData. · 1c58d5ac
      Jim Ingham authored
      llvm-svn: 252024
      1c58d5ac
    • Jim Ingham's avatar
      Try a little harder to provide a legit CWD to argdumper if · 6d9880a6
      Jim Ingham authored
      the user hasn't provided one.
      
      llvm-svn: 252023
      6d9880a6
    • Alexey Samsonov's avatar
      [LLVMSymbolize] Reduce indentation by using helper function. NFC. · 5365a01d
      Alexey Samsonov authored
      llvm-svn: 252022
      5365a01d
    • Alexey Samsonov's avatar
      884adda0
    • Alexey Samsonov's avatar
      [llvm-symbolizer] Improve the test for missing input file. · b0742319
      Alexey Samsonov authored
      llvm-svn: 252020
      b0742319
    • Adam Nemet's avatar
      Fix unused variable warning from r252017 · 7c94c9bf
      Adam Nemet authored
      llvm-svn: 252019
      7c94c9bf
    • Enrico Granata's avatar
      Fix an issue where LLDB would truncate summaries for string types without... · b7662929
      Enrico Granata authored
      Fix an issue where LLDB would truncate summaries for string types without producing any evidence thereof
      
      llvm-svn: 252018
      b7662929
    • Adam Nemet's avatar
      LLE 6/6: Add LoopLoadElimination pass · e54a4fa9
      Adam Nemet authored
      Summary:
      The goal of this pass is to perform store-to-load forwarding across the
      backedge of a loop.  E.g.:
      
        for (i)
           A[i + 1] = A[i] + B[i]
      
        =>
      
        T = A[0]
        for (i)
           T = T + B[i]
           A[i + 1] = T
      
      The pass relies on loop dependence analysis via LoopAccessAnalisys to
      find opportunities of loop-carried dependences with a distance of one
      between a store and a load.  Since it's using LoopAccessAnalysis, it was
      easy to also add support for versioning away may-aliasing intervening
      stores that would otherwise prevent this transformation.
      
      This optimization is also performed by Load-PRE in GVN without the
      option of multi-versioning.  As was discussed with Daniel Berlin in
      http://reviews.llvm.org/D9548, this is inferior to a more loop-aware
      solution applied here.  Hopefully, we will be able to remove some
      complexity from GVN/MemorySSA as a consequence.
      
      In the long run, we may want to extend this pass (or create a new one if
      there is little overlap) to also eliminate loop-indepedent redundant
      loads and store that *require* versioning due to may-aliasing
      intervening stores/loads.  I have some motivating cases for store
      elimination. My plan right now is to wait for MemorySSA to come online
      first rather than using memdep for this.
      
      The main motiviation for this pass is the 456.hmmer loop in SPECint2006
      where after distributing the original loop and vectorizing the top part,
      we are left with the critical path exposed in the bottom loop.  Being
      able to promote the memory dependence into a register depedence (even
      though the HW does perform store-to-load fowarding as well) results in a
      major gain (~20%).  This gain also transfers over to x86: it's
      around 8-10%.
      
      Right now the pass is off by default and can be enabled
      with -enable-loop-load-elim.  On the LNT testsuite, there are two
      performance changes (negative number -> improvement):
      
        1. -28% in Polybench/linear-algebra/solvers/dynprog: the length of the
           critical paths is reduced
        2. +2% in Polybench/stencils/adi: Unfortunately, I couldn't reproduce this
           outside of LNT
      
      The pass is scheduled after the loop vectorizer (which is after loop
      distribution).  The rational is to try to reuse LAA state, rather than
      recomputing it.  The order between LV and LLE is not critical because
      normally LV does not touch scalar st->ld forwarding cases where
      vectorizing would inhibit the CPU's st->ld forwarding to kick in.
      
      LoopLoadElimination requires LAA to provide the full set of dependences
      (including forward dependences).  LAA is known to omit loop-independent
      dependences in certain situations.  The big comment before
      removeDependencesFromMultipleStores explains why this should not occur
      for the cases that we're interested in.
      
      Reviewers: dberlin, hfinkel
      
      Subscribers: junbuml, dberlin, mssimpso, rengolin, sanjoy, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D13259
      
      llvm-svn: 252017
      e54a4fa9
    • Adam Nemet's avatar
      [LAA] LLE 5/6: Add predicate functions Dependence::isForward/isBackward, NFC · 397f5829
      Adam Nemet authored
      Summary: Will be used by the LoopLoadElimination pass.
      
      Reviewers: hfinkel
      
      Subscribers: llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D13258
      
      llvm-svn: 252016
      397f5829
    • Adam Nemet's avatar
      [LAA] LLE 4/6: APIs to access the dependent instructions for a dependence, NFC · ed653d67
      Adam Nemet authored
      Summary:
      The functions use LAI and MemoryDepChecker classes so they need to be
      defined after those definitions outside of the Dependence class.
      
      Will be used by the LoopLoadElimination pass.
      
      Reviewers: hfinkel
      
      Subscribers: rengolin, llvm-commits
      
      Differential Revision: http://reviews.llvm.org/D13257
      
      llvm-svn: 252015
      ed653d67
    • Peter Collingbourne's avatar
      CodeGen, Target: Move Mach-O-specific symbol name logic to Mach-O lowering. · 94d77869
      Peter Collingbourne authored
      A profile of an LTO link of Chrome revealed that we were spending some
      ~30-50% of execution time in the function Constant::getRelocationInfo(),
      which is called from TargetLoweringObjectFile::getKindForGlobal() and in turn
      from TargetMachine::getNameWithPrefix().
      
      It turns out that we only need the result of getKindForGlobal() when
      targeting Mach-O, so this change moves the relevant part of the logic to
      TargetLoweringObjectFileMachO.
      
      NFCI.
      
      Differential Revision: http://reviews.llvm.org/D14168
      
      llvm-svn: 252014
      94d77869
    • Greg Clayton's avatar
      26014690
    • Greg Clayton's avatar
      Fix __fp16 types so we can display them and use them in expressions. · dee40e72
      Greg Clayton authored
      I am not adding a test case for this since I don't know how portable the __fp16 type is between compilers and I don't want to break the test suite.
      
      <rdar://problem/22375079>
      
      llvm-svn: 252012
      dee40e72