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

Hal Finkel hfinkel at anl.gov
Mon Nov 12 11:00:20 PST 2012


----- Original Message -----
> From: "Ulrich Weigand" <Ulrich.Weigand at de.ibm.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Monday, November 12, 2012 11:35:31 AM
> Subject: [llvm-commits] [PATCH, PowerPC] Make TOC contents deterministic
> 
> 
> 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 ...

Yes, the compiler should be deterministic. I believe that non-determinism is considered a type of compiler bug, even if all output options are functionally correct.

> 
> 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?

I love two-line changes ;) Yes, please commit.

Thanks again,
Hal

> 
> Bye,
> Ulrich
> 
> (See attached file: diff-llvm-deterministic-toc)
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list