mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-01 01:15:55 +00:00

We can't create metadata-valued PHIs; don't try to do so when sinking. I created a test case for this using the @llvm.type.test intrinsic, because it takes a metadata parameter and does not have severe side effects (thus SimplifyCFG is willing to otherwise sink it). Previously, running the test case would crash with: Invalid use of metadata! %.sink = select i1 %flag, metadata <...>, metadata <0x4e45dc0> LLVM ERROR: Broken function found, compilation aborted! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280866 91177308-0d34-0410-b5e6-96231b3b80d8
52 lines
1.1 KiB
LLVM
52 lines
1.1 KiB
LLVM
; RUN: opt < %s -simplifycfg -S | FileCheck %s
|
|
|
|
define i1 @test1(i1 zeroext %flag, i8* %y) #0 {
|
|
entry:
|
|
br i1 %flag, label %if.then, label %if.else
|
|
|
|
if.then:
|
|
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
|
|
br label %if.end
|
|
|
|
if.else:
|
|
%s = call i1 @llvm.type.test(i8* %y, metadata !1)
|
|
br label %if.end
|
|
|
|
if.end:
|
|
%t = phi i1 [ %s, %if.else ], [ %r, %if.then ]
|
|
ret i1 %t
|
|
}
|
|
|
|
!0 = !{i32 0, !"typeid1"}
|
|
!1 = !{i32 4, !"typeid1"}
|
|
|
|
declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
|
|
|
|
; CHECK-LABEL: test1
|
|
; CHECK: @llvm.type.test
|
|
; CHECK: @llvm.type.test
|
|
; CHECK: ret i1
|
|
|
|
define i1 @test2(i1 zeroext %flag, i8* %y, i8* %z) #0 {
|
|
entry:
|
|
br i1 %flag, label %if.then, label %if.else
|
|
|
|
if.then:
|
|
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
|
|
br label %if.end
|
|
|
|
if.else:
|
|
%s = call i1 @llvm.type.test(i8* %z, metadata !0)
|
|
br label %if.end
|
|
|
|
if.end:
|
|
%t = phi i1 [ %s, %if.else ], [ %r, %if.then ]
|
|
ret i1 %t
|
|
}
|
|
|
|
; CHECK-LABEL: test2
|
|
; CHECK: %[[S:[a-z0-9.]+]] = select i1 %flag, i8* %y, i8* %z
|
|
; CHECK: %[[R:[a-z0-9.]+]] = call i1 @llvm.type.test(i8* %[[S]], metadata !0)
|
|
; CHECK: ret i1 %[[R]]
|
|
|