Skip to content
  1. Nov 17, 2016
  2. Nov 16, 2016
    • Kevin Enderby's avatar
      General clean up of error handling in llvm-objdump to remove its use of report_fatal_error(). · 7fa40c9f
      Kevin Enderby authored
      No real functional change with this commit.
      
      The problem with report_fatal_error() is it does not include the tool name
      and the file name the for which the error message was generated.
      
      Uses of report_fatal_error() were change to report_error() or error()
      to get a better error and to make the code smaller and cleaner.
      
      Also changed things like error(errorToErrorCode(SOrErr.takeError())) to
      use report_error() with a file name and the llvm::Error (as well as the
      ArchitectureName if available) so the error message is printed.
      
      llvm-svn: 287163
      7fa40c9f
    • Vitaly Buka's avatar
      Fix "isn't a prototype" warning · e596986a
      Vitaly Buka authored
      llvm-svn: 287161
      e596986a
    • Davide Italiano's avatar
      [ELF] Convert ELF.h to Expected<T>. · 6cf09265
      Davide Italiano authored
      This has two advantages:
      1) We slowly move away from ErrorOr to the new handling interface,
      in the hope of having an uniform error handling in LLVM, eventually.
      2) We're starting to have *meaningful* error messages for invalid
      object ELF files, rather than a generic "parse error". At some point
      we should include also the offset to improve the quality of the
      diagnostic.
      
      llvm-svn: 287081
      6cf09265
    • Richard Smith's avatar
      Fix build break when the host C compiler is C89. · 6b335d19
      Richard Smith authored
      llvm-svn: 287075
      6b335d19
    • Kevin Enderby's avatar
      General clean up of Mach-O error handling in llvm-objdump. · 844c4ac5
      Kevin Enderby authored
      To get a good error message for all files that could contain Mach-O
      files the code in llvm-objdump needs to use the archive member name
      and name of the architecture of a slice of a universal file in those cases
      where the error come from a Mach-O file in an archive or a universal file.
      
      Most of this is fixed by moving the call to checkSymbolTable() into
      ProcessMachO() and calling it when the operation needs the symbol
      table.  And then calling the form of report_error() that has the
      ArchiveName and ArchitectureName arguments.  One other place
      needed to call this form of report_error() also with these arguments.
      
      Also changed the code in MachODump.cpp to not use report_fatal_error()
      and use report_error() instead to make the code smaller and cleaner.  All
      cases of this are for errors with the symbol table which should now never
      be tripped since checkSymbolTable() should be called first to get a good
      error message in these cases.
      
      llvm-svn: 287050
      844c4ac5
  3. Nov 15, 2016
    • Amaury Sechet's avatar
      [C API] Prevent nullptr dereferences in C API for counting attributes. · 003216b3
      Amaury Sechet authored
      See https://reviews.llvm.org/D26392
      
      Patch by @maleadt
      
      llvm-svn: 287044
      003216b3
    • Tim Northover's avatar
      llvm-objdump: deal with unexpected object files more gracefully. · bf55f7ea
      Tim Northover authored
      Specifically, we don't want to segfault on release builds, so print the problem
      instead.
      
      llvm-svn: 287022
      bf55f7ea
    • Greg Clayton's avatar
      Improve DWARF parsing speed by improving DWARFAbbreviationDeclaration · 6f6e4dbd
      Greg Clayton authored
      This patch gets a DWARF parsing speed improvement by having DWARFAbbreviationDeclaration instances know if they have a fixed byte size. If an abbreviation has a fixed byte size that can be calculated given a DWARFUnit, then parsing a DIE becomes two steps: parse ULEB128 abbrev code, and then add constant size to the offset.
      
      This patch also adds a fixed byte size to each DWARFAbbreviationDeclaration::AttributeSpec so that attributes can quickly skip their values if needed without the need to lookup the fixed for size.
      
      Notable improvements:
      
      - DWARFAbbreviationDeclaration::findAttributeIndex() now returns an Optional<uint32_t> instead of a uint32_t and we no longer have to look for the magic -1U return value
      - Optional<uint32_t> DWARFAbbreviationDeclaration::findAttributeIndex(dwarf::Attribute attr) const;
      - DWARFAbbreviationDeclaration now has a getAttributeValue() function that extracts an attribute value given a DIE offset that takes advantage of the DWARFAbbreviationDeclaration::AttributeSpec::ByteSize
      - bool DWARFAbbreviationDeclaration::getAttributeValue(const uint32_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U, DWARFFormValue &FormValue) const;
      - A DWARFAbbreviationDeclaration instance can return a fixed byte size for itself so DWARF parsing is faster:
      - Optional<size_t> DWARFAbbreviationDeclaration::getFixedAttributesByteSize(const DWARFUnit &U) const;
      - Any functions that used to take a "const DWARFUnit *U" that would crash if U was NULL now take a "const DWARFUnit &U" and are only called with a valid DWARFUnit
      
      Differential Revision: https://reviews.llvm.org/D26567
      
      llvm-svn: 286924
      6f6e4dbd
    • Saleem Abdulrasool's avatar
      llvm-strings: support the `-n` option · f7009b42
      Saleem Abdulrasool authored
      Permit specifying the match length (the `-n` or `--bytes` option).  The
      deprecated `-[length]` form is not supported as an option.  This allows the
      strings tool to display only the specified length strings rather than the
      hardcoded default length of >= 4.
      
      llvm-svn: 286914
      f7009b42
  4. Nov 14, 2016
    • Saleem Abdulrasool's avatar
      Revert "Revert "llvm-strings: support printing the filename"" · f10a8714
      Saleem Abdulrasool authored
      Change the dynamic files to static in the hope that it will actually fix the
      transient errors that Ive been unable to reproduce.
      
      llvm-svn: 286891
      f10a8714
    • Kevin Enderby's avatar
      Add a checkSymbolTable() method to the MachOObjectFile class. · 22fc0078
      Kevin Enderby authored
      The philosophy of the error checking in libObject for Mach-O files
      is that the constructor will check the load commands so for their
      tables the offsets and sizes are properly contained in the file.
      But there is no checking of the entries of any of the tables.
      
      For the contents of the tables themselves the methods accessing
      the contents of the entries return errors as needed.  In some
      cases this however makes it difficult or cumbersome to produce
      a good error message which would include the tool name, file name,
      archive member, and name of the architecture of a slice of a universal file
      the error occurred in.
      
      So idea is that there will be a method to check a table which can
      be called up front before using it allowing a good error message
      to be produced before a table is used.  And if only verification of
      the Mach-O file and its tables are wanted a new possible method
      checkAllTables() could be added to call all of the methods to
      check all the tables at some time when such methods exist.
      
      The checkSymbolTable() is the first of such methods to check
      one of the Mach-O file tables.  This method initially will used in
      llvm-objdump’s DisassembleMachO() routine before it gets the
      section and symbol information.  As if there are problems with
      the symbol table currently the error is first encountered by the
      bool operator() in the SymbolSorter() struct which passed to
      std::sort().  In this case there is no context as to the file name
      the symbol which results a poor error message:
      
      LLVM ERROR: truncated or malformed object (bad string index: 22 for symbol at index 1)
      
      with the added call to the checkSymbolTable() method the
      error message includes the tool name and file name:
      
      llvm-objdump: 'macho-invalid-symbol-strx': truncated or malformed object (bad string table index: 22 past the end of string table, for symbol at index 1)
      llvm-svn: 286887
      22fc0078
    • Teresa Johnson's avatar
      [ThinLTO] Only promote exported locals as marked in index · 4fef68cb
      Teresa Johnson authored
      Summary:
      We have always speculatively promoted all renamable local values
      (except const non-address taken variables) for both the exporting
      and importing module. We would then internalize them back based on
      the ThinLink results if they weren't actually exported. This is
      inefficient, and results in unnecessary renames. It also meant we
      had to check the non-renamability of a value in the summary, which
      was already checked during function importing analysis in the ThinLink.
      
      Made renameModuleForThinLTO (which does the promotion/renaming) instead
      use the index when exporting, to avoid unnecessary renames/promotions.
      For importing modules, we can simply promoted all values as any local
      we import by definition is exported and needs promotion.
      
      This required changes to the method used by the FunctionImport pass
      (only invoked from 'opt' for testing) and when invoked from llvm-link,
      since neither does a ThinLink. We simply conservatively mark all locals
      in the index as promoted, which preserves the current aggressive
      promotion behavior.
      
      I also needed to change an llvm-lto based test where we had previously
      been aggressively promoting values that weren't importable (aliasees),
      but now will not promote.
      
      Reviewers: mehdi_amini
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D26467
      
      llvm-svn: 286871
      4fef68cb
    • Teresa Johnson's avatar
      Restore "[ThinLTO] Prevent exporting of locals used/defined in module level asm" · 3624bdf6
      Teresa Johnson authored
      This restores the rest of r286297 (part was restored in r286475).
      Specifically, it restores the part requiring adding a dependency from
      the Analysis to Object library (downstream use changed to correctly
      model split BitReader vs BitWriter libraries).
      
      Original description of this part of patch follows:
      
      Module level asm may also contain defs of values. We need to prevent
      export of any refs to local values defined in module level asm (e.g. a
      ref in normal IR), since that also requires renaming/promotion of the
      local. To do that, the summary index builder looks at all values in the
      module level asm string that are not marked Weak or Global, which is
      exactly the set of locals that are defined. A summary is created for
      each of these local defs and flagged as NoRename.
      
      This required adding handling to the BitcodeWriter to look at GV
      declarations to see if they have a summary (rather than skipping them
      all).
      
      Finally, added an assert to IRObjectFile::CollectAsmUndefinedRefs to
      ensure that an MCAsmParser is available, otherwise the module asm parse
      would silently fail. Initialized the asm parser in the opt tool for use
      in testing this fix.
      
      Fixes PR30610.
      
      llvm-svn: 286844
      3624bdf6
    • Renato Golin's avatar
      Revert "llvm-strings: support printing the filename" · 199b6b94
      Renato Golin authored
      Also,
      
      Revert "test: remove the archive before modifying it"
      Revert "test: explicitly use gnu format"
      
      This reverts commits r286778, r286729 and r286767, as they are randomly failing
      on many bots (AArch64, x86_64).
      
      llvm-svn: 286820
      199b6b94
  5. Nov 13, 2016
  6. Nov 12, 2016
  7. Nov 11, 2016
    • Lang Hames's avatar
      [ORC] Re-apply 286620 with fixes for the ErrorSuccess class. · 1f2bf2d3
      Lang Hames authored
      llvm-svn: 286639
      1f2bf2d3
    • Peter Collingbourne's avatar
      6de481a3
    • Peter Collingbourne's avatar
      Bitcode: Clean up error handling for certain bitcode query functions. · cd513a41
      Peter Collingbourne authored
      The functions getBitcodeTargetTriple(), isBitcodeContainingObjCCategory(),
      getBitcodeProducerString() and hasGlobalValueSummary() now return errors
      via their return value rather than via the diagnostic handler.
      
      To make this work, re-implement these functions using non-member functions
      so that they can be used without the LLVMContext required by BitcodeReader.
      
      Differential Revision: https://reviews.llvm.org/D26532
      
      llvm-svn: 286623
      cd513a41
    • Lang Hames's avatar
      [ORC] Revert r286620 while I investigate a bot failure. · 4f734f25
      Lang Hames authored
      llvm-svn: 286621
      4f734f25
    • Lang Hames's avatar
      [ORC] Refactor the ORC RPC utilities to add some new features. · ae1fdddb
      Lang Hames authored
      (1) Add support for function key negotiation.
      
      The previous version of the RPC required both sides to maintain the same
      enumeration for functions in the API. This means that any version skew between
      the client and server would result in communication failure.
      
      With this version of the patch functions (and serializable types) are defined
      with string names, and the derived function signature strings are used to
      negotiate the actual function keys (which are used for efficient call
      serialization). This allows clients to connect to any server that supports a
      superset of the API (based on the function signatures it supports).
      
      (2) Add a callAsync primitive.
      
      The callAsync primitive can be used to install a return value handler that will
      run as soon as the RPC function's return value is sent back from the remote.
      
      (3) Launch policies for RPC function handlers.
      
      The new addHandler method, which installs handlers for RPC functions, takes two
      arguments: (1) the handler itself, and (2) an optional "launch policy". When the
      RPC function is called, the launch policy (if present) is invoked to actually
      launch the handler. This allows the handler to be spawned on a background
      thread, or added to a work list. If no launch policy is used, the handler is run
      on the server thread itself. This should only be used for short-running
      handlers, or entirely synchronous RPC APIs.
      
      (4) Zero cost cross type serialization.
      
      You can now define serialization from any type to a different "wire" type. For
      example, this allows you to call an RPC function that's defined to take a
      std::string while passing a StringRef argument. If a serializer from StringRef
      to std::string has been defined for the channel type this will be used to
      serialize the argument without having to construct a std::string instance.
      
      This allows buffer reference types to be used as arguments to RPC calls without
      requiring a copy of the buffer to be made.
      
      llvm-svn: 286620
      ae1fdddb
    • Greg Clayton's avatar
      Clean up DWARFFormValue by reducing duplicated code and removing... · 82f12b14
      Greg Clayton authored
      Clean up DWARFFormValue by reducing duplicated code and removing DWARFFormValue::getFixedFormSizes()
      
      In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64.
      
      This patch cleans up code so that everyone is using one of the new DWARFFormValue functions:
      
      static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr);
      static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32);
      
      This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form.
      
      This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64.
      
      To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values.
      
      https://reviews.llvm.org/D26526
      
      llvm-svn: 286597
      82f12b14
    • NAKAMURA Takumi's avatar
      llvm-strings: Fix r286556 to add required libraries. · 8c140e04
      NAKAMURA Takumi authored
      llvm-svn: 286594
      8c140e04
    • Mehdi Amini's avatar
      Fix gold plugin after Error API changes · 48f29605
      Mehdi Amini authored
      llvm-svn: 286571
      48f29605
    • Teresa Johnson's avatar
      Split Bitcode/ReaderWriter.h into separate reader and writer headers · ad17679a
      Teresa Johnson authored
      Summary:
      Split ReaderWriter.h which contains the APIs into both the BitReader and
      BitWriter libraries into BitcodeReader.h and BitcodeWriter.h.
      
      This is to address Chandler's concern about sharing the same API header
      between multiple libraries (BitReader and BitWriter). That concern is
      why we create a single bitcode library in our downstream build of clang,
      which led to r286297 being reverted as it added a dependency that
      created a cycle only when there is a single bitcode library (not two as
      in upstream).
      
      Reviewers: mehdi_amini
      
      Subscribers: dlj, mehdi_amini, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D26502
      
      llvm-svn: 286566
      ad17679a
    • Mehdi Amini's avatar
      Fix build failure, update llvm-strings for the new Error API · 2aad0461
      Mehdi Amini authored
      llvm-svn: 286563
      2aad0461
    • Mehdi Amini's avatar
      Make the Error class constructor protected · 41af4309
      Mehdi Amini authored
      This is forcing to use Error::success(), which is in a wide majority
      of cases a lot more readable.
      
      Differential Revision: https://reviews.llvm.org/D26481
      
      llvm-svn: 286561
      41af4309
    • Saleem Abdulrasool's avatar
      llvm-strings: explicitly include cctype · 2dcea63b
      Saleem Abdulrasool authored
      Include the cctype header to try to fix windows bots.
      
      llvm-svn: 286558
      2dcea63b
    • Saleem Abdulrasool's avatar
      llvm-strings: introduce basic strings tool · 030ff0f2
      Saleem Abdulrasool authored
      This is a replacement to binutils' string tool.  It prints strings found in a
      binary (object file, executable, or archive library).  It is rather bare and
      not functionally equivalent, however, it lays the groundwork necessary for the
      strings tool, enabling iterative development of features to reach feature
      parity.
      
      llvm-svn: 286556
      030ff0f2
  8. Nov 09, 2016
Loading