2011-01-29 12:46:23 +08:00
|
|
|
; RUN: opt < %s -jump-threading -S | FileCheck %s
|
2016-06-14 08:51:09 +08:00
|
|
|
; RUN: opt < %s -passes=jump-threading -S | FileCheck %s
|
2008-11-27 13:07:53 +08:00
|
|
|
|
|
|
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
|
|
|
target triple = "i386-apple-darwin7"
|
|
|
|
|
2012-03-14 02:07:41 +08:00
|
|
|
; Test that we can thread through the block with the partially redundant load (%2).
|
|
|
|
; rdar://6402033
|
|
|
|
define i32 @test1(i32* %P) nounwind {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2008-11-27 13:07:53 +08:00
|
|
|
entry:
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
%0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1]
|
2008-11-27 13:07:53 +08:00
|
|
|
%1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb: ; preds = %entry
|
2011-01-29 12:46:23 +08:00
|
|
|
; CHECK: bb1.thread:
|
|
|
|
; CHECK: store
|
|
|
|
; CHECK: br label %bb3
|
2008-11-27 13:07:53 +08:00
|
|
|
store i32 42, i32* %P, align 4
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1: ; preds = %entry, %bb
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] ; <i32> [#uses=2]
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %P, align 4 ; <i32> [#uses=1]
|
2008-11-27 13:07:53 +08:00
|
|
|
%3 = icmp sgt i32 %2, 36 ; <i1> [#uses=1]
|
|
|
|
br i1 %3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2: ; preds = %bb1
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
%4 = tail call i32 (...) @f2() nounwind ; <i32> [#uses=0]
|
2008-11-27 13:07:53 +08:00
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3: ; preds = %bb1
|
2011-01-29 12:46:23 +08:00
|
|
|
; CHECK: bb3:
|
|
|
|
; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ]
|
|
|
|
; CHECK: ret i32 %res.01
|
2008-11-27 13:07:53 +08:00
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @f1(...)
|
|
|
|
|
|
|
|
declare i32 @f2(...)
|
2012-03-14 02:07:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
;; Check that we preserve TBAA information.
|
|
|
|
; rdar://11039258
|
|
|
|
|
|
|
|
define i32 @test2(i32* %P) nounwind {
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2012-03-14 02:07:41 +08:00
|
|
|
entry:
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
%0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1]
|
2012-03-14 02:07:41 +08:00
|
|
|
%1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
|
|
|
|
br i1 %1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb: ; preds = %entry
|
|
|
|
; CHECK: bb1.thread:
|
|
|
|
; CHECK: store{{.*}}, !tbaa !0
|
|
|
|
; CHECK: br label %bb3
|
|
|
|
store i32 42, i32* %P, align 4, !tbaa !0
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1: ; preds = %entry, %bb
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i32, i32* %P, align 4, !tbaa !0
|
2012-03-14 02:07:41 +08:00
|
|
|
%3 = icmp sgt i32 %2, 36
|
|
|
|
br i1 %3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2: ; preds = %bb1
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
%4 = tail call i32 (...) @f2() nounwind
|
2012-03-14 02:07:41 +08:00
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3: ; preds = %bb1
|
|
|
|
; CHECK: bb3:
|
|
|
|
; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ]
|
|
|
|
; CHECK: ret i32 %res.01
|
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
2014-10-20 13:34:36 +08:00
|
|
|
define i32 @test3(i8** %x, i1 %f) {
|
|
|
|
; Correctly thread loads of different (but compatible) types, placing bitcasts
|
|
|
|
; as necessary in the predecessors. This is especially tricky because the same
|
|
|
|
; predecessor ends up with two entries in the PHI node and they must share
|
|
|
|
; a single cast.
|
|
|
|
; CHECK-LABEL: @test3(
|
|
|
|
entry:
|
|
|
|
%0 = bitcast i8** %x to i32**
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32*, i32** %0, align 8
|
2014-10-20 13:34:36 +08:00
|
|
|
br i1 %f, label %if.end57, label %if.then56
|
2015-02-28 05:17:42 +08:00
|
|
|
; CHECK: %[[LOAD:.*]] = load i32*, i32**
|
2014-10-20 13:34:36 +08:00
|
|
|
; CHECK: %[[CAST:.*]] = bitcast i32* %[[LOAD]] to i8*
|
|
|
|
|
|
|
|
if.then56:
|
|
|
|
br label %if.end57
|
|
|
|
|
|
|
|
if.end57:
|
2015-02-28 05:17:42 +08:00
|
|
|
%2 = load i8*, i8** %x, align 8
|
2014-10-20 13:34:36 +08:00
|
|
|
%tobool59 = icmp eq i8* %2, null
|
|
|
|
br i1 %tobool59, label %return, label %if.then60
|
|
|
|
; CHECK: %[[PHI:.*]] = phi i8* [ %[[CAST]], %[[PRED:[^ ]+]] ], [ %[[CAST]], %[[PRED]] ]
|
|
|
|
; CHECK-NEXT: %[[CMP:.*]] = icmp eq i8* %[[PHI]], null
|
|
|
|
; CHECK-NEXT: br i1 %[[CMP]]
|
|
|
|
|
|
|
|
if.then60:
|
|
|
|
ret i32 42
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret i32 13
|
|
|
|
}
|
|
|
|
|
2016-07-15 03:21:15 +08:00
|
|
|
define i32 @test4(i32* %P) {
|
|
|
|
; CHECK-LABEL: @test4(
|
|
|
|
entry:
|
|
|
|
%v0 = tail call i32 (...) @f1()
|
|
|
|
%v1 = icmp eq i32 %v0, 0
|
|
|
|
br i1 %v1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
; CHECK: bb1.thread:
|
|
|
|
; CHECK: store atomic
|
|
|
|
; CHECK: br label %bb3
|
|
|
|
store atomic i32 42, i32* %P unordered, align 4
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
; CHECK: bb1:
|
|
|
|
; CHECK-NOT: phi
|
|
|
|
; CHECK: load atomic
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
%v2 = load atomic i32, i32* %P unordered, align 4
|
|
|
|
%v3 = icmp sgt i32 %v2, 36
|
|
|
|
br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2:
|
|
|
|
%v4 = tail call i32 (...) @f2()
|
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3:
|
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test5(i32* %P) {
|
|
|
|
; Negative test
|
|
|
|
|
|
|
|
; CHECK-LABEL: @test5(
|
|
|
|
entry:
|
|
|
|
%v0 = tail call i32 (...) @f1()
|
|
|
|
%v1 = icmp eq i32 %v0, 0
|
|
|
|
br i1 %v1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
; CHECK: bb:
|
|
|
|
; CHECK-NEXT: store atomic i32 42, i32* %P release, align 4
|
|
|
|
; CHECK-NEXT: br label %bb1
|
|
|
|
store atomic i32 42, i32* %P release, align 4
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
; CHECK: bb1:
|
|
|
|
; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36
|
|
|
|
; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
%v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
%v3 = icmp sgt i32 %v2, 36
|
|
|
|
br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2:
|
|
|
|
%v4 = tail call i32 (...) @f2()
|
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3:
|
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test6(i32* %P) {
|
|
|
|
; Negative test
|
|
|
|
|
|
|
|
; CHECK-LABEL: @test6(
|
|
|
|
entry:
|
|
|
|
%v0 = tail call i32 (...) @f1()
|
|
|
|
%v1 = icmp eq i32 %v0, 0
|
|
|
|
br i1 %v1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
; CHECK: bb:
|
|
|
|
; CHECK-NEXT: store i32 42, i32* %P
|
|
|
|
; CHECK-NEXT: br label %bb1
|
|
|
|
store i32 42, i32* %P
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
; CHECK: bb1:
|
|
|
|
; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36
|
|
|
|
; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
%v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
%v3 = icmp sgt i32 %v2, 36
|
|
|
|
br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2:
|
|
|
|
%v4 = tail call i32 (...) @f2()
|
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3:
|
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test7(i32* %P) {
|
|
|
|
; Negative test
|
|
|
|
|
|
|
|
; CHECK-LABEL: @test7(
|
|
|
|
entry:
|
|
|
|
%v0 = tail call i32 (...) @f1()
|
|
|
|
%v1 = icmp eq i32 %v0, 0
|
|
|
|
br i1 %v1, label %bb1, label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
; CHECK: bb:
|
|
|
|
; CHECK-NEXT: %val = load i32, i32* %P
|
|
|
|
; CHECK-NEXT: br label %bb1
|
|
|
|
%val = load i32, i32* %P
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
; CHECK: bb1:
|
|
|
|
; CHECK-NEXT: %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
; CHECK-NEXT: %v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
; CHECK-NEXT: %v3 = icmp sgt i32 %v2, 36
|
|
|
|
; CHECK-NEXT: br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
%res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
|
|
|
|
%v2 = load atomic i32, i32* %P acquire, align 4
|
|
|
|
%v3 = icmp sgt i32 %v2, 36
|
|
|
|
br i1 %v3, label %bb3, label %bb2
|
|
|
|
|
|
|
|
bb2:
|
|
|
|
%v4 = tail call i32 (...) @f2()
|
|
|
|
ret i32 %res.0
|
|
|
|
|
|
|
|
bb3:
|
|
|
|
ret i32 %res.0
|
|
|
|
}
|
|
|
|
|
2016-08-08 12:10:22 +08:00
|
|
|
; Make sure we merge the aliasing metadata. (If we don't, we have a load
|
|
|
|
; with the wrong metadata, so the branch gets incorrectly eliminated.)
|
|
|
|
define void @test8(i32*, i32*, i32*) {
|
|
|
|
; CHECK-LABEL: @test8(
|
|
|
|
; CHECK: %a = load i32, i32* %0, !range !4
|
|
|
|
; CHECK-NEXT: store i32 %a
|
|
|
|
; CHECK: br i1 %c
|
|
|
|
%a = load i32, i32* %0, !tbaa !0, !range !4, !alias.scope !9, !noalias !10
|
|
|
|
%b = load i32, i32* %0, !range !5
|
|
|
|
store i32 %a, i32* %1
|
|
|
|
%c = icmp eq i32 %b, 8
|
|
|
|
br i1 %c, label %ret1, label %ret2
|
|
|
|
|
|
|
|
ret1:
|
|
|
|
ret void
|
|
|
|
|
|
|
|
ret2:
|
|
|
|
%xxx = tail call i32 (...) @f1() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Make sure we merge/PRE aliasing metadata correctly. That means that
|
|
|
|
; we need to remove metadata from the existing load, and add appropriate
|
|
|
|
; metadata to the newly inserted load.
|
|
|
|
define void @test9(i32*, i32*, i32*, i1 %c) {
|
|
|
|
; CHECK-LABEL: @test9(
|
|
|
|
br i1 %c, label %d1, label %d2
|
|
|
|
|
|
|
|
; CHECK: d1:
|
|
|
|
; CHECK-NEXT: %a = load i32, i32* %0{{$}}
|
|
|
|
d1:
|
|
|
|
%a = load i32, i32* %0, !range !4, !alias.scope !9, !noalias !10
|
|
|
|
br label %d3
|
|
|
|
|
|
|
|
; CHECK: d2:
|
|
|
|
; CHECK-NEXT: %xxxx = tail call i32 (...) @f1()
|
|
|
|
; CHECK-NEXT: %b.pr = load i32, i32* %0, !tbaa !0{{$}}
|
|
|
|
d2:
|
|
|
|
%xxxx = tail call i32 (...) @f1() nounwind
|
|
|
|
br label %d3
|
|
|
|
|
|
|
|
d3:
|
|
|
|
%p = phi i32 [ 1, %d2 ], [ %a, %d1 ]
|
|
|
|
%b = load i32, i32* %0, !tbaa !0
|
|
|
|
store i32 %p, i32* %1
|
|
|
|
%c2 = icmp eq i32 %b, 8
|
|
|
|
br i1 %c2, label %ret1, label %ret2
|
|
|
|
|
|
|
|
ret1:
|
|
|
|
ret void
|
|
|
|
|
|
|
|
ret2:
|
|
|
|
%xxx = tail call i32 (...) @f1() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!0 = !{!3, !3, i64 0}
|
|
|
|
!1 = !{!"omnipotent char", !2}
|
[Verifier] Add verification for TBAA metadata
Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.
Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:
- That by the time an struct access tuple `(base-type, offset)` is
"reduced" to a scalar base type, the offset is `0`. For instance, in
C++ you can't start from, say `("struct-a", 16)`, and end up with
`("int", 4)` -- by the time the base type is `"int"`, the offset
better be zero. In particular, a variant of this invariant is needed
for `llvm::getMostGenericTBAA` to be correct.
- That there are no cycles in a struct path.
- That struct type nodes have their offsets listed in an ascending
order.
- That when generating the struct access path, you eventually reach the
access type listed in the tbaa tag node.
Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren
Subscribers: mcrosier, llvm-commits
Differential Revision: https://reviews.llvm.org/D26438
llvm-svn: 289402
2016-12-12 04:07:15 +08:00
|
|
|
!2 = !{!"Simple C/C++ TBAA"}
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
|
|
|
!3 = !{!"int", !1}
|
2016-08-08 12:10:22 +08:00
|
|
|
!4 = !{ i32 0, i32 1 }
|
|
|
|
!5 = !{ i32 8, i32 10 }
|
|
|
|
!6 = !{!6}
|
|
|
|
!7 = !{!7, !6}
|
|
|
|
!8 = !{!8, !6}
|
|
|
|
!9 = !{!7}
|
|
|
|
!10 = !{!8}
|