1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/test/Transforms/MergeFunc/ranges-multiple.ll
JF Bastien 940c24167e 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

llvm-svn: 246305
2015-08-28 16:49:09 +00:00

45 lines
1.2 KiB
LLVM

; RUN: opt -mergefunc -S < %s | FileCheck %s
define i1 @cmp_with_range(i8*, i8*) {
%v1 = load i8, i8* %0, !range !0
%v2 = load i8, i8* %1, !range !0
%out = icmp eq i8 %v1, %v2
ret i1 %out
}
define i1 @cmp_no_range(i8*, i8*) {
; CHECK-LABEL: @cmp_no_range
; CHECK-NEXT: %v1 = load i8, i8* %0
; CHECK-NEXT: %v2 = load i8, i8* %1
; CHECK-NEXT: %out = icmp eq i8 %v1, %v2
; CHECK-NEXT: ret i1 %out
%v1 = load i8, i8* %0
%v2 = load i8, i8* %1
%out = icmp eq i8 %v1, %v2
ret i1 %out
}
define i1 @cmp_different_range(i8*, i8*) {
; CHECK-LABEL: @cmp_different_range
; CHECK-NEXT: %v1 = load i8, i8* %0, !range !1
; CHECK-NEXT: %v2 = load i8, i8* %1, !range !1
; CHECK-NEXT: %out = icmp eq i8 %v1, %v2
; CHECK-NEXT: ret i1 %out
%v1 = load i8, i8* %0, !range !1
%v2 = load i8, i8* %1, !range !1
%out = icmp eq i8 %v1, %v2
ret i1 %out
}
define i1 @cmp_with_same_range(i8*, i8*) {
; CHECK-LABEL: @cmp_with_same_range
; CHECK: tail call i1 @cmp_with_range
%v1 = load i8, i8* %0, !range !0
%v2 = load i8, i8* %1, !range !0
%out = icmp eq i8 %v1, %v2
ret i1 %out
}
; The comparison must check every element of the range, not just the first pair.
!0 = !{i8 0, i8 2, i8 21, i8 30}
!1 = !{i8 0, i8 2, i8 21, i8 25}