llvm.org GIT mirror llvm / 696d5d4
Merging r293025: ------------------------------------------------------------------------ r293025 | ahatanak | 2017-01-24 22:21:51 -0800 (Tue, 24 Jan 2017) | 29 lines [SimplifyCFG] Do not sink and merge inline-asm instructions. Conservatively disable sinking and merging inline-asm instructions as doing so can potentially create arguments that cannot satisfy the inline-asm constraints. For example, SimplifyCFG used to do the following transformation: (before) if.then: %0 = call i32 asm "rorl $2, $0", "=&r,0,n"(i32 %r6, i32 8) br label %if.end if.else: %1 = call i32 asm "rorl $2, $0", "=&r,0,n"(i32 %r6, i32 6) br label %if.end (after) %.sink = select i1 %tobool, i32 6, i32 8 %0 = call i32 asm "rorl $2, $0", "=&r,0,n"(i32 %r6, i32 %.sink) This would result in a crash in the backend since only immediate integer operands are permitted for constraint "n". rdar://problem/30110806 Differential Revision: https://reviews.llvm.org/D29111 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293074 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
2 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
14351435 if (isa(I) || I->isEHPad() || isa(I) ||
14361436 I->getType()->isTokenTy())
14371437 return false;
1438
1439 // Conservatively return false if I is an inline-asm instruction. Sinking
1440 // and merging inline-asm instructions can potentially create arguments
1441 // that cannot satisfy the inline-asm constraints.
1442 if (const auto *C = dyn_cast(I))
1443 if (C->isInlineAsm())
1444 return false;
1445
14381446 // Everything must have only one use too, apart from stores which
14391447 // have no uses.
14401448 if (!isa(I) && !I->hasOneUse())
767767 ; CHECK-NOT: exact
768768 ; CHECK: }
769769
770 ; Check that simplifycfg doesn't sink and merge inline-asm instructions.
771
772 define i32 @test_inline_asm1(i32 %c, i32 %r6) {
773 entry:
774 %tobool = icmp eq i32 %c, 0
775 br i1 %tobool, label %if.else, label %if.then
776
777 if.then:
778 %0 = call i32 asm "rorl $2, $0", "=&r,0,n,~{dirflag},~{fpsr},~{flags}"(i32 %r6, i32 8)
779 br label %if.end
780
781 if.else:
782 %1 = call i32 asm "rorl $2, $0", "=&r,0,n,~{dirflag},~{fpsr},~{flags}"(i32 %r6, i32 6)
783 br label %if.end
784
785 if.end:
786 %r6.addr.0 = phi i32 [ %0, %if.then ], [ %1, %if.else ]
787 ret i32 %r6.addr.0
788 }
789
790 ; CHECK-LABEL: @test_inline_asm1(
791 ; CHECK: call i32 asm "rorl $2, $0", "=&r,0,n,~{dirflag},~{fpsr},~{flags}"(i32 %r6, i32 8)
792 ; CHECK: call i32 asm "rorl $2, $0", "=&r,0,n,~{dirflag},~{fpsr},~{flags}"(i32 %r6, i32 6)
793
770794 declare i32 @call_target()
771795
772796 define void @test_operand_bundles(i1 %cond, i32* %ptr) {