summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSymbol.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* IWYU for llvm-config.h in llvm, additions.Nico Weber2018-04-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
* Reverting r315590; it did not include changes for llvm-tblgen, which is ↵Aaron Ballman2017-10-151-1/+1
| | | | | | | | causing link errors for several people. Error LNK2019 unresolved external symbol "public: void __cdecl `anonymous namespace'::MatchableInfo::dump(void)const " (?dump@MatchableInfo@?A0xf4f1c304@@QEBAXXZ) referenced in function "public: void __cdecl `anonymous namespace'::AsmMatcherEmitter::run(class llvm::raw_ostream &)" (?run@AsmMatcherEmitter@?A0xf4f1c304@@QEAAXAEAVraw_ostream@llvm@@@Z) llvm-tblgen D:\llvm\2017\utils\TableGen\AsmMatcherEmitter.obj 1 llvm-svn: 315854
* [dump] Remove NDEBUG from test to enable dump methods [NFC]Don Hinton2017-10-121-1/+1
| | | | | | | | | | | | | | | Summary: Add LLVM_FORCE_ENABLE_DUMP cmake option, and use it along with LLVM_ENABLE_ASSERTIONS to set LLVM_ENABLE_DUMP. Remove NDEBUG and only use LLVM_ENABLE_DUMP to enable dump methods. Move definition of LLVM_ENABLE_DUMP from config.h to llvm-config.h so it'll be picked up by public headers. Differential Revision: https://reviews.llvm.org/D38406 llvm-svn: 315590
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-081-1/+7
| | | | | | minor fixes (NFC). llvm-svn: 294526
* Cleanup dump() functions.Matthias Braun2017-01-281-1/+5
| | | | | | | | | | | | | | | | | | We had various variants of defining dump() functions in LLVM. Normalize them (this should just consistently implement the things discussed in http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html For reference: - Public headers should just declare the dump() method but not use LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - The definition of a dump method should look like this: #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MyClass::dump() { // print stuff to dbgs()... } #endif llvm-svn: 293359
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-3/+2
| | | | | | No functionality change intended. llvm-svn: 284733
* [MC] Remove guard(s). NFCI.Davide Italiano2016-08-221-2/+0
| | | | | | | All the methods are already marked with LLVM_DUMP_METHOD. llvm-svn: 279428
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-1/+1
| | | | | | | | r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
* [ptr-traits] Provide a real MCFragment address for the sentinel insteadChandler Carruth2015-12-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | of casting the integer '4' to such a pointer. There is no reason to expect '4' to be a portable or reliable pointer of this form. The only reason this ever worked is because the PointerIntPair that this actually gets used with has an artificially *low* presumed alignment that allowed it to work. When the alignment of PointerIntPair is derived from the actual type's alignment, the asserts start firing on this pointer. I'm amazed we never managed to do anything that triggered the alignment sanitizer with it, as this is just flat out UB. If folks dislike this approach to providing a sentinel fragment address, there are a myriad of other alternatives, suggestions welcome. But this one has the distinct advantage of not requiring the friend dance of ilist's sentinel (which I'll point out is *also* in play for MCFragment!) and seems to be using a nicely provided facility in MCFragment to establish just such dummy nodes. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256552
* Fix pr24486.Rafael Espindola2015-10-051-2/+3
| | | | | | | | | | | | | | | | | | This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303
* [MC] Switch static const to an enum to silence MSVC linker warningsDavid Majnemer2015-07-101-3/+0
| | | | | | | Integral class statics are handled oddly in MSVC, we don't need them in this case, use an enum instead. llvm-svn: 241945
* Pack MCSymbol::Flags in to the bitfield with other members. NFC.Pete Cooper2015-07-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All file formats only needed 16-bits right now which is enough to fit in to the padding with other fields. This reduces the size of MCSymbol to 24-bytes on a 64-bit system. The layout is now 0 | class llvm::MCSymbol 0 | class llvm::PointerIntPair SectionOrFragmentAndHasName 0 | intptr_t Value | [sizeof=8, dsize=8, align=8 | nvsize=8, nvalign=8] 8 | unsigned int IsTemporary 8 | unsigned int IsRedefinable 8 | unsigned int IsUsed 8 | _Bool IsRegistered 8 | unsigned int IsExternal 8 | unsigned int IsPrivateExtern 8 | unsigned int Kind 9 | unsigned int IsUsedInReloc 9 | unsigned int SymbolContents 9 | unsigned int CommonAlignLog2 10 | uint32_t Flags 12 | uint32_t Index 16 | union 16 | uint64_t Offset 16 | uint64_t CommonSize 16 | const class llvm::MCExpr * Value | [sizeof=8, dsize=8, align=8 | nvsize=8, nvalign=8] | [sizeof=24, dsize=24, align=8 | nvsize=24, nvalign=8] llvm-svn: 241196
* Encode MCSymbol alignment as log2(align).Pete Cooper2015-07-011-0/+2
| | | | | | | | | | | | | Given that alignments are always powers of 2, just encode it this way. This matches how we encode alignment on IR GlobalValue's for example. This compresses the CommonAlign member down to 5 bits which allows it to pack better with the surrounding fields. Reviewed by Duncan Exon Smith. llvm-svn: 241189
* Pack MCSymbol::HasName in to a spare bit in the section/fragment union.Pete Cooper2015-06-301-1/+1
| | | | | | | | | | | | This is part of an effort to pack the average MCSymbol down to 24 bytes. The HasName bit was pushing the size of the bitfield over to another word, so this change uses a PointerIntPair to fit in it to unused bits of a PointerUnion. Reviewed by Rafael Espíndola llvm-svn: 241115
* Move MCSymbol Value in to the union of Offset and CommonSize.Pete Cooper2015-06-221-0/+4
| | | | | | | | | | | | | | | | This is a reapplication of r239440 which was reverted in r239441. There are no changes to this patch from then, but this had instead exposed a bug in .thumb_set which was fixed in r240318. Having fixed that bug, it is now safe to re-apply this code. Original commit message below: It wasn't possible to have a variable Symbol with offset or 'isCommon' so this just enables better packing of the MCSymbol class. Reviewed by Rafael Espindola. llvm-svn: 240320
* Fix warning of comparing different enums. NFCPete Cooper2015-06-091-1/+1
| | | | llvm-svn: 239443
* Revert "Move MCSymbol Value in to the union of Offset and CommonSize."Pete Cooper2015-06-091-4/+0
| | | | | | | | | This reverts commit 2e449ec5bcdf67b52b315b16c2128aaf25d5b73c. This was svn r239440. Its currently failing an ARM test so reverting while I work out what to do next. llvm-svn: 239441
* Move MCSymbol Value in to the union of Offset and CommonSize.Pete Cooper2015-06-091-0/+4
| | | | | | | | | It wasn't possible to have a variable Symbol with offset or 'isCommon' so this just enables better packing of the MCSymbol class. Reviewed by Rafael Espindola. llvm-svn: 239440
* Use AlignOf traits to enable static_assert.Pete Cooper2015-06-091-3/+3
| | | | | | This is better than runtime asserts. Thanks to David Blaikie for the help here. llvm-svn: 239431
* Reduce duplication in MCSymbol Name handling. NFC>Pete Cooper2015-06-091-0/+1
| | | | | | | | | | | | | Based on feedback to r239428 by David Blaikie, use const_cast to reduce duplication of the const and non-const versions of getNameEntryPtr. Also have that method return the pointer to the name directly instead of users having to then get the name from the union. Finally, add a FIXME that we should use a static_assert once available in the new operator. llvm-svn: 239429
* Make MCSymbol::Name be a union of uint64_t and a pointer.Pete Cooper2015-06-091-6/+9
| | | | | | | | | This should hopefully fix the 32-bit bots which were allocating space for a pointer but needed to be aligned to 64-bits. Now we allocate enough space for a uint64_t and a pointer and cast to the appropriate storage llvm-svn: 239428
* Change from alignof to llvm::alignOf to appease Visual StudioPete Cooper2015-06-091-2/+2
| | | | llvm-svn: 239424
* Allocate space for MCSymbol::Name only if required.Pete Cooper2015-06-091-0/+15
| | | | | | | | | | | | | | Similarly to User which allocates a number of Use's prior to the this pointer, allocate space for the Name* for MCSymbol only when we need a name. Given that an MCSymbol is 48-bytes on 64-bit systems, this saves a decent % of space. Given the verify_uselistorder test case with debug info and llc, 50k symbols have names out of 700k so this optimises for the common case of temporary unnamed symbols. Reviewed by David Blaikie. llvm-svn: 239423
* MC: Add target hook to control symbol quotingMatt Arsenault2015-06-091-30/+8
| | | | llvm-svn: 239370
* Use a PointerUnion in MCSymbol for Section and Fragment. NFC.Pete Cooper2015-06-081-2/+1
| | | | | | | The Fragment and Section, and a bool for HasFragment were all used to create a PointerUnion. Just use a pointer union instead. llvm-svn: 239324
* The fragment implies the section, don't store both.Rafael Espindola2015-06-011-1/+2
| | | | | | This reduces MCSymbol from 64 to 56 bytes on x86_64. llvm-svn: 238747
* Use operator<< instead of print in a few more places.Rafael Espindola2015-05-271-3/+1
| | | | llvm-svn: 238315
* MCSymbol: Make print() robust against empty namesMatthias Braun2015-05-271-0/+4
| | | | | | | This shouldn't happen, but it's nice not to abort when printing broken machine functions. llvm-svn: 238287
* Move alignment from MCSectionData to MCSection.Rafael Espindola2015-05-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | This starts merging MCSection and MCSectionData. There are a few issues with the current split between MCSection and MCSectionData. * It optimizes the the not as important case. We want the production of .o files to be really fast, but the split puts the information used for .o emission in a separate data structure. * The ELF/COFF/MachO hierarchy is not represented in MCSectionData, leading to some ad-hoc ways to represent the various flags. * It makes it harder to remember where each item is. The attached patch starts merging the two by moving the alignment from MCSectionData to MCSection. Most of the patch is actually just dropping 'const', since MCSectionData is mutable, but MCSection was not. llvm-svn: 237936
* Revert accidentally committed "MC: Allow targets to stop symbol name quoting"Matt Arsenault2015-04-231-1/+1
| | | | llvm-svn: 235672
* MC: Allow targets to stop symbol name quotingMatt Arsenault2015-04-231-1/+1
| | | | | | | | | Currently symbol names are printed in quotes if it contains something outside of the arbitrary set of characters that isAcceptableChar tests for. On somem targets, it is never OK to print a symbol name in quotes so allow targets to opt out of this behavior. llvm-svn: 235670
* Move AliasedSymbol to MachObjectWriter.Rafael Espindola2015-04-171-12/+0
| | | | | | | It was only used by MachO. Part of pr19627. llvm-svn: 235185
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-04-031-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR19582. Previously, when an asm assignment (.set or =) was created, we would look up the section immediately in MCSymbol::setVariableValue. This caused symbols to receive the wrong section if the RHS of the assignment had not been seen yet. This had a knock-on effect in the object file emitters, causing them to emit extra symbols, or to give symbols the wrong visibility or the wrong section. For example, in the following asm: .data .Llocal: .text leaq .Llocal1(%rip), %rdi .Llocal1 = .Llocal2 .Llocal2 = .Llocal the first assignment would give .Llocal1 a null section, which would never get fixed up by the second assignment. This would cause the ELF object file emitter to consider .Llocal1 to be an undefined symbol and give it external linkage, even though .Llocal1 should not have been emitted at all in the object file. Or in the following asm: alias_to_local = Ltmp0 Ltmp0: the Mach-O object file emitter would give the alias_to_local symbol a n_type of N_SECT and a n_sect of 0. This is invalid under the Mach-O specification, which requires N_SECT symbols to receive a non-zero section number if the symbol is defined in a section in the object file. https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/#//apple_ref/c/tag/nlist After this change we do not look up the section when the assignment is created, but instead look it up on demand and store it in Section, which is treated as a cache if the symbol is a variable symbol. This change also fixes a bug in MCExpr::FindAssociatedSection. Previously, if we saw a subtraction, we would return the first referenced section, even in cases where we should have been returning the absolute pseudo-section. Now we always return the absolute pseudo-section for expressions that subtract two section-derived expressions. This isn't always correct (e.g. if one of the sections ends up being laid out at an absolute address), but it's probably the best we can do without more context. This allows us to remove code in two places where we appear to have been working around this bug, in MachObjectWriter::markAbsoluteVariableSymbols and in X86AsmPrinter::EmitStartOfAsmFile. Re-applies r233595 (aka D8586), which was reverted in r233898. Differential Revision: http://reviews.llvm.org/D8798 llvm-svn: 233995
* Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a ↵Peter Collingbourne2015-04-021-1/+7
| | | | | | cache." llvm-svn: 233898
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-03-301-7/+1
| | | | | | | | | | | This fixes the visibility of symbols in certain edge cases involving aliases with multiple levels of indirection. Fixes PR19582. Differential Revision: http://reviews.llvm.org/D8586 llvm-svn: 233595
* Revert "Add back r203962, r204028 and r204059."Rafael Espindola2014-03-191-22/+0
| | | | | | This reverts commit r204178. llvm-svn: 204203
* Add back r203962, r204028 and r204059.Rafael Espindola2014-03-181-0/+22
| | | | | | | | This reverts commit r204137. This includes a fix for handling aliases of aliases. llvm-svn: 204178
* Revert r203962 and two revisions depending on it: r204028 and r204059.Alexander Kornienko2014-03-181-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The revision I'm reverting breaks handling of transitive aliases. This blocks us and breaks sanitizer bootstrap: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2651 (and checked locally by Alexey). This revision is the result of: svn merge -r204059:204058 -r204028:204027 -r203962:203961 . + the regression test added to test/MC/ELF/alias.s Another way to reproduce the regression with clang: $ cat q.c void a1(); void a2() __attribute__((alias("a1"))); void a3() __attribute__((alias("a2"))); void a1() {} $ ~/work/llvm-build/bin/clang-3.5-good -c q.c && mv q.o good.o && \ ~/work/llvm-build/bin/clang-3.5-bad -c q.c && mv q.o bad.o && \ objdump -t good.o bad.o good.o: file format elf64-x86-64 SYMBOL TABLE: 0000000000000000 l df *ABS* 0000000000000000 q.c 0000000000000000 l d .text 0000000000000000 .text 0000000000000000 l d .data 0000000000000000 .data 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l d .comment 0000000000000000 .comment 0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack 0000000000000000 l d .eh_frame 0000000000000000 .eh_frame 0000000000000000 g F .text 0000000000000006 a1 0000000000000000 g F .text 0000000000000006 a2 0000000000000000 g F .text 0000000000000006 a3 bad.o: file format elf64-x86-64 SYMBOL TABLE: 0000000000000000 l df *ABS* 0000000000000000 q.c 0000000000000000 l d .text 0000000000000000 .text 0000000000000000 l d .data 0000000000000000 .data 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l d .comment 0000000000000000 .comment 0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack 0000000000000000 l d .eh_frame 0000000000000000 .eh_frame 0000000000000000 g F .text 0000000000000006 a1 0000000000000000 g F .text 0000000000000006 a2 0000000000000000 g .text 0000000000000000 a3 llvm-svn: 204137
* Correctly handle an ELF symbol defined with "a = b + expr".Rafael Espindola2014-03-141-0/+17
| | | | | | | | | We were marking the symbol as absolute instead of computing b's offset + the expression value. This fixes pr19126. llvm-svn: 203962
* Don't mangle \n and "Rafael Espindola2013-11-141-3/+14
| | | | | | | | | | There is nothing special about quotes and newlines from the object file point of view, only the assembler has to worry about expanding the \n and \". This patch then removes the special handling from the Mangler. llvm-svn: 194667
* Revert "Re-commit r192758 - MC: quote tricky symbol names in asm output"Hans Wennborg2013-10-181-4/+6
| | | | | | | | | | | | | | | | | This caused the clang-native-mingw32-win7 buildbot to break. The assembler was complaining about the following lines that were showing up in the asm for CrashRecoveryContext.cpp: movl $"__ZL16ExceptionHandlerP19_EXCEPTION_POINTERS@4", 4(%eax) calll "_AddVectoredExceptionHandler@8" .def "__ZL16ExceptionHandlerP19_EXCEPTION_POINTERS@4"; "__ZL16ExceptionHandlerP19_EXCEPTION_POINTERS@4": calll "_RemoveVectoredExceptionHandler@4" Reverting for now. llvm-svn: 192940
* Re-commit r192758 - MC: quote tricky symbol names in asm outputHans Wennborg2013-10-171-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The reason this got reverted was that the @feat.00 symbol which was emitted for every TU became quoted, and on cygwin/mingw we use the gas assembler which couldn't handle the quotes. This commit fixes the problem by only emitting @feat.00 for win32, where we use clang -cc1as to assemble. gas would just drop this symbol anyway, so there is no loss there. With @feat.00 gone, there shouldn't be quoted symbols showing up on cygwin since it uses the Itanium ABI, which doesn't put these funny characters in symbols. > Because of win32 mangling, we produce symbol and section names with > funny characters in them, most notably @ characters. > > MC would choke on trying to parse its own assembly output. This patch addresses > that by: > > - Making @ trigger quoting of symbol names > - Also quote section names in the same way > - Just parse section names like other identifiers (to allow for quotes) > - Don't assume @ signifies a symbol variant if it is in a string. llvm-svn: 192859
* Revert r192758 (and r192759), "MC: Better handling of tricky symbol and ↵NAKAMURA Takumi2013-10-161-4/+6
| | | | | | | | | | | | | | | section names" GNU AS didn't like quotes in symbol names. Error: junk at end of line, first unrecognized character is `"' .def "@feat.00"; "@feat.00" = 1 Reproduced on Cygwin's 2.23.52.20130309 and mingw32's 2.20.1.20100303. llvm-svn: 192775
* MC: Better handling of tricky symbol and section namesHans Wennborg2013-10-161-6/+4
| | | | | | | | | | | | | | | | | Because of win32 mangling, we produce symbol and section names with funny characters in them, most notably @ characters. MC would choke on trying to parse its own assembly output. This patch addresses that by: - Making @ trigger quoting of symbol names - Also quote section names in the same way - Just parse section names like other identifiers (to allow for quotes) - Don't assume @ signifies a symbol variant if it is in a string. Differential Revision: http://llvm-reviews.chandlerc.com/D1945 llvm-svn: 192758
* Fix Doxygen issues:Dmitri Gribenko2012-09-141-1/+1
| | | | | | | | | | * wrap code blocks in \code ... \endcode; * refer to parameter names in paragraphs correctly (\arg is not what most people want -- it starts a new paragraph); * use \param instead of \arg to document parameters in order to be consistent with the rest of the codebase. llvm-svn: 163902
* Release build: guard dump functions withManman Ren2012-09-121-1/+1
| | | | | | | | "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163344. llvm-svn: 163679
* Release build: guard dump functions with "ifndef NDEBUG"Manman Ren2012-09-061-0/+2
| | | | | | No functional change. llvm-svn: 163344
* Tidy up. Trailing whitespace.Jim Grosbach2012-05-111-2/+2
| | | | llvm-svn: 156602
OpenPOWER on IntegriCloud