1. Oct 13, 2018
    • Shafik Yaghmour's avatar
      Changing test names in TestDataFormatterLibcxxVariant.py and... · 730985b1
      Shafik Yaghmour authored
      Changing test names in TestDataFormatterLibcxxVariant.py and TestStdFunctionStepIntoCallable.py to be unique, NFC
      
      llvm-svn: 344407
      730985b1
    • Ben Hamilton's avatar
      [clang-format] Fix BraceWrapping AfterFunction for ObjC methods · 97034a36
      Ben Hamilton authored
      Summary:
      > clang-format --version
      > clang-format version 7.0.0 (tags/RELEASE_700/final)
      > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" |clang-format -style='{BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}'
      ```
      @implementation Foo
      - (void)foo:(id)bar {
      }
      @end
      ```
      
      with patch:
      
      > bin/clang-format --version
      > clang-format version 8.0.0 (trunk 344285)
      > echo "@implementation Foo\n- (void)foo:(id)bar\n{\n}\n@end\n" |bin/clang-format -style='{BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}'
      ```
      @implementation Foo
      - (void)foo:(id)bar
      {
      }
      @end
      ```
      
      Contributed by hultman@.
      
      Reviewers: benhamilton, jolesiak, klimek, Wizard
      
      Reviewed By: benhamilton
      
      Subscribers: cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D53197
      
      llvm-svn: 344406
      97034a36
    • Eli Friedman's avatar
      Revert BTF commit series. · a6e3a823
      Eli Friedman authored
      The initial patch was not reviewed, and does not have any tests;
      it should not have been merged.
      
      This reverts 344395, 344390, 344387, 344385, 344381, 344376,
      and 344366.
      
      llvm-svn: 344405
      a6e3a823
    • Craig Topper's avatar
      [LegalizeVectorTypes] When widening the operands to a concat_vectors, see if... · 1bb0c604
      Craig Topper authored
      [LegalizeVectorTypes] When widening the operands to a concat_vectors, see if we can use the widened operand 0 if the width matches and the other operands are undef.
      
      This saves a conversion to extracts and build_vector. We already do this when both the result and the input need to be widened to the same type.
      
      This changed the sse-intrinsics-fast-isel test because we don't lower (insert_vector_elt (scalar_to_vector X), Y, 1) well. We turn it into (vector_shuffle (scalar_to_vector X), (scalar_to_vector Y), <0, 4, 2, 3>) losing track of the fact that the upper elts could be undef.
      
      We should probably find a way to prevent the scalarization of the <2 x f32> load on these tests.
      
      llvm-svn: 344404
      1bb0c604
    • Craig Topper's avatar
      [LegalizeVectorTypes] When unrolling in WidenVecRes_Convert, make sure we use... · 05f014a6
      Craig Topper authored
      [LegalizeVectorTypes] When unrolling in WidenVecRes_Convert, make sure we use the original vector element count. Not min of the widened result type and the possibly widened input type.
      
      If the input type is widened as well, but we still were forced to unroll, we shouldn't be considering the widened input element count. We should only create as many scalar operations as the original type called for.
      
      This will be important for an upcoming patch.
      
      llvm-svn: 344403
      05f014a6
    • Simon Pilgrim's avatar
      Fix Wdocumentation warning. NFCI. · 9ff1e1be
      Simon Pilgrim authored
      llvm-svn: 344402
      9ff1e1be
    • Vedant Kumar's avatar
      [dotest] Make a missing FileCheck binary a warning, not an error · 8e2f09d6
      Vedant Kumar authored
      This allows bots which haven't updated to pass in --filecheck to
      dotest.py to run more tests. FileCheck-dependent tests will continue to
      fail.
      
      Differential Revision: https://reviews.llvm.org/D53175
      
      llvm-svn: 344401
      8e2f09d6
    • Simon Pilgrim's avatar
      Fix a clang::driver::ArgStringList usage I missed in rL344398. NFCI. · c39a2174
      Simon Pilgrim authored
      llvm-svn: 344400
      c39a2174
    • Simon Pilgrim's avatar
      Regenerate test. NFCI. · 1d6b9381
      Simon Pilgrim authored
      llvm-svn: 344399
      1d6b9381
    • Simon Pilgrim's avatar
      Consistently make llvm::opt::ArgStringList usage explicit to try and appease... · 0e50d4c4
      Simon Pilgrim authored
      Consistently make llvm::opt::ArgStringList usage explicit to try and appease MSVC 2015 buildbots. NFCI.
      
      llvm-svn: 344398
      0e50d4c4
    • Jim Ingham's avatar
      9082c1c0
    • Rui Ueyama's avatar
      Replace assert() with llvm_unreachable because it's obviously a typo. · 0f3a56c8
      Rui Ueyama authored
      llvm-svn: 344395
      0f3a56c8
    • Rui Ueyama's avatar
      Remove `Type` parameter from SymbolTable::insert(). NFC. · f3fad557
      Rui Ueyama authored
      `Type` parameter was used only to check for TLS attribute mismatch,
      but we can do that when we actually replace symbols, so we don't need
      to type as an argument. This change should simplify the interface of
      the symbol table a bit.
      
      llvm-svn: 344394
      f3fad557
    • Reid Kleckner's avatar
      [codeview] Emit S_BUILDINFO and LF_BUILDINFO with cwd and source file · 810687cb
      Reid Kleckner authored
      Summary: We can fill in the command line and compiler path later if we want.
      
      Reviewers: zturner
      
      Subscribers: hiraditya, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D53179
      
      llvm-svn: 344393
      810687cb
    • Andrea Di Biagio's avatar
      [llvm-mca] Correctly set aliases for register writes introduced by optimized register moves. · 6c17e802
      Andrea Di Biagio authored
      This fixes a problem introduced by r344334. A write from a non-zero move
      eliminated at register renaming stage was not correctly handled by the PRF. This
      would have led to an assertion failure if the processor model declares a PRF
      that enables non-zero move elimination.
      
      llvm-svn: 344392
      6c17e802
    • Jonathan Metzman's avatar
      [SanitizerCoverage] Prevent /OPT:REF from stripping constructors · 0b94e880
      Jonathan Metzman authored
      Summary:
      Linking with the /OPT:REF linker flag when building COFF files causes
      the linker to strip SanitizerCoverage's constructors. Prevent this by
      giving the constructors WeakODR linkage and by passing the linker a
      directive to include sancov.module_ctor.
      
      Include a test in compiler-rt to verify libFuzzer can be linked using
      /OPT:REF
      
      Reviewers: morehouse, rnk
      
      Reviewed By: morehouse, rnk
      
      Subscribers: rnk, morehouse, hiraditya
      
      Differential Revision: https://reviews.llvm.org/D52119
      
      llvm-svn: 344391
      0b94e880
    • Simon Pilgrim's avatar
      Fix MCBTF string array initialization so its MSVC friendly. NFCI. · f45bbd4c
      Simon Pilgrim authored
      llvm-svn: 344390
      f45bbd4c
    • Reid Kleckner's avatar
      Revert r344375 "[Driver] check for exit code from SIGPIPE" · 31859771
      Reid Kleckner authored
      This doesn't build on Windows.
      
      llvm-svn: 344389
      31859771
    • Jonas Toth's avatar
      [Doc] fix second error in UsersManual · 20ab6954
      Jonas Toth authored
      llvm-svn: 344388
      20ab6954
    • Fangrui Song's avatar
      [BPF] Use cstdint {,u}int*_t instead of linux/types.h __u32 __u16 ... · d15d6026
      Fangrui Song authored
      llvm-svn: 344387
      d15d6026
    • Stella Stamenova's avatar
      [lldbsuite] Fix the filecheck functionality to work with Python 3 · 073d21fa
      Stella Stamenova authored
      Summary: This is another string/byte conversion issue between Python 2 and 3. In Python 2, the subprocess communication expects a byte string, but in Python 3, it expects bytes. Since both versions are capable of using strings when universal_newlines is set to True AND filecheck operates on strings, force the use of strings.
      
      Reviewers: zturner, asmith, vsk
      
      Reviewed By: zturner
      
      Subscribers: lldb-commits
      
      Differential Revision: https://reviews.llvm.org/D53166
      
      llvm-svn: 344386
      073d21fa
    • Eric Liu's avatar
      Disambiguate: s/make_unique/llvm::make_unique/. NFC · 0916efc2
      Eric Liu authored
      llvm-svn: 344385
      0916efc2
    • Jonas Toth's avatar
      [clangd] NFC fix semicolon warning · f79f8eec
      Jonas Toth authored
      llvm-svn: 344384
      f79f8eec
    • Jonas Toth's avatar
      [Doc] fix BB, add code-block type · 30f6c631
      Jonas Toth authored
      llvm-svn: 344382
      30f6c631
    • Fangrui Song's avatar
      [BPF] Don't include linux/types.h and fix style · 19b8fa5c
      Fangrui Song authored
      llvm-svn: 344381
      19b8fa5c
    • Jonas Toth's avatar
      [doc] fix markup in clang-tidy bugprone-not-null-terminated-result · 60422354
      Jonas Toth authored
      llvm-svn: 344379
      60422354
    • Zachary Turner's avatar
      Fix another error related to YAML quoting. · 4b6f6007
      Zachary Turner authored
      This one occured in polly, which I didn't build / test the first
      time so I didn't catch it.
      
      llvm-svn: 344378
      4b6f6007
    • Zachary Turner's avatar
      Better support for POSIX paths in PDBs. · 5bba1caf
      Zachary Turner authored
      This a resubmission of a patch which was previously reverted
      due to breaking several lld tests.  The issues causing those
      failures have been fixed, so the patch is now resubmitted.
      
      ---Original Commit Message---
      
      While it doesn't make a *ton* of sense for POSIX paths to be
      in PDBs, it's possible to occur in real scenarios involving
      cross compilation.
      
      The tools need to be able to handle this, because certain types
      of debugging scenarios are possible without a running process
      and so don't necessarily require you to be on a Windows system.
      These include post-mortem debugging and binary forensics (e.g.
      using a debugger to disassemble functions and examine symbols
      without running the process).
      
      There's changes in clang, LLD, and lldb in this patch.  After
      this the cross-platform disassembly and source-list tests pass
      on Linux.
      
      Furthermore, the behavior of LLD can now be summarized by a much
      simpler rule than before: Unless you specify /pdbsourcepath and
      /pdbaltpath, the PDB ends up with paths that are valid within
      the context of the machine that the link is performed on.
      
      Differential Revision: https://reviews.llvm.org/D53149
      
      llvm-svn: 344377
      5bba1caf
    • Fangrui Song's avatar
      [BPF] Some fixes after rL344366 · 2c31e12d
      Fangrui Song authored
      * Move #include outside of namespaces
      * Add missing #include
      * Add out-of-line virtual destructor to BTFTypeEntry
      
      designated initializers should also be fixed
      
      llvm-svn: 344376
      2c31e12d
    • Nick Desaulniers's avatar
      [Driver] check for exit code from SIGPIPE · c7a3e4a4
      Nick Desaulniers authored
      Summary:
      D53000 adds a special exit code for SIGPIPE (writing to a closed
      reader), and rather than print a fatal warning, skips printing the
      error.  This can be seen commonly from piping into head, tee, or
      split.
      
      Fixes PR25349, rdar://problem/14285346, b/77310947.
      
      Reviewers: jfb
      
      Reviewed By: jfb
      
      Subscribers: cfe-commits, thakis, srhines
      
      Differential Revision: https://reviews.llvm.org/D53001
      
      llvm-svn: 344375
      c7a3e4a4
    • Jonas Toth's avatar
      [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length · 78886233
      Jonas Toth authored
      New checker called bugprone-not-null-terminated-result. This check finds function calls where it is possible to cause a not null-terminated result. Usually the proper length of a string is strlen(src) + 1 or equal length of this expression, because the null terminator needs an extra space. Without the null terminator it can result in undefined behaviour when the string is read.
      
      The following function calls are checked:
      memcpy, wmemcpy, memcpy_s, wmemcpy_s, memchr, wmemchr, memmove, wmemmove, memmove_s, wmemmove_s, memset, wmemset, strerror_s, strncmp, wcsncmp, strxfrm, wcsxfrm
      
      The following is a real-world example where the programmer forgot to increase the passed third argument, which is size_t length. That is why the length of the allocated memory is problematic too.
      
      static char *StringCpy(const std::string &str) {
        char *result = reinterpret_cast<char *>(malloc(str.size()));
        memcpy(result, str.data(), str.size());
        return result;
      }
      
      After running the tool fix-it rewrites all the necessary code according to the given options. If it is necessary, the buffer size will be increased to hold the null terminator.
      
      static char *StringCpy(const std::string &str) {
        char *result = reinterpret_cast<char *>(malloc(str.size() + 1));
        strcpy(result, str.data());
        return result;
      }
      
      Patch by Charusso.
      
      Differential ID: https://reviews.llvm.org/D45050
      
      llvm-svn: 344374
      78886233
    • Erik Pilkington's avatar
      [CodeGen] Handle extern references to OBJC_CLASS_$_* · 92d8a29c
      Erik Pilkington authored
      Some ObjC users declare a extern variable named OBJC_CLASS_$_Foo, then use it's
      address as a Class. I.e., one could define isInstanceOfF:
      
      BOOL isInstanceOfF(id c) {
        extern void OBJC_CLASS_$_F;
        return [c class] == (Class)&OBJC_CLASS_$_F;
      }
      
      This leads to asserts in clang CodeGen if there is an @implementation of F in
      the same TU as an instance of this pattern, because CodeGen assumes that a
      variable named OBJC_CLASS_$_* has the right type. This commit fixes the problem
      by RAUWing the old (incorrectly typed) global with a new global, then removing
      the old global.
      
      rdar://45077269
      
      Differential revision: https://reviews.llvm.org/D53154
      
      llvm-svn: 344373
      92d8a29c
    • Nick Desaulniers's avatar
      [Support] exit with custom return code for SIGPIPE · 727891c9
      Nick Desaulniers authored
      Summary:
      We tell the user to file a bug report on LLVM right now, and
      SIGPIPE isn't LLVM's fault so our error message is wrong.
      
      Allows frontends to detect SIGPIPE from writing to closed readers.
      This can be seen commonly from piping into head, tee, or split.
      
      Fixes PR25349, rdar://problem/14285346, b/77310947
      
      Reviewers: jfb
      
      Reviewed By: jfb
      
      Subscribers: majnemer, kristina, llvm-commits, thakis, srhines
      
      Differential Revision: https://reviews.llvm.org/D53000
      
      llvm-svn: 344372
      727891c9
    • Shafik Yaghmour's avatar
    • Louis Dionne's avatar
      [NFC][libc++] Fix broken link in comment · e2441bd2
      Louis Dionne authored
      llvm-svn: 344369
      e2441bd2
    • Rui Ueyama's avatar
      [lld] Add more complete support for the INCLUDE command. · 2e9d40d5
      Rui Ueyama authored
      Patch by Ian Tessier.
      
      This change adds INCLUDE support to the MEMORY and SECTION commands, and
      to output sections, as per:
      
      https://sourceware.org/binutils/docs/ld/File-Commands.html#File-Commands
      
      Differential Revision: https://reviews.llvm.org/D52951
      
      llvm-svn: 344368
      2e9d40d5
    • Dan Albert's avatar
      [Driver] Add defaults for Android ARM FPUs. · d0fbef9c
      Dan Albert authored
      Summary:
      Android mandates that devices have at least vfpv3-d16 until
      Marshmallow and NEON after that. Still honor the user's decision, but
      raise the defaults for Android targets.
      
      Reviewers: srhines, pirama, javed.absar, kristof.beyls, peter.smith
      
      Reviewed By: peter.smith
      
      Subscribers: peter.smith, rengolin, kristof.beyls, chrib, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D53121
      
      llvm-svn: 344367
      d0fbef9c
    • Yonghong Song's avatar
      [BPF] Add BTF generation for BPF target · 6c2327a0
      Yonghong Song authored
      BTF is the debug format for BPF, a kernel virtual machine
      and widely used for tracing, networking and security, etc ([1]).
      
      Currently only instruction streams are passed to kernel,
      the kernel verifier verifies them before execution. In order to
      provide better visibility of bpf programs to user space
      tools, some debug information, e.g., function names and
      debug line information are desirable for kernel so tools
      can get such information with better annotation
      for jited instructions for performance or other reasons.
      
      The dwarf is too complicated in kernel and for BPF.
      Hence, BTF is designed to be the debug format for BPF ([2]).
      Right now, pahole supports BTF for types, which
      are generated based on dwarf sections in the ELF file.
      
      In order to annotate performance metrics for jited bpf insns,
      it is necessary to pass debug line info to the kernel.
      Furthermore, we want to pass the actual code to the
      kernel because of the following reasons:
      
      . bpf program typically is small so storage overhead
        should be small.
      . in bpf land, it is totally possible that
        an application loads the bpf program into the
        kernel and then that application quits, so
        holding debug info by the user space application
        is not practical.
      . having source codes directly kept by kernel
        would ease deployment since the original source
        code does not need ship on every hosts and
        kernel-devel package does not need to be
        deployed even if kernel headers are used.
      
      The only reliable time to get the source code is
      during compilation time. This will result in both more
      accurate information and easier deployment as
      stated in the above.
      
      Another consideration is for JIT. The project like bcc
      use MCJIT to compile a C program into bpf insns and
      load them to the kernel ([3]). The generated BTF sections
      will be readily available for such cases as well.
      
      This patch implemented generation of BTF info in llvm
      compiler. The BTF related sections will be generated
      when both -target bpf and -g are specified. Two sections
      are generated:
        .BTF contains all the type and string information, and
        .BTF.ext contains the func_info and line_info.
      
      The separation is related to how two sections are used
      differently in bpf loader, e.g., linux libbpf ([4]).
      The .BTF section can be loaded into the kernel directly
      while .BTF.ext needs loader manipulation before loading
      to the kernel. The format of the each section is roughly
      defined in llvm:include/llvm/MC/MCBTFContext.h and
      from the implementation in llvm:lib/MC/MCBTFContext.cpp.
      A later example also shows the contents in each section.
      
      The type and func_info are gathered during CodeGen/AsmPrinter
      by traversing dwarf debug_info. The line_info is
      gathered in MCObjectStreamer before writing to
      the object file. After all the information is gathered,
      the two sections are emitted in MCObjectStreamer::finishImpl.
      
      With cmake CMAKE_BUILD_TYPE=Debug, the compiler can
      dump out all the tables except insn offset, which
      will be resolved later as relocation records.
      The debug type "btf" is used for BTFContext dump.
      
      Dwarf tests the debug info generation with
      llvm-dwarfdump to decode the binary sections and
      check whether the result is expected. Currently
      we do not have such a tool yet. We will implement
      btf dump functionality in bpftool ([5]) as the bpftool is
      considered the recommended tool for bpf introspection.
      The implementation for type and func_info is tested
      with linux kernel test cases. The line_info is visually
      checked with dump from linux kernel libbpf ([4]) and
      checked with readelf dumping section raw data.
      
      Note that the .BTF and .BTF.ext information will not
      be emitted to assembly code and there is no assembler
      support for BTF either.
      
      In the below, with a clang/llvm built with CMAKE_BUILD_TYPE=Debug,
      Each table contents are shown for a simple C program.
      
        -bash-4.2$ cat -n test.c
           1  struct A {
           2    int a;
           3    char b;
           4  };
           5
           6  int test(struct A *t) {
           7    return t->a;
           8  }
        -bash-4.2$ clang -O2 -target bpf -g -mllvm -debug-only=btf -c test.c
        Type Table:
        [1] FUNC name_off=1 info=0x0c000001 size/type=2
              param_type=3
        [2] INT name_off=12 info=0x01000000 size/type=4
              desc=0x01000020
        [3] PTR name_off=0 info=0x02000000 size/type=4
        [4] STRUCT name_off=16 info=0x04000002 size/type=8
              name_off=18 type=2 bit_offset=0
              name_off=20 type=5 bit_offset=32
        [5] INT name_off=22 info=0x01000000 size/type=1
              desc=0x02000008
      
        String Table:
        0 :
        1 : test
        6 : .text
        12 : int
        16 : A
        18 : a
        20 : b
        22 : char
        27 : test.c
        34 : int test(struct A *t) {
        58 :   return t->a;
      
        FuncInfo Table:
        sec_name_off=6
              insn_offset=<Omitted> type_id=1
      
        LineInfo Table:
        sec_name_off=6
              insn_offset=<Omitted> file_name_off=27 line_off=34 line_num=6 column_num=0
              insn_offset=<Omitted> file_name_off=27 line_off=58 line_num=7 column_num=3
        -bash-4.2$ readelf -S test.o
        ......
          [12] .BTF              PROGBITS         0000000000000000  0000028d
             00000000000000c1  0000000000000000           0     0     1
          [13] .BTF.ext          PROGBITS         0000000000000000  0000034e
             0000000000000050  0000000000000000           0     0     1
          [14] .rel.BTF.ext      REL              0000000000000000  00000648
             0000000000000030  0000000000000010          16    13     8
        ......
        -bash-4.2$
      
      The latest linux kernel ([6]) can already support .BTF with type information.
      The [7] has the reference implementation in linux kernel side
      to support .BTF.ext func_info. The .BTF.ext line_info support is not
      implemented yet. If you have difficulty accessing [6], you can
      manually do the following to access the code:
      
        git clone https://github.com/yonghong-song/bpf-next-linux.git
        cd bpf-next-linux
        git checkout btf
      
      The change will push to linux kernel soon once this patch is landed.
      
      References:
      [1]. https://www.kernel.org/doc/Documentation/networking/filter.txt
      [2]. https://lwn.net/Articles/750695/
      [3]. https://github.com/iovisor/bcc
      [4]. https://github.com/torvalds/linux/tree/master/tools/lib/bpf
      [5]. https://github.com/torvalds/linux/tree/master/tools/bpf/bpftool
      [6]. https://github.com/torvalds/linux
      [7]. https://github.com/yonghong-song/bpf-next-linux/tree/btf
      
      
      
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      
      Differential Revision: https://reviews.llvm.org/D52950
      
      llvm-svn: 344366
      6c2327a0
    • Michal Gorny's avatar
      [tests] Readd Python binding tests to check-all · e67b68f3
      Michal Gorny authored
      Now that both issues found out during the last iteration have been
      fixed, reenable the Python binding tests on buildbots.
      
      llvm-svn: 344365
      e67b68f3
    • Michal Gorny's avatar
      [python] [tests] Remove cdb lookup failure test · 4fc27bd9
      Michal Gorny authored
      Remove the test checking for compilation db lookup failure.
      Since r342228, JSONCompilationDatabasePlugin infers compile commands for
      missing files, therefore making the lookup always succeed.
      
      Differential Revision: https://reviews.llvm.org/D53202
      
      llvm-svn: 344364
      4fc27bd9