[PATCH] D12376: Remove Merge Functions pointer comparisons

Jason Koenig via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 11:45:11 PDT 2015


jrkoenig created this revision.
jrkoenig added reviewers: jfb, dschuff, nlewycky.
jrkoenig added a subscriber: llvm-commits.

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.

http://reviews.llvm.org/D12376

Files:
  lib/Transforms/IPO/MergeFunctions.cpp
  test/Transforms/MergeFunc/merge-block-address-other-function.ll
  test/Transforms/MergeFunc/merge-block-address.ll
  test/Transforms/MergeFunc/no-merge-block-address-different-labels.ll
  test/Transforms/MergeFunc/no-merge-block-address-other-function.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12376.33232.patch
Type: text/x-patch
Size: 18582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150826/6a4d2ddd/attachment.bin>


More information about the llvm-commits mailing list