[llvm-commits] [PATCH, PowerPC] Make TOC contents deterministic

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Mon Nov 12 09:35:31 PST 2012


Hello,

the PowerPC back-end currently uses a DenseMap to hold all symbols that
need to go into the TOC.  After compilation of a file is done, the TOC
contents are emitted by iterating over the DenseMap. However, the problem
with that approach is that this iterating process is not really
deterministic, since it depends on the address space layout of the compiler
process (as the sequence chosen by the iterator depends on key values,
which happen to be pointers into the heap).

While this is not a matter of code correctness, it is still not quite
ideal: for example, it causes spurious differences between the stage2 and
stage3 compiler binaries in a bootstrap process; or it causes spurious
differences between object files generated with the integrated assembler
vs. the external assembler.  The code already contains a FIXME that this
ought to be improved ...

The attached patch fixes this problem by replacing the DenseMap data
structure with a MapVector, which provides bascially the same API except
that the iterator is guaranteed to use a deterministic sequence (namely the
sequence in which symbols have been added to the TOC).   It would appear
this data structure was added specifically to solve this type of problem,
and indeed it does work for the case of the TOC.

OK to commit?

Bye,
Ulrich

(See attached file: diff-llvm-deterministic-toc)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-llvm-deterministic-toc
Type: application/octet-stream
Size: 1066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121112/e53cf117/attachment.obj>


More information about the llvm-commits mailing list