1. Jun 27, 2017
    • Chandler Carruth's avatar
      [SROA] Fix PR32902 by more carefully propagating !nonnull metadata. · 3f81d802
      Chandler Carruth authored
      This is based heavily on the work done ni D34285. I mostly wanted to do
      test cleanup for the author to save them some time, but I had a really
      hard time understanding why it was so hard to write better test cases
      for these issues.
      
      The problem is that because SROA does a second rewrite of the loads and
      because we *don't* propagate !nonnull for non-pointer loads, we first
      introduced invalid !nonnull metadata and then stripped it back off just
      in time to avoid most ways of this PR manifesting. Moving to the more
      careful utility only fixes this by changing the predicate to look at the
      new load's type rather than the target type. However, that *does* fix
      the bug, and the utility is much nicer including adding range metadata
      to model the nonnull property after a conversion to an integer.
      
      However, we have bigger problems because we don't actually propagate
      *range* metadata, and the utility to do this extracted from instcombine
      isn't really in good shape to do this currently. It *only* handles the
      case of copying range metadata from an integer load to a pointer load.
      It doesn't even handle the trivial cases of propagating from one integer
      load to another when they are the same width! This utility will need to
      be beefed up prior to using in this location to get the metadata to
      fully survive.
      
      And even then, we need to go and teach things to turn the range metadata
      into an assume the way we do with nonnull so that when we *promote* an
      integer we don't lose the information.
      
      All of this will require a new test case that looks kind-of like
      `preserve-nonnull.ll` does here but focuses on range metadata. It will
      also likely require more testing because it needs to correctly handle
      changes to the integer width, especially as SROA actively tries to
      change the integer width!
      
      Last but not least, I'm a little worried about hooking the range
      metadata up here because the instcombine logic for converting from
      a range metadata *to* a nonnull metadata node seems broken in the face
      of non-zero address spaces where null is not mapped to the integer `0`.
      So that probably needs to get fixed with test cases both in SROA and in
      instcombine to cover it.
      
      But this *does* extract the core PR fix from D34285 of preventing the
      !nonnull metadata from being propagated in a broken state just long
      enough to feed into promotion and crash value tracking.
      
      On D34285 there is some discussion of zero-extend handling because it
      isn't necessary. First, the new load size covers all of the non-undef
      (ie, possibly initialized) bits. This may even extend past the original
      alloca if loading those bits could produce valid data. The only way its
      valid for us to zero-extend an integer load in SROA is if the original
      code had a zero extend or those bits were undef. And we get to assume
      things like undef *never* satifies nonnull, so non undef bits can
      participate here. No need to special case the zero-extend handling, it
      just falls out correctly.
      
      The original credit goes to Ariel Ben-Yehuda! I'm mostly landing this to
      save a few rounds of trivial edits fixing style issues and test case
      formulation.
      
      Differental Revision: D34285
      
      llvm-svn: 306379
      3f81d802
    • Haojian Wu's avatar
      [clang-tidy] Fix type names in modernize-use-unique/shared_ptr checks. · 665494ca
      Haojian Wu authored
      Summary:
      If the class being created in unique_ptr is in anonymous nampespace, the
      anonymous namespace will be included in the apply-fixes. This patch fix
      this.
      
      ```
      namespace {
      class Foo {};
      }
      std::unique_ptr<Foo> f;
      f.reset(new Foo());
      // Before the change: f = std::make_unique<(annonymous namespace)::Foo>();
      // After the change: f = std::make_unique<Foo>();
      ```
      
      Reviewers: alexfh
      
      Reviewed By: alexfh
      
      Subscribers: JDevlieghere, xazax.hun, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D34286
      
      llvm-svn: 306378
      665494ca
    • Stephan Bergmann's avatar
      Make CastExpr::getSubExprAsWritten look through implicit temporary under CK_ConstructorConversion · f31b0dc4
      Stephan Bergmann authored
      With
      
          struct S1 {};
          struct S2 { operator S1(); };
          S1 f(S2 s) { return static_cast<S1>(s); }
      
      the static_cast expr is
      
          CXXStaticCastExpr 0x... 'struct S1' static_cast<struct S1> <ConstructorConversion>
          `-CXXConstructExpr 0x... 'struct S1' 'void (struct S1 &&) noexcept' elidable
      
          `-MaterializeTemporaryExpr 0x... 'struct S1' xvalue
            `-ImplicitCastExpr 0x... 'struct S1' <UserDefinedConversion>
              `-CXXMemberCallExpr 0x... 'struct S1'
                `-MemberExpr 0x... '<bound member function type>' .operator S1 0x...
                  `-DeclRefExpr 0x... 'struct S2' lvalue ParmVar 0x... 's' 'struct S2'
      
      getSubExprAsWritten used to return the MaterializeTemporaryExpr (of type S1)
      under the CXXConstructExpr, instead of unwinding further to the DeclRefExpr (of
      type S2) at the bottom.
      
      Differential Revision: https://reviews.llvm.org/D22128
      
      llvm-svn: 306377
      f31b0dc4
    • Vassil Vassilev's avatar
      Add missing forward declaraion. · 2315d833
      Vassil Vassilev authored
      llvm-svn: 306376
      2315d833
    • Nicolai Haehnle's avatar
      AMDGPU: M0 operands to spill/restore opcodes are dead · 43cc6c4e
      Nicolai Haehnle authored
      Summary:
      With scalar stores, M0 is clobbered and therefore marked as implicitly
      defined. However, it is also dead.
      
      This fixes an assertion when the Greedy Register Allocator decides to
      optimize a spill/restore pair away again (via tryHintsRecoloring).
      
      Reviewers: arsenm
      
      Subscribers: qcolombet, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D33319
      
      llvm-svn: 306375
      43cc6c4e
    • Stephan Bergmann's avatar
      Make sure TraverseInitListExpr visits InitListExpr exactly twice · a504c433
      Stephan Bergmann authored
      ... once each for the syntactic and semantic form. Without this fix, behavior
      of the newly added tests would have been
      
      InitListExprIsPreOrderVisitedTwice:
       syntactic: 1
       semantic: 2
      
      InitListExprIsPostOrderVisitedTwice:
       syntactic: 0
       semantic: 1
      
      InitListExprIsPreOrderNoQueueVisitedTwice:
       syntactic: 1
       semantic: 2
      
      InitListExprIsPostOrderNoQueueVisitedTwice:
       syntactic: 0
       semantic: 2
      
      llvm-svn: 306374
      a504c433
    • Stephan Bergmann's avatar
      Switch TestVisitor to Lang_C via -x c · 83e6a826
      Stephan Bergmann authored
      ...instead of -std=c99, as the latter lead to
      
        error: invalid argument '-std=c99' not allowed with 'C++'
      
      complaints in test logs
      
      Differential Revision: https://reviews.llvm.org/D34417
      
      llvm-svn: 306373
      83e6a826
    • NAKAMURA Takumi's avatar
      3a90dcff
    • Ayman Musa's avatar
      [TableGen] Fix bug in TableGen CodeGenPatterns when adding variants of the patterns. · 40e3f194
      Ayman Musa authored
      All patterns reside in a std::vector container, where new variants are added to it using the standard library's emplace_back function.
      When calling this with a new element while there is no enough allocated space, a bigger space is allocated and all the old info in the small vector is copied to the newly allocated vector, then the old vector is freed.
      The problem is that before doing this "copying", we take a reference of one of the elements in the old vector, and after the "copying" we add it to the new vector.
      As the old vector is freed after the copying, the reference now does not point to a valid element.
      
      Added new function to the API of CodeGenDAGPatterns class to return the same information as a copy in order to avoid this issue.
      
      This was revealed in rL305465 that added many patterns and forced the reallocation of the vector which caused crashes in windows bots.
      
      Differential Revision: https://reviews.llvm.org/D34341
      
      llvm-svn: 306371
      40e3f194
    • Igor Breger's avatar
      [GlobalISel][X86] Add fp32/62 legalizer, regbank-select, selection tests for... · 925f088b
      Igor Breger authored
      [GlobalISel][X86] Add fp32/62 legalizer, regbank-select, selection tests for G_FADD, G_FSUB, G_FMUL, G_FDIV. NFC.
      
      llvm-svn: 306370
      925f088b
    • Galina Kistanova's avatar
    • Mikael Holmen's avatar
      [Reassociate] Make sure EraseInst sets MadeChange · 37b5120a
      Mikael Holmen authored
      Summary:
      EraseInst didn't report that it made IR changes through MadeChange.
      
      It is essential that changes to the IR are reported correctly,
      since for example ReassociatePass::run() will indicate that all
      analyses are preserved otherwise.
      And the CGPassManager determines if the CallGraph is up-to-date
      based on status from InstructionCombiningPass::runOnFunction().
      
      Reviewers: craig.topper, rnk, davide
      
      Reviewed By: rnk, davide
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D34616
      
      llvm-svn: 306368
      37b5120a
    • Hiroshi Inoue's avatar
      [PowerPC] set optimization level in SelectionDAGISel · 5102028f
      Hiroshi Inoue authored
      PowerPC backend does not pass the current optimization level to SelectionDAGISel and so SelectionDAGISel works with the default optimization level regardless of the current optimization level.
      This patch makes the PowerPC backend set the optimization level correctly.
      
      Differential Revision: https://reviews.llvm.org/D34615
      
      llvm-svn: 306367
      5102028f
    • Mandeep Singh Grang's avatar
      [COFF, ARM64] Fix typo in COFF ARM64 Relocation Type · 53b82b3d
      Mandeep Singh Grang authored
      Summary:
      Fixed IMAGE_REL_ARM64_PAGEBASE_REL2 ==> IMAGE_REL_ARM64_PAGEBASE_REL21
      Refer: http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
      
      Reviewers: zturner, rnk, ruiu
      
      Reviewed By: ruiu
      
      Subscribers: aemerson, kristof.beyls, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D34659
      
      llvm-svn: 306366
      53b82b3d
    • Craig Topper's avatar
      [InstCombine] Add test cases demonstrating that we don't optmize... · f9319a78
      Craig Topper authored
      [InstCombine] Add test cases demonstrating that we don't optmize select+cmp+cttz/ctlz when the bitwidth is larger than 64 bits.
      
      llvm-svn: 306365
      f9319a78
    • Akira Hatanaka's avatar
      [CodeGen][ObjC] Fix GNU's encoding of bit-field ivars. · 4b1c4844
      Akira Hatanaka authored
      According to the documentation, when encoding a bit-field, GNU runtime
      needs its starting position in addition to its type and size.
      
      https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html
      
      Prior to r297702, the starting position information was not being
      encoded, which is incorrect, and after r297702, an assertion started to
      fail because an ObjCIvarDecl was being passed to a function expecting a
      FieldDecl.
      
      This commit moves LookupFieldBitOffset to ASTContext and uses the
      function to encode the starting position of bit-fields.
      
      llvm-svn: 306364
      4b1c4844
    • Leslie Zhai's avatar
      [AVR] Migrate to new MCAsmBackend applyFixup and processFixupValue · c9d9d797
      Leslie Zhai authored
      Reviewers: rafael, dylanmckay, jroelofs, meadori
      
      Reviewed By: rafael, meadori
      
      Subscribers: meadori, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D34551
      
      llvm-svn: 306359
      c9d9d797
    • Chandler Carruth's avatar
      [SROA] Further test cleanup and add a test for the actual propagation of · c6916235
      Chandler Carruth authored
      the nonnull attribute distinct from rewriting it into an assume.
      
      llvm-svn: 306358
      c6916235
    • Hal Finkel's avatar
      Make test/parallel/omp_nested.c not use so many threads · 2bc3449d
      Hal Finkel authored
      I've found it very difficult to get test/parallel/omp_nested.c to pass
      consistently across my build environments. The problem is that it creates N^2
      threads (it is testing nested parallel regions), and that often exceeds the
      thread limits on systems with many cores. We do raise the process limits in
      lit, and that often helps, but if running lit with a smaller number of threads
      or on a system where we're otherwise resource constrained, this particular test
      tends to fail (because the runtime cannot create a sufficient number of
      threads).
      
      This seems to work: if the maximum number of threads is more than some small
      number, then cap the number of threads used for the parallel region. The choice
      of 4 here is somewhat arbitrary.
      
      Differential Revision: https://reviews.llvm.org/D32033
      
      llvm-svn: 306357
      2bc3449d
    • Davide Italiano's avatar
      [CFLAA] Move FunctionHandle to llvm::cflaa. · e096da7f
      Davide Italiano authored
      Also, while here, remove an unneeded `using namespace llvm`.
      Thanks to George for the suggestion.
      
      llvm-svn: 306355
      e096da7f
    • Davide Italiano's avatar
      [CFLAA] Move a common function to the header to reduce duplication. · 31d4c1bb
      Davide Italiano authored
      Differential Revision:  https://reviews.llvm.org/D34660
      
      llvm-svn: 306354
      31d4c1bb
    • Chandler Carruth's avatar
      [SROA] Clean up a test case a bit prior to adding more testing for · 3b978394
      Chandler Carruth authored
      nonnull as part of fixing PR32902.
      
      llvm-svn: 306353
      3b978394
    • Matthias Braun's avatar
      ScheduleDAGInstrs: Fix fixupKills() adding too many kill flags. · e2ae0019
      Matthias Braun authored
      Remove invalid shortcut in fixupKills(): A register needs to be marked
      live even when we are not adding a kill flag. This is because a
      partially live register must not get a kill flags, but it still needs to
      be fully marked live when walking backwards.
      
      llvm-svn: 306352
      e2ae0019
    • Davide Italiano's avatar
      [CFLAA] Use raw pointers instead of Optional<Pointer>. NFC. · 604c003f
      Davide Italiano authored
      Using Optional<> here doesn't seem to be terribly valuable, but
      this is not the main point of this change. The change enables
      us to merge the (now) two identical copies of parentFunctionOfValue()
      that Steensgaard's and Andersens' provide.
      
      llvm-svn: 306351
      604c003f
    • Richard Smith's avatar
      Remove redundant check. · 92843707
      Richard Smith authored
      llvm-svn: 306350
      92843707
    • Richard Smith's avatar
      Fix this test to use a construct that actually forces struct layout to happen... · 96b96c8e
      Richard Smith authored
      Fix this test to use a construct that actually forces struct layout to happen when testing -Wpadded.
      
      llvm-svn: 306349
      96b96c8e
    • Davide Italiano's avatar
      e34a8064
    • Saleem Abdulrasool's avatar
      AST: enhance mangling for blocks with MS ABI · 3cc6d0bc
      Saleem Abdulrasool authored
      When generating the decorated name for a static variable inside a
      BlockDecl, construct a scope for the block invocation function that
      homes the parameter. This allows for arbitrary nesting of the blocks
      even if the variables are shadowed. Furthermore, using this for the name
      allows for undname to properly undecorated the name for us. It shows up
      as the synthetic __block_invocation function that the compiler emitted
      in the local scope.
      
      llvm-svn: 306347
      3cc6d0bc
    • Richard Smith's avatar
      Revert r301742, which caused us to try to evaluate all full-expressions. · 9f7df0c0
      Richard Smith authored
      Also add testcases for a bunch of expression forms that cause our evaluator to
      crash. See PR33140 and PR32864 for crashes that this was causing.
      
      This reverts r305287, which reverted r305239, which reverted r301742. The
      previous revert claimed that buildbots were broken, but did not add any
      testcases and the buildbots have lost all memory of what was wrong here.
      
      Changes to test/OpenMP are not reverted; another change has triggered those
      tests to change their output in the same way that r301742 did.
      
      llvm-svn: 306346
      9f7df0c0
    • Wolfgang Pieb's avatar
      DAGCombine: Make sure we only eliminate trunc/extend when the scales of... · 9f658582
      Wolfgang Pieb authored
      DAGCombine: Make sure we only eliminate trunc/extend when the scales of truncation and extension match.
      This fixes PR33368.
      
      Reviewer: rksimon
      
      Differential Revision:  https://reviews.llvm.org/D34069
      
      llvm-svn: 306345
      9f658582
    • Dehao Chen's avatar
      revert r306336 for breaking ppc test. · 8b7effb3
      Dehao Chen authored
      llvm-svn: 306344
      8b7effb3
    • Alexander Shaposhnikov's avatar
      [clang] Enable printf check for CFIndex · 62351374
      Alexander Shaposhnikov authored
      According to 
      https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
      CFIndex and NSInteger should be treated the same way (see the section Platform Dependencies).
      This diff changes the function shouldNotPrintDirectly in SemaChecking.cpp accordingly 
      and adds tests for the "fixit" and the warning.
      
      Differential revision: https://reviews.llvm.org/D34496
      
      Test plan: make check-all
      
      llvm-svn: 306343
      62351374
    • Alex Shlyapnikov's avatar
      [Sanitizers] 64 bit allocator respects allocator_may_return_null flag · 01676883
      Alex Shlyapnikov authored
      Summary:
      Make SizeClassAllocator64 return nullptr when it encounters OOM, which
      allows the entire sanitizer's allocator to follow
      allocator_may_return_null=1 policy
      (LargeMmapAllocator: D34243, SizeClassAllocator64: D34433).
      
      Reviewers: eugenis
      
      Subscribers: srhines, kubamracek, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D34540
      
      llvm-svn: 306342
      01676883
    • Eugene Zelenko's avatar
      [CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use... · 76bf48d9
      Eugene Zelenko authored
      [CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
      
      llvm-svn: 306341
      76bf48d9
    • Vedant Kumar's avatar
      [Coverage] Improve readability by using a struct. NFC. · 71b3d721
      Vedant Kumar authored
      llvm-svn: 306340
      71b3d721
    • Ayal Zaks's avatar
      reverting 306331. · 3923c0c4
      Ayal Zaks authored
      Causes TBAA metadata to be generates on reverse shuffles, investigating.
      
      llvm-svn: 306338
      3923c0c4
    • Sanjay Patel's avatar
      [x86] add tests for missing sbb transforms; NFC · b859910e
      Sanjay Patel authored
      llvm-svn: 306337
      b859910e
    • Dehao Chen's avatar
      Enable vectorizer-maximize-bandwidth by default. · 79655792
      Dehao Chen authored
      Summary:
      vectorizer-maximize-bandwidth is generally useful in terms of performance. I've tested the impact of changing this to default on speccpu benchmarks on sandybridge machines. The result shows non-negative impact:
      
      spec/2006/fp/C++/444.namd                 26.84  -0.31%
      spec/2006/fp/C++/447.dealII               46.19  +0.89%
      spec/2006/fp/C++/450.soplex               42.92  -0.44%
      spec/2006/fp/C++/453.povray               38.57  -2.25%
      spec/2006/fp/C/433.milc                   24.54  -0.76%
      spec/2006/fp/C/470.lbm                    41.08  +0.26%
      spec/2006/fp/C/482.sphinx3                47.58  -0.99%
      spec/2006/int/C++/471.omnetpp             22.06  +1.87%
      spec/2006/int/C++/473.astar               22.65  -0.12%
      spec/2006/int/C++/483.xalancbmk           33.69  +4.97%
      spec/2006/int/C/400.perlbench             33.43  +1.70%
      spec/2006/int/C/401.bzip2                 23.02  -0.19%
      spec/2006/int/C/403.gcc                   32.57  -0.43%
      spec/2006/int/C/429.mcf                   40.35  +0.27%
      spec/2006/int/C/445.gobmk                 26.96  +0.06%
      spec/2006/int/C/456.hmmer                  24.4  +0.19%
      spec/2006/int/C/458.sjeng                 27.91  -0.08%
      spec/2006/int/C/462.libquantum            57.47  -0.20%
      spec/2006/int/C/464.h264ref               46.52  +1.35%
      
      geometric mean                                   +0.29%
      
      The regression on 453.povray seems real, but is due to secondary effects as all hot functions are bit-identical with and without the flag.
      
      I started this patch to consult upstream opinions on this. It will be greatly appreciated if the community can help test the performance impact of this change on other architectures so that we can decided if this should be target-dependent.
      
      Reviewers: hfinkel, mkuper, davidxl, chandlerc
      
      Reviewed By: chandlerc
      
      Subscribers: rengolin, sanjoy, javed.absar, bjope, dorit, magabari, RKSimon, llvm-commits, mzolotukhin
      
      Differential Revision: https://reviews.llvm.org/D33341
      
      llvm-svn: 306336
      79655792
    • Kuba Mracek's avatar
      [asan] Flag 'asan_gen_prefixes.cc' as unsupported on iOS. The ARM and ARM64... · 495371d6
      Kuba Mracek authored
      [asan] Flag 'asan_gen_prefixes.cc' as unsupported on iOS. The ARM and ARM64 assemblers can use different label prefixes than the expected.
      
      llvm-svn: 306335
      495371d6
    • Dehao Chen's avatar
      Fix the bug when handling shufflevector for aarch64. · 38f1bc78
      Dehao Chen authored
      Summary: This Fixes https://bugs.llvm.org/show_bug.cgi?id=33600
      
      Reviewers: mssimpso, davidxl, Carrot
      
      Reviewed By: mssimpso
      
      Subscribers: aemerson, rengolin, sanjoy, javed.absar, llvm-commits, kristof.beyls
      
      Differential Revision: https://reviews.llvm.org/D34641
      
      llvm-svn: 306334
      38f1bc78