llvm-6502/include/llvm
Peter Collingbourne c39f5dd0e2 MC: For variable symbols, maintain MCSymbol::Section as a cache.
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233995 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03 01:46:11 +00:00
..
ADT [ADT] Increment epoch from DenseMap::swap. 2015-04-02 04:58:12 +00:00
Analysis [opaque pointer types] Push explicit type parameter for geps through the constant folders 2015-04-03 01:15:16 +00:00
AsmParser Pass a MemoryBufferRef when we can avoid taking ownership. 2014-08-26 21:49:01 +00:00
Bitcode Purge unused includes throughout libSupport. 2015-03-23 18:07:13 +00:00
CodeGen MachineRegisterInfo: Make it clear that hints are for vregs 2015-04-03 00:18:33 +00:00
Config [ADT][CMake][AutoConf] Fail-fast iterators for DenseMap 2015-03-26 19:25:01 +00:00
DebugInfo DWARFDebugRangeList: make the list of entries available to clients. 2015-03-13 23:30:07 +00:00
ExecutionEngine [Orc] Add support classes for inspecting and running C++ static ctor/dtors, and 2015-04-02 04:34:45 +00:00
IR Return iterator from BasicBlock::eraseFromParent 2015-04-03 01:20:33 +00:00
IRReader Pass a MemoryBufferRef when we can avoid taking ownership. 2014-08-26 21:49:01 +00:00
LineEditor [C++11] Replace OwningPtr with std::unique_ptr in places where it doesn't break the API. 2014-04-21 09:34:48 +00:00
Linker Remember to move a type to the correct set when setting the body. 2015-03-06 00:50:21 +00:00
LTO libLTO, llvm-lto, gold: Introduce flag for controlling optimization level. 2015-03-19 22:01:00 +00:00
MC MC: For variable symbols, maintain MCSymbol::Section as a cache. 2015-04-03 01:46:11 +00:00
Object [llvm-readobj] add support for macho universal binary. 2015-03-24 20:26:55 +00:00
Option Make getLastArgNoClaim work for up to 4 arguments. 2015-03-20 23:32:58 +00:00
Passes [PM] Create a separate library for high-level pass management code. 2015-03-07 09:02:36 +00:00
ProfileData InstrProf: Teach llvm-cov to handle universal binaries when given -arch 2015-03-11 02:30:51 +00:00
Support Add an LLVM_PTR_SIZE macro to make LLVM_ALIGNAS more useful 2015-04-02 17:43:35 +00:00
TableGen Remove StringRef->std::string->StringRef conversions. 2015-03-17 21:33:38 +00:00
Target Clarify that higher priority means higher values. 2015-03-31 20:04:46 +00:00
Transforms Reapply r233175 and r233183: float2int. 2015-03-27 10:36:57 +00:00
CMakeLists.txt Remove llvm_headers_do_not_build for the benefit of XCode and Visual Studio users. 2014-08-14 00:51:47 +00:00
InitializePasses.h Reapply r233175 and r233183: float2int. 2015-03-27 10:36:57 +00:00
LinkAllIR.h
LinkAllPasses.h Reapply r233175 and r233183: float2int. 2015-03-27 10:36:57 +00:00
module.modulemap [modules] Mark Analysis/TargetLibraryInfo.def as a textual header. 2015-03-06 23:39:54 +00:00
module.modulemap.build [modules] Add module maps for LLVM. These are not quite ready for prime-time 2014-05-21 02:46:14 +00:00
Pass.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
PassAnalysisSupport.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
PassInfo.h Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition. 2015-02-15 22:54:22 +00:00
PassRegistry.h Revert r231276 (including r231277): Add a lock() function in PassRegistry to speed up multi-thread synchronization. 2015-03-05 17:53:00 +00:00
PassSupport.h Defining a new API for debug options that doesn't rely on static global cl::opts. 2014-10-15 21:54:35 +00:00