llvm-project/llvm/test
JF Bastien 057292a76c Improve the determinism of MergeFunctions
Summary:

Merge functions previously relied on unsigned comparisons of pointer values to
order functions. This caused observable non-determinism in the compiler for
large bitcode programs. Basically, opt -mergefuncs program.bc | md5sum produces
different hashes when run repeatedly on the same machine. Differing output was
observed on three large bitcodes, but it was less frequent on the smallest file.
It is possible that this only manifests on the large inputs, hence remaining
undetected until now.

This patch fixes this by removing (almost, see below) all places where
comparisons between pointers are used to order functions. Most of these changes
are local, but the comparison of global values requires assigning an identifier
to each local in the order it is visited. This is very similar to the way the
comparison function identifies Value*'s defined within a function. Because the
order of visiting the functions and their subparts is deterministic, the
identifiers assigned to the globals will be as well, and the order of functions
will be deterministic.

With these changes, there is no more observed non-determinism. There is also
only minor slowdowns (negligible to 4%) compared to the baseline, which is
likely a result of the fact that global comparisons involve hash lookups and not
just pointer comparisons.

The one caveat so far is that programs containing BlockAddress constants can
still be non-deterministic. It is not clear what the right solution is here. In
particular, even if the global numbers are used to order by function, we still
need a way to order the BasicBlock*'s. Unfortunately, we cannot just bail out
and fail to order the functions or consider them equal, because we require a
total order over functions. Note that programs with BlockAddress constants are
relatively rare, so the impact of leaving this in is minor as long as this pass
is opt-in.

Author: jrkoenig

Reviewers: nlewycky, jfb, dschuff

Subscribers: jevinskie, llvm-commits, chapuni

Differential revision: http://reviews.llvm.org/D12168

llvm-svn: 245762
2015-08-21 23:27:24 +00:00
..
Analysis Fix how DependenceAnalysis calls delinearization 2015-08-19 02:56:36 +00:00
Assembler [IR] Add token types 2015-08-14 05:09:07 +00:00
Bindings [OCaml] Do not use -warn-error in tests. 2015-07-17 17:33:23 +00:00
Bitcode [test] Testing write access to llvm 2015-08-14 17:42:50 +00:00
BugPoint Fix typo in comment 2015-07-26 11:37:05 +00:00
CodeGen AMDGPU/SI: Better handle s_wait insertion 2015-08-21 22:47:27 +00:00
DebugInfo delete more dead code from this testcase. 2015-08-21 00:02:04 +00:00
ExecutionEngine [mips] Expand JAL instructions when PIC is enabled. 2015-08-18 16:18:09 +00:00
Feature [IR] Give catchret an optional 'return value' operand 2015-08-15 02:46:08 +00:00
FileCheck
Instrumentation [msan] Fix handling of musttail calls. 2015-08-14 22:03:50 +00:00
Integer
JitListener DI: Disallow uniquable DICompileUnits 2015-08-03 17:26:41 +00:00
LTO Move the personality function from LandingPadInst to Function 2015-06-17 20:52:32 +00:00
LibDriver Add support for producing thin archives in llvm-lib. 2015-07-17 16:01:11 +00:00
Linker Make DW_AT_[MIPS_]linkage_name optional, and off by default for SCE. 2015-08-11 21:36:45 +00:00
MC Fix symbol value computation when part of the expression is weak. 2015-08-20 16:18:30 +00:00
Object Add a test showing that objdump (and so ObjectFIle) can handle shndx. 2015-08-10 21:00:15 +00:00
Other Update test suite to make "ninja check" succeed without native backend builtin 2015-08-04 06:32:54 +00:00
SymbolRewriter
TableGen TableGen: Support folding casts from bits to int 2015-07-31 01:12:06 +00:00
Transforms Improve the determinism of MergeFunctions 2015-08-21 23:27:24 +00:00
Unit
Verifier [IR] Add token types 2015-08-14 05:09:07 +00:00
YAMLParser YAML: Implement block scalar parsing. 2015-05-13 23:10:51 +00:00
tools TransformUtils: Introduce module splitter. 2015-08-21 02:48:20 +00:00
.clang-format
CMakeLists.txt TransformUtils: Introduce module splitter. 2015-08-21 02:48:20 +00:00
Makefile
Makefile.tests
TestRunner.sh
lit.cfg TransformUtils: Introduce module splitter. 2015-08-21 02:48:20 +00:00
lit.site.cfg.in Improve lit "native" feature to check if the native backend is builtin 2015-08-04 06:32:31 +00:00