[PATCH] ValueMapper: Eliminate cross-file co-recursion, NFC

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 16:28:08 PDT 2016


Eliminate co-recursion of Mapper::mapValue through
ValueMaterializer::materializeInitFor, through a major redesign of the
ValueMapper.cpp interface.

  - Expose a ValueMapper class that controls the entry points to the
    mapping algorithms.
  - Change IRLinker to use ValueMapper directly, rather than
    llvm::RemapInstruction, llvm::MapValue, etc.
  - Use (e.g.) ValueMapper::scheduleMapGlobalInit to add mapping work to
    a worklist in ValueMapper instead of recursing.

There were two fairly major complications.

Firstly, IRLinker::linkAppendingVarProto incorporates an on-the-fly IR
ugprade that I had to split apart.  Frankly I think this upgrade should
be done in the bitcode reader (and we should only accept the "new"
form), but for now I've just made it work and added a FIXME.

Secondly, IRLinker has special logic to correctly implement aliases with
comdats, and uses two ValueToValueMapTy instances and two
ValueMaterializers.  This wasn't hard to support by making ValueMapper
support arbitrary MappingContexts when scheduling work.

While out of scope for this commit, it should be straightforward to
remove recursion from Mapper::mapValue once this is in place.

(Note: 0001 is a prep commit that would be silly without 0002.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ValueMapper-Hide-Mapper-VM-behind-an-accessor-NFC.patch
Type: application/octet-stream
Size: 7787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160412/b24b6757/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ValueMapper-Eliminate-cross-file-co-recursion-NFC.patch
Type: application/octet-stream
Size: 33028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160412/b24b6757/attachment-0003.obj>


More information about the llvm-commits mailing list