llvm-6502/lib/CodeGen/AsmPrinter
Duncan P. N. Exon Smith 09fe4bf794 Reapply "AsmPrinter: Change DIEValue to be stored by value"
This reverts commit r238350, effectively reapplying r238349 after fixing
(all?) the problems, all somehow related to how I was using
`AlignedArrayCharUnion<>` inside `DIEValue`:

  - MSVC can only handle `sizeof()` on types, not values.  Change the
    assert.
  - GCC doesn't know the `is_trivially_copyable` type trait.  Instead of
    asserting it, add destructors.
  - Call placement new even when constructing POD (i.e., the pointers).
  - Instead of copying the char buffer, copy the casted classes.

I've left in a couple of `static_assert`s that I think both MSVC and GCC
know how to handle.  If the bots disagree with me, I'll remove them.

  - Check that the constructed type is either standard layout or a
    pointer.  This protects against a programming error: we really want
    the "small" `DIEValue`s to be small and simple, so don't
    accidentally change them not to be.
  - Similarly, check that the size of the buffer is no bigger than a
    `uint64_t` or a pointer.  (I thought checking against
    `sizeof(uint64_t)` would be good enough, but Chandler suggested that
    pointers might sometimes be bigger than that in the context of
    sanitizers.)

I've also committed r238359 in the meantime, which introduces a
DIEValue.def to simplify dispatching between the various types (thanks
to a review comment by David Blaikie).  Without that, this commit would
be almost unintelligible.

Here's the original commit message:
--
Change `DIEValue` to be stored/passed/etc. by value, instead of
reference.  It's now a discriminated union, with a `Val` field storing
the actual type.  The classes that used to inherit from `DIEValue` no
longer do.  There are two categories of these:

  - Small values fit in a single pointer and are stored by value.
  - Large values require auxiliary storage, and are stored by reference.

The only non-mechanical change is to tools/dsymutil/DwarfLinker.cpp.  It
was relying on `DIEInteger`s being passed around by reference, so I
replaced that assumption with a `PatchLocation` type that stores a safe
reference to where the `DIEInteger` lives instead.

This commit causes a temporary regression in memory usage, since I've
left merging `DIEAbbrevData` into `DIEValue` for a follow-up commit.  I
measured an increase from 845 MB to 879 MB, around 3.9%.  The follow-up
drops it lower than the starting point, and I've only recently brought
the memory this low anyway, so I'm committing these changes separately
to keep them incremental.  (I also considered swapping the commits, but
the other one first would cause a lot more code churn.)

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)
--

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 22:14:58 +00:00
..
AddressPool.cpp Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
AddressPool.h Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
ARMException.cpp [AsmPrinter] Make AsmPrinter's OutStreamer member a unique_ptr. 2015-04-24 19:11:51 +00:00
AsmPrinter.cpp Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
AsmPrinterDwarf.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
AsmPrinterHandler.h Print jump tables before exception tables. 2015-03-09 18:29:12 +00:00
AsmPrinterInlineAsm.cpp Stop resetting SanitizeAddress in TargetMachine::resetTargetOptions. NFC. 2015-05-15 00:20:44 +00:00
ByteStreamer.h Don't generate comments in the DebugLocStream unless required. NFC. 2015-05-20 22:51:27 +00:00
CMakeLists.txt Debug info: Factor out the creation of DWARF expressions from AsmPrinter 2015-01-12 22:19:22 +00:00
DbgValueHistoryCalculator.cpp IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DbgValueHistoryCalculator.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DebugLocEntry.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DebugLocStream.h Don't generate comments in the DebugLocStream unless required. NFC. 2015-05-20 22:51:27 +00:00
DIE.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DIEHash.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DIEHash.h Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DwarfAccelTable.cpp AsmPrinter: Avoid EmitLabelDifference() in DwarfAccelTable 2015-05-24 16:48:54 +00:00
DwarfAccelTable.h Use operator<< instead of print in a few more places. 2015-05-27 13:05:42 +00:00
DwarfCFIException.cpp [AsmPrinter] Make AsmPrinter's OutStreamer member a unique_ptr. 2015-04-24 19:11:51 +00:00
DwarfCompileUnit.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DwarfCompileUnit.h IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DwarfDebug.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DwarfDebug.h Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
DwarfException.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
DwarfExpression.cpp IR: Give 'DI' prefix to debug info metadata 2015-04-29 16:38:44 +00:00
DwarfExpression.h Revert "Add bool to DebugLocDwarfExpression to control emitting comments." 2015-05-20 22:37:48 +00:00
DwarfFile.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DwarfFile.h AsmPrinter: Prune an include, NFC 2015-05-24 16:54:59 +00:00
DwarfStringPool.cpp AsmPrinter: Avoid creating symbols in DwarfStringPool 2015-05-24 16:58:59 +00:00
DwarfStringPool.h AsmPrinter: Avoid creating symbols in DwarfStringPool 2015-05-24 16:58:59 +00:00
DwarfUnit.cpp Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
DwarfUnit.h Reapply "AsmPrinter: Change DIEValue to be stored by value" 2015-05-27 22:14:58 +00:00
EHStreamer.cpp Move alignment from MCSectionData to MCSection. 2015-05-21 19:20:38 +00:00
EHStreamer.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
ErlangGCPrinter.cpp [AsmPrinter] Make AsmPrinter's OutStreamer member a unique_ptr. 2015-04-24 19:11:51 +00:00
LLVMBuild.txt Add proper dependencies to LLVMBuild.txt in llvm/lib. 2013-12-10 05:39:34 +00:00
Makefile
OcamlGCPrinter.cpp MC: Clean up method names in MCContext. 2015-05-18 18:43:14 +00:00
Win64Exception.cpp MC: Clean up method names in MCContext. 2015-05-18 18:43:14 +00:00
Win64Exception.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00
WinCodeViewLineTables.cpp MC: Clean up method names in MCContext. 2015-05-18 18:43:14 +00:00
WinCodeViewLineTables.h Use 'override/final' instead of 'virtual' for overridden methods 2015-04-11 02:11:45 +00:00