Remove Merge Functions pointer comparisons
authorJF Bastien <jfb@google.com>
Fri, 28 Aug 2015 16:49:09 +0000 (16:49 +0000)
committerJF Bastien <jfb@google.com>
Fri, 28 Aug 2015 16:49:09 +0000 (16:49 +0000)
commit1616e55c95455e001a705b3876785a0f72963f88
treee874b33c13235b623bf7d430f46eb18c9e79119f
parentc03acbca56b21439a306a5f2cbae2e4bf6ce22f9
Remove Merge Functions pointer comparisons

Summary:
This patch removes two remaining places where pointer value comparisons
are used to order functions: comparing range annotation metadata, and comparing
block address constants. (These are both rare cases, and so no actual
non-determinism was observed from either case).

The fix for range metadata is simple: the annotation always consists of a pair
of integers, so we just order by those integers.

The fix for block addresses is more subtle. Two constants are the same if they
are the same basic block in the same function, or if they refer to corresponding
basic blocks in each respective function. Note that in the first case, merging
is trivially correct. In the second, the correctness of merging relies on the
fact that the the values of block addresses cannot be compared. This change is
actually an enhancement, as these functions could not previously be merged (see
merge-block-address.ll).

There is still a problem with cross function block addresses, in that constants
pointing to a basic block in a merged function is not updated.

This also more robustly compares floating point constants by all fields of their
semantics, and fixes a dyn_cast/cast mixup.

Author: jrkoenig
Reviewers: dschuff, nlewycky, jfb
Subscribers llvm-commits
Differential revision: http://reviews.llvm.org/D12376

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246305 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/MergeFunctions.cpp
test/Transforms/MergeFunc/merge-block-address-other-function.ll [new file with mode: 0644]
test/Transforms/MergeFunc/merge-block-address.ll [new file with mode: 0644]
test/Transforms/MergeFunc/no-merge-block-address-different-labels.ll [new file with mode: 0644]
test/Transforms/MergeFunc/no-merge-block-address-other-function.ll [new file with mode: 0644]
test/Transforms/MergeFunc/ranges-multiple.ll [new file with mode: 0644]