Commit Graph

2229 Commits

Author SHA1 Message Date
Saleem Abdulrasool 3f44cd7926 MC: change runtime check to an assertion
It is unclear how it would be possible to get M to be NULL in normal scenarios.
Change this to an assert rather than a runtime check as per dblakie's
suggestion.

llvm-svn: 204060
2014-03-17 17:13:57 +00:00
Saleem Abdulrasool 11543a9953 ARM IAS: support .thumb_set
This performs the equivalent of a .set directive in that it creates a symbol
which is an alias for another symbol or value which may possibly be yet
undefined.  This directive also has the added property in that it marks the
aliased symbol as being a thumb function entry point, in the same way that the
.thumb_func directive does.

The current implementation fails one test due to an unrelated issue.  Functions
within .thumb sections are not marked as thumb_func.  The result is that
the aliasee function is not valued correctly.

llvm-svn: 204059
2014-03-17 17:13:54 +00:00
Alexey Samsonov 464d2e448b [C++11] Introduce ObjectFile::symbols() to use range-based loops.
Reviewers: rafael

Reviewed By: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3081

llvm-svn: 204031
2014-03-17 07:28:19 +00:00
Rafael Espindola f863a3e2ec Consider the base pointer for setting the symbol type.
This is really a consistency fix. Since given

a = b

we propagate the information, we should propagate it too given

a = b + (1 - 1)

Fixes pr19145.

llvm-svn: 204028
2014-03-17 04:29:51 +00:00
David Blaikie c714ef4581 DebugInfo: Improve reuse of file table entries in asm debug info
The previous deduping strategy was woefully inadequate - it only
considered the most recent file used and avoided emitting a duplicate in
that case - never considering the a/b/a scenario.

It was also lacking when it came to directory paths as the previous
filename would never match the current if the filename had been split
into file and directory components.

This change builds caching functionality into the line table at the
lowest level in an optional form (a file number of 0 indicates that one
should be chosen and returned) and will eventually be reused by the
normal source level debugging DWARF emission.

llvm-svn: 204027
2014-03-17 01:52:11 +00:00
Jim Grosbach 9a3284fb2f MC: don't create a backtrace for diagnostics.
For better or worse, this is currently the normal error reporting path
when dealing with backend errors from inline assembly. It's not just
internal compiler issues that come through here, so we shouldn't be
creating a backtrace on this path.

rdar://16329947

llvm-svn: 203979
2014-03-14 22:41:58 +00:00
David Blaikie bfdb81dc2d MCContext: Remove redundant assignment
The member variable is not initialized in the ctor so it's already
empty. No need to empty it again.

llvm-svn: 203963
2014-03-14 20:09:26 +00:00
Rafael Espindola 8953f81f67 Correctly handle an ELF symbol defined with "a = b + expr".
We were marking the symbol as absolute instead of computing b's offset + the
expression value.

This fixes pr19126.

llvm-svn: 203962
2014-03-14 20:09:04 +00:00
Alexey Samsonov aa4d29571c [C++11] Introduce SectionRef::relocations() to use range-based loops
Reviewers: rafael

Reviewed By: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3077

llvm-svn: 203927
2014-03-14 14:22:49 +00:00
David Blaikie d9012ba118 MCDwarf: Rename MCDwarfFileTable to MCDwarfLineTable
This type now represents all the data for the DWARF line table:
directory names, file names, and the line table proper.

llvm-svn: 203858
2014-03-13 21:59:51 +00:00
David Blaikie 5cff0e6a81 MCDwarf: Extract the DWARF line table header handling into its own type
llvm-svn: 203856
2014-03-13 21:47:12 +00:00
David Blaikie 498589c3fd MCDwarf: Sink file/directory creation down into MCDwarfFileTable form MCContext
llvm-svn: 203836
2014-03-13 19:15:04 +00:00
David Blaikie 533490de63 MCDwarf: Oh, and move the directory string over to std::string as well
(see r203831 for similar stuff)

llvm-svn: 203833
2014-03-13 19:05:33 +00:00
David Blaikie a55ddad134 MCDwarf: Simplify MCDwarfFile to just use std::string instead of cunning use of MCContext's allocator.
There aren't /that/ many files, and we are already using various maps
and other standard containers that don't use MCContext's allocator to
store these values, so this doesn't seem to be critical and simplifies
the design (I'll be moving construction out of MCContext shortly so it'd
be annoying to have to pass the allocator around to allocate these
things... and we'll have non-MCContext users (debug_line.dwo) shortly)

llvm-svn: 203831
2014-03-13 18:55:04 +00:00
David Blaikie 639f8ea397 MCDwarf: Simply MCDwarfFile since it really is just a StringRef and unsigned.
llvm-svn: 203827
2014-03-13 18:21:24 +00:00
Rafael Espindola 4269b9eed5 Use printable names to implement directional labels.
This changes the implementation of local directional labels to use a dedicated
map. With that it can then just use CreateTempSymbol, which is what the rest
of MC uses.

CreateTempSymbol doesn't do a great job at making sure the names are unique
(or being efficient when the names are not needed), but that should probably
be fixed in a followup patch.

This fixes pr18928.

llvm-svn: 203826
2014-03-13 18:09:26 +00:00
David Blaikie f4a640eaf6 Remove stale comment
llvm-svn: 203823
2014-03-13 17:58:09 +00:00
David Blaikie 11765bce2d MCDwarf: Refactor line table handling into a single data structure
This replaces several "compile unit ID -> thing" mappings in favor of
one mapping from CUID to the whole line table structure (files,
directories, and lines).

This is another step along the way to refactoring out reusable
components of line table handling for use when generating debug_line.dwo
for fission type units.

Also, might be a good basis to fold some of this handling down into
MCStreamers to avoid the special case of "One line table when doing asm
printing, line table per CU otherwise" by building it into the different
MCStreamer implementations.

llvm-svn: 203821
2014-03-13 17:55:28 +00:00
Alexey Samsonov 063eb3fa2d [C++11] Introduce ObjectFile::sections().
Summary:
This adds ObjectFile::section_iterator_range, that allows to write
range-based for-loops running over all sections of a given file.
Several files from lib/ are converted to the new interface. Similar fixes
should be applied to a variety of llvm-* tools.

Reviewers: rafael

Reviewed By: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3069

llvm-svn: 203799
2014-03-13 13:52:54 +00:00
Saleem Abdulrasool 324133910a MC: fix silly typo
llvm-svn: 203763
2014-03-13 07:02:46 +00:00
Saleem Abdulrasool ac58e9fc0b MC: fix possible NULL pointer dereference
Avoid NULL pointer scenario found via clang's static analyzer.

llvm-svn: 203745
2014-03-13 02:09:51 +00:00
David Blaikie f4ad698336 MCDwarf: Remove unused parameter
llvm-svn: 203727
2014-03-12 22:35:23 +00:00
David Blaikie a55e64f84a MCDwarf: Invert the Section+CU->LineEntries mapping so the CU is the primary dimension
This makes the mapping consistent with other CU->X mappings in the
MCContext, helping pave the way to refactor all these values into a
single data structure per CU and thus a single map.

I haven't renamed the data structure as that would make the patch churn
even higher (the MCLineSection name no longer makes sense, as this
structure now contains lines for multiple sections covered by a single
CU, rather than lines for a single section in multiple CUs) and further
refactorings will follow that may remove this type entirely.

For convenience, I also gave the MCLineSection value semantics so we
didn't have to do the lazy construction, manual delete, etc.

(& for those playing at home, refactoring the line printing into a
single data structure will eventually alow that data structure to be
reused to own the debug_line.dwo line table used for type unit file name
resolution)

llvm-svn: 203726
2014-03-12 22:28:56 +00:00
David Blaikie c47d084650 Correct typo ("a entry" -> "an entry")
llvm-svn: 203678
2014-03-12 16:56:05 +00:00
Rafael Espindola 3d5d464df8 Try harder to evaluate expressions when printing assembly.
When printing assembly we don't have a Layout object, but we can still
try to fold some constants.

Testcase by Ulrich Weigand.

llvm-svn: 203677
2014-03-12 16:55:59 +00:00
Rafael Espindola a063bdde8d Simplify a really complicated check for Arch == X86_64.
The function hasReliableSymbolDifference had exactly one use in the MachO
writer. It is also only true for X86_64. In fact, the comments refers to
"Darwin x86_64" and everything else, so this makes the code match the
comment.

If this is to be abstracted again, it should be a property of
TargetObjectWriter, like useAggressiveSymbolFolding.

llvm-svn: 203605
2014-03-11 21:22:57 +00:00
David Majnemer 596587f6d0 MC: Appease the buildbots
This is fallout from r203429.

llvm-svn: 203430
2014-03-10 01:04:18 +00:00
David Majnemer e500ec1f3a MC: Cleanup MCSectionMachO::ParseSectionSpecifier
Split by comma once instead of multiple times.  Moving this upfront
makes the rest of the code considerably simpler.

No functional change.

llvm-svn: 203429
2014-03-10 00:55:07 +00:00
Craig Topper 59be68f05f [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203342
2014-03-08 07:14:16 +00:00
Craig Topper 12f0ca454b De-virtualize a method since it doesn't override anything (yay 'override' keyword) and its class is in an anonymous namespace.
llvm-svn: 203341
2014-03-08 07:07:08 +00:00
Craig Topper 34a61bc97a [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203340
2014-03-08 07:02:02 +00:00
David Majnemer cd481d3845 MC: Use MachO::SectionType for MCSectionMachO::getType's return type
This is a straightfoward replacement, it makes debugging a little
easier.

This has no functional impact.

llvm-svn: 203264
2014-03-07 18:49:54 +00:00
Ahmed Charles df17c83fa8 Change MCDisassembler::setSymbolizer to take unique_ptr by value.
This changes the interface to be more explicit that ownership is being
transferred.

llvm-svn: 203223
2014-03-07 09:38:02 +00:00
David Majnemer 7b58305ff6 MC: Remove superfluous section attribute flag definitions
Summary:
llvm/MC/MCSectionMachO.h and llvm/Support/MachO.h both had the same
definitions for the section flags.  Instead, grab the definitions out of
support.

No functionality change.

Reviewers: grosbach, Bigcheese, rafael

Reviewed By: rafael

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2998

llvm-svn: 203211
2014-03-07 07:36:05 +00:00
Saleem Abdulrasool 5715e522ac Reapply "MC: simplify object file selection for Windows"
That was overly aggressive in assuming that we could always assume COFF.  Some
of the tests assume that they will get ELF rather than COFF even on Windows
where the default is COFF.

llvm-svn: 203176
2014-03-06 23:02:15 +00:00
Ted Kremenek 297febee57 Remove unreachable 'return true' always dominated by 'return Error' or 'return false'.
llvm-svn: 203171
2014-03-06 22:13:17 +00:00
Saleem Abdulrasool 35476334e9 Support: split object format out of environment
This is a preliminary setup change to support a renaming of Windows target
triples.  Split the object file format information out of the environment into a
separate entity.  Unfortunately, file format was previously treated as an
environment with an unknown OS.  This is most obvious in the ARM subtarget where
the handling for macho on an arbitrary platform switches to AAPCS rather than
APCS (as per Apple's needs).

llvm-svn: 203160
2014-03-06 20:47:11 +00:00
Saleem Abdulrasool 0b5569972f MC: simplify object file selection for Windows
Windows always uses COFF unless Windows ELF is in use.  Rather than checking if
Windows, MinGW, or Cygwin is being targeted, just check if the target OS is
windows and that it is not an ELF environment.

llvm-svn: 203159
2014-03-06 20:47:03 +00:00
Reid Kleckner 94a1c4d3f1 MS asm: The initial dot in struct access is optional
Fixes PR18994.

Tests, once again, in that other repository.  =P

llvm-svn: 203146
2014-03-06 19:19:12 +00:00
Ahmed Charles 56440fd820 Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

llvm-svn: 203083
2014-03-06 05:51:42 +00:00
Rafael Espindola 8377085657 Always print the implicit .text at the start of an asm file.
Before llvm-mc would print it, but llc was assuming that it would produce
another section changing directive before one was needed. That assumption is
false with inline asm.

Fixes PR19049.

Another option would be to always create the section, but in the asm printer
avoid printing sections changes during initialization. That would work, but
* We do use the fact that llvm-mc prints it in testing. The tests can be changed
  if needed.
* A quick poll on IRC suggest that most developers prefer the implicit .text to
  be printed.

llvm-svn: 203001
2014-03-05 20:09:15 +00:00
Ahmed Charles fba066461f [C++11] Add overloads for externally used OwningPtr functions.
This will allow external callers of these functions to switch over time
rather than forcing a breaking change all a once. These particular
functions were determined by building clang/lld/lldb.

llvm-svn: 202959
2014-03-05 10:27:34 +00:00
Ahmed Charles 96c9d95f51 [C++11] Replace OwningPtr::take() with OwningPtr::release().
llvm-svn: 202957
2014-03-05 10:19:29 +00:00
Benjamin Kramer b6d0bd48bd [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.
Remove the old functions.

llvm-svn: 202636
2014-03-02 12:27:27 +00:00
Craig Topper 73156025e0 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202621
2014-03-02 09:09:27 +00:00
Venkatraman Govindaraju bf70566a45 Add support for parsing sun-style section flags in ELFAsmParser.
llvm-svn: 202573
2014-03-01 06:21:00 +00:00
Rafael Espindola 8837995b52 Remove MCPureStreamer.
We moved MCJIT to use native object formats a long time ago and R600
now uses ELF, so it was dead.

llvm-svn: 202408
2014-02-27 16:17:34 +00:00
Nico Rieck 01143f9a51 Reuse constants for COFF string table entry offsets
llvm-svn: 202130
2014-02-25 09:50:40 +00:00
Rafael Espindola 90c7f1cc16 Replace the F_Binary flag with a F_Text one.
After this I will set the default back to F_None. The advantage is that
before this patch forgetting to set F_Binary would corrupt a file on windows.
Forgetting to set F_Text produces one that cannot be read in notepad, which
is a better failure mode :-)

llvm-svn: 202052
2014-02-24 18:20:12 +00:00
Saleem Abdulrasool 7ecc549724 Asm Parser: support .error directive
The .error directive is similar to .err in that it will halt assembly if it is
evaluated for assembly.  However, it permits a user supplied message to be
rendered.

llvm-svn: 201999
2014-02-23 23:02:23 +00:00