Commit Graph

2466 Commits

Author SHA1 Message Date
Saleem Abdulrasool 1e76cbdff7 MC: modernise for loop
Convert a for loop to range bsaed form.  NFC.

llvm-svn: 212684
2014-07-10 04:50:09 +00:00
Saleem Abdulrasool 427c08d48b MC: add and use an accessor for WinCFI
This adds a utility method to access the WinCFI information in bulk and uses
that to iterate rather than requesting the count and individually iterating
them.  This is in preparation for restructuring WinCFI handling to enable more
clear sharing across architectures to enable unwind information emission for
Windows on ARM.

llvm-svn: 212683
2014-07-10 04:50:06 +00:00
Vladimir Medic fb8a2a95cd Mips.abiflags is a new implicitly generated section that will be present on all new modules. The section contains a versioned data structure which represents essentially information to allow a program loader to determine the requirements of the application. This patch implements mips.abiflags section and provides test cases for it.
llvm-svn: 212519
2014-07-08 08:59:22 +00:00
Rafael Espindola 8026bd0b2a This only needs a StringRef.
llvm-svn: 212401
2014-07-06 14:17:29 +00:00
Alp Toker a55b95b58a SourceMgr: make valid buffer IDs start from one
Use 0 for the invalid buffer instead of -1/~0 and switch to unsigned
representation to enable more idiomatic usage.

Also introduce a trivial SourceMgr::getMainFileID() instead of hard-coding 0/1
to identify the main file.

llvm-svn: 212398
2014-07-06 10:33:31 +00:00
David Majnemer 82cb0309e2 MC: make MCSymbolData::dump work on const objects
This just lets us dump a const MCSymbolData object, no functionality
changed.

llvm-svn: 212365
2014-07-05 00:39:52 +00:00
David Majnemer e0950ee85c MC: Correct comment in ExportSymbol
No functionality changed, just make it so that the code _could_ be
uncommented.

llvm-svn: 212363
2014-07-04 23:20:46 +00:00
David Majnemer bee5f754f2 MC: Cleanup COFFAsmParser::ParseSectionFlags
Switch a normal for-loop to a range-based for. No functionality changed.

llvm-svn: 212362
2014-07-04 23:15:28 +00:00
Rafael Espindola 97de474a36 Invert the MC -> Object dependency.
Now that we have a lib/MC/MCAnalysis, the dependency was there just because
of two helper classes. Move the two over to MC.

This will allow IRObjectFile to parse inline assembly.

llvm-svn: 212248
2014-07-03 02:01:39 +00:00
Rafael Espindola e1865a8e8c Fix configure+make build.
llvm-svn: 212210
2014-07-02 20:05:48 +00:00
Rafael Espindola cbc5ac7a7e Move CFG building code to a new lib/MC/MCAnalysis library.
The new library is 150KB on a Release+Asserts build, so it is quiet a bit of
code that regular users of MC don't need to link with now.

llvm-svn: 212209
2014-07-02 19:49:34 +00:00
Rafael Espindola 83120cdf68 Avoid revocations when possible.
This is a small targeted fix for pr20119. The code needs quiet a bit of
refactoring and I added some FIXMEs about it, but I want to get the testcase
passing first.

llvm-svn: 212101
2014-07-01 14:34:30 +00:00
Reid Kleckner b5dd9452b4 Fix .seh_stackalloc 0
seh_stackalloc 0 is not representable in Win64 SEH info, so emitting it
is a bug.

Reviewers: rnk

Differential Revision: http://reviews.llvm.org/D4334

Patch by Vadim Chugunov!

llvm-svn: 212081
2014-07-01 00:42:47 +00:00
Saleem Abdulrasool 7206a52522 MC: rename EmitWin64EH routines
Rename the routines to reflect the reality that they are more related to call
frame information than to Win64 EH. Although EH is implemented in an intertwined
manner by augmenting with an exception handler and an associated parameter, the
majority of these routines emit information required to unwind the frames. This
also helps identify that these routines are generic for most windows platforms
(they apply equally to nearly all architectures except x86) although the
encoding of the information is architecture dependent.

Unwinding data is emitted via EmitWinCFI* and exception handling information via
EmitWinEH*.

llvm-svn: 211994
2014-06-29 01:52:01 +00:00
David Majnemer c57d038240 MC: Fix associative sections on COFF
COFF sections in MC were represented by a tuple of section-name and
COMDAT-name.  This is not sufficient to represent a .text section
associated with another .text section; we need a way to distinguish
between the key section and the one marked associative.

llvm-svn: 211913
2014-06-27 17:19:44 +00:00
Alp Toker e69170a110 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

llvm-svn: 211814
2014-06-26 22:52:05 +00:00
Alp Toker 614717388c Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

llvm-svn: 211749
2014-06-26 00:00:48 +00:00
Rafael Espindola 591c641920 Merge the used symbol scanning of MCObjectStreamer and RecordStreamer.
This completes the refactoring of RecordStreamer.

llvm-svn: 211727
2014-06-25 18:37:33 +00:00
Rafael Espindola e2c6624475 Move expression visitation logic up to MCStreamer.
Remove the duplicate from MCRecordStreamer. No functionality change.

llvm-svn: 211714
2014-06-25 15:45:33 +00:00
Rafael Espindola 2be1281d43 Simplify the visitation of target expressions. No functionality change.
llvm-svn: 211707
2014-06-25 15:29:54 +00:00
Rafael Espindola 9364ac69d8 Simplify AddValueSymbols. No functionality change.
llvm-svn: 211701
2014-06-25 14:42:14 +00:00
NAKAMURA Takumi 1db5995d14 Re-apply r211399, "Generate native unwind info on Win64" with a fix to ignore SEH pseudo ops in X86 JIT emitter.
--
This patch enables LLVM to emit Win64-native unwind info rather than
DWARF CFI.  It handles all corner cases (I hope), including stack
realignment.

Because the unwind info is not flexible enough to describe stack frames
with a gap of unknown size in the middle, such as the one caused by
stack realignment, I modified register spilling code to place all spills
into the fixed frame slots, so that they can be accessed relative to the
frame pointer.

Patch by Vadim Chugunov!

Reviewed By: rnk

Differential Revision: http://reviews.llvm.org/D4081

llvm-svn: 211691
2014-06-25 12:41:52 +00:00
Rafael Espindola 6804d450cd Fix another asserting method in the null streamer.
llvm-svn: 211668
2014-06-25 05:37:58 +00:00
Rafael Espindola c00d875d35 Fix a regression from r211653.
The method was empty in the null streamer but I mistakenly replaced it with
the aborting one in MCStreamer.

llvm-svn: 211666
2014-06-25 05:31:22 +00:00
NAKAMURA Takumi 6d9bb5cbb7 MCNullStreamer.cpp: Roll back a few empty methods that have been marked as unreachable in MCStreamer.cpp.
void EmitCOFFSecRel32(MCSymbol const *Symbol) override {}
  void EmitGPRel32Value(const MCExpr *Value) override {}

It should fix crash like "llc -mtriple=i686-cygwin -filetype=null".

llvm-svn: 211664
2014-06-25 04:34:36 +00:00
Rafael Espindola 624ac24da9 Move some trivial methods up to MCStreamer.
This saves some duplicated boilerplate in RecordStreamer and NullStreamer.

llvm-svn: 211653
2014-06-25 00:27:53 +00:00
Rafael Espindola 49bbfd026a Simplify the handling of .cfi_endproc.
No functionality change.

llvm-svn: 211651
2014-06-25 00:13:59 +00:00
Rafael Espindola c607d8e7be Simplify EmitLabel.
All the "real" streamers were already calling to MCStreamer::EmitLabel
to do part of the work.

llvm-svn: 211646
2014-06-24 23:54:40 +00:00
Rafael Espindola f491704e22 Print a=b as an assignment.
In assembly the expression a=b is parsed as an assignment, so it should be
printed as one.

This remove a truly horrible hack for producing a label with "a=.". It would
be used by codegen but would never be reached by the asm parser. Sorry I
missed this when it was first committed.

llvm-svn: 211639
2014-06-24 22:45:16 +00:00
Rafael Espindola 886048276f Allow using .cfi_startproc without a leading symbol.
This is possible now that we don't produce .eh symbols. This fixes pr19430.

llvm-svn: 211502
2014-06-23 15:34:32 +00:00
Rafael Espindola 440bb21b5a Stop producing func.eh symbols on Darwin.
According Nick Kledzik (http://llvm.org/bugs/show_bug.cgi?id=19430#c2):
"... mach-o no longer needs names in the __eh_frame section (and has not for
years)."

Iain Sandoe confirms it is also unnecessary for their old darwin support.

llvm-svn: 211500
2014-06-23 15:13:23 +00:00
David Majnemer 8114c1ae17 MC: Cleanup parseMSInlineAsm
Utilize range based for-loops to simplify some code.
Use insert() instead of a loop for simplicity/efficiency.

No functionality change.

llvm-svn: 211486
2014-06-23 02:17:16 +00:00
Saleem Abdulrasool bdbc0088da MC: adjust text section flags for WoA
Correct the section flags for code built for Windows on ARM with
`-ffunction-sections`.  Windows on ARM uses solely Thumb-2 instructions, and
indicates that the function is thumb by placing it in a text section that has
IMAGE_SCN_MEM_16BIT flag set.

When we encounter a .section directive, a new section is constructed.  This may
be a text segment.  In order to identify that we need the additional flag,
expose the target triple through the ObjectFileInfo as this information is lost
otherwise.

Since any modern ARM targeting environment on Windows would be Thumb-2 (Windows
ARM NT or Windows Embedded Compact), introducing a new flag to indicate the
section attribute seems to be a bit overkill.  Simply depend on the target
triple.  Since there is one location that this information is currently needed,
creating a target specific assembly parser and delegating the parsing of section
switches also feels a bit heavy handed.  If it turns out that this information
ends up changing additional behaviour, then it may be worth considering that
alternative.

llvm-svn: 211481
2014-06-22 22:25:01 +00:00
NAKAMURA Takumi d77cefe633 Revert r211399, "Generate native unwind info on Win64"
It broke Legacy JIT Tests on x86_64-{mingw32|msvc}, aka Windows x64.

llvm-svn: 211480
2014-06-22 22:00:56 +00:00
Weiming Zhao 58eb5ab326 Report error for non-zero data in .bss
User may initialize a var with non-zero value and specify .bss section.
E.g. : int a __attribute__((section(".bss"))) = 2;

This patch converts an assertion to error report for better user
experience.

Differential Revision: http://reviews.llvm.org/D4199

llvm-svn: 211455
2014-06-22 00:33:44 +00:00
Rafael Espindola b4076b290e Always use a temp symbol for CIE.
Fixes pr19185.

llvm-svn: 211423
2014-06-20 23:54:32 +00:00
Rafael Espindola c3510c74f7 Use compact unwind for the iOS simulator.
Another step in fixing pr19185.

llvm-svn: 211416
2014-06-20 22:40:55 +00:00
Rafael Espindola becdf63f7d Use a helper function and clang-format.
No functionality change.

llvm-svn: 211415
2014-06-20 22:37:01 +00:00
Reid Kleckner 4a01230db4 Generate native unwind info on Win64
This patch enables LLVM to emit Win64-native unwind info rather than
DWARF CFI.  It handles all corner cases (I hope), including stack
realignment.

Because the unwind info is not flexible enough to describe stack frames
with a gap of unknown size in the middle, such as the one caused by
stack realignment, I modified register spilling code to place all spills
into the fixed frame slots, so that they can be accessed relative to the
frame pointer.

Patch by Vadim Chugunov!

Reviewed By: rnk

Differential Revision: http://reviews.llvm.org/D4081

llvm-svn: 211399
2014-06-20 20:35:47 +00:00
Eric Christopher d29430dae9 Fix up a few formatting issues.
llvm-svn: 211307
2014-06-19 20:00:09 +00:00
Alp Toker 660839f210 MCNullStreamer: assign file IDs to resolve crashes and errors
Use the MCStreamer base implementations for file ID tracking instead of
overriding them as no-ops.

Avoids assertions when streaming Dwarf debug info, and fixes ASM parsing of loc
and file directives.

llvm-svn: 211282
2014-06-19 17:15:36 +00:00
Oliver Stannard 8b27308617 Emit DWARF info for all code section in an assembly file
Currently, when using llvm as an assembler, DWARF debug information is only
generated for the .text section. This patch modifies this so that DWARF info
is emitted for all executable sections.

llvm-svn: 211273
2014-06-19 15:52:37 +00:00
Oliver Stannard f7693f4c1f Emit DWARF3 call frame information when DWARF3+ debug info is requested
Currently, llvm always emits a DWARF CIE with a version of 1, even when emitting
DWARF 3 or 4, which both support CIE version 3. This patch makes it emit the
newer CIE version when we are emitting DWARF 3 or 4. This will not reduce
compatibility, as we already emit other DWARF3/4 features, and is worth doing as
the DWARF3 spec removed some ambiguities in the interpretation of call frame
information.

It also fixes a minor bug where the "return address" field of the CIE was
encoded as a ULEB128, which is only valid when the CIE version is 3. There are
no test changes for this, because (as far as I can tell) none of the platforms
that we test have a return address register with a DWARF register number >127.

llvm-svn: 211272
2014-06-19 15:39:33 +00:00
Eric Christopher 4c5bff36ad Move -dwarf-version to an MC level command line option so it's
used by all of the MC level tools and codegen. Fix up all uses
in the compiler to use this and set it on the context accordingly.

llvm-svn: 211257
2014-06-19 06:22:08 +00:00
Craig Topper 35b2f75733 Convert some assert(0) to llvm_unreachable or fold an 'if' condition into the assert.
llvm-svn: 211254
2014-06-19 06:10:58 +00:00
David Majnemer 6a5b812c7b MS asm: Properly handle quoted symbol names
We would get confused by '@' characters in symbol names, we would
mistake the text following them for the variant kind.

When an identifier a string, the variant kind will never show up inside
of it.  Instead, check to see if there is a variant following the
string.

This fixes PR19965.

llvm-svn: 211249
2014-06-19 01:25:43 +00:00
Saleem Abdulrasool 71ede29e9c MC: do not add comment string to the AsmToken in AsmLexer::LexLineComment
Fixes macros with varargs if the macro instantiation has a trailing comment.

Patch by Janne Grunau!

llvm-svn: 211219
2014-06-18 20:57:32 +00:00
Saleem Abdulrasool 763e2cb6e5 MCAsmParser: full support for gas' '.if{cond} expression' directives
Patch by Janne Grunau!

llvm-svn: 211218
2014-06-18 20:57:28 +00:00
Weiming Zhao 8c89973462 [ARM] [MC] Refactor the constant pool classes
ARMTargetStreamer implements ConstantPool and AssmeblerConstantPools
to keep track of assembler-generated constant pools that are used for
ldr-pseudo.

When implementing ldr-pseudo for AArch64, these two classes can be reused.
So this patch factors them out from ARM target to the general MC lib.

llvm-svn: 211198
2014-06-18 18:17:25 +00:00
Artyom Skrobov 9aea8432c5 Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in place
llvm-svn: 210978
2014-06-14 13:18:07 +00:00