Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit bbe0f05

Browse files
committed
[SimplifyCFG] Add test for sinking inline asm in if/else
This test code previously caused a failure in the module verifier, because SimplifyCFG created this invalid instruction, which tries to take the address of inline asm: %.sink = select i1 %1, i64 ()* asm "mov $0, #1", "=r", i64 ()* asm %"mov $0, #2", "=r" This has been fixed recently, presumably by James Molloy's patches that re-wrote and changed parts of SimplifyCFG, so this patch just adds a regression test for it. Differential Revision: https://reviews.llvm.org/D24231 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280660 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7e3e982 commit bbe0f05

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; RUN: opt < %s -simplifycfg -S | FileCheck %s
2+
3+
define i32 @test(i32 %x) {
4+
; CHECK-LABEL: @test
5+
entry:
6+
%y = alloca i32, align 4
7+
%tobool = icmp ne i32 %x, 0
8+
br i1 %tobool, label %if.then, label %if.else
9+
10+
if.then:
11+
; CHECK-LABEL: if.then:
12+
; CHECK: [[ASM1:%.*]] = call i32 asm "mov $0, #1", "=r"()
13+
%tmp1 = call i32 asm "mov $0, #1", "=r"() nounwind readnone
14+
store i32 %tmp1, i32* %y, align 4
15+
br label %if.end
16+
17+
if.else:
18+
; CHECK-LABEL: if.else:
19+
; CHECK: [[ASM2:%.*]] = call i32 asm "mov $0, #2", "=r"()
20+
%tmp2 = call i32 asm "mov $0, #2", "=r"() nounwind readnone
21+
store i32 %tmp2, i32* %y, align 4
22+
br label %if.end
23+
24+
if.end:
25+
; CHECK-LABEL: if.end:
26+
; CHECK: {{%.*}} = phi i32 [ [[ASM2]], %if.else ], [ [[ASM1]], %if.then ]
27+
%tmp3 = load i32, i32* %y, align 4
28+
ret i32 %tmp3
29+
}

0 commit comments

Comments
 (0)