forked from OSchip/llvm-project
[X86] Add codegen prepare test exercising a bitcast + tail call
In preparation of https://reviews.llvm.org/D60837, add this test where we don't perform a tail call because we don't look through a bitcast. llvm-svn: 359040
This commit is contained in:
parent
fb59fef7dc
commit
eea9da5921
|
@ -1,4 +1,6 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
|
||||
; RUN: opt -S -codegenprepare %s -mtriple=x86_64-apple-darwin -o - | FileCheck %s --check-prefix OPT
|
||||
|
||||
; Teach CGP to dup returns to enable tail call optimization.
|
||||
; rdar://9147433
|
||||
|
@ -105,3 +107,43 @@ land.end: ; preds = %entry, %land.rhs
|
|||
ret i1 %0
|
||||
}
|
||||
|
||||
; We need to look through bitcasts when looking for tail calls in phi incoming
|
||||
; values.
|
||||
declare i32* @g_ret32()
|
||||
define i8* @f_ret8(i8* %obj) nounwind {
|
||||
; OPT-LABEL: @f_ret8(
|
||||
; OPT-NEXT: entry:
|
||||
; OPT-NEXT: [[CMP:%.*]] = icmp eq i8* [[OBJ:%.*]], null
|
||||
; OPT-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[IF_THEN:%.*]]
|
||||
; OPT: if.then:
|
||||
; OPT-NEXT: [[PTR:%.*]] = tail call i32* @g_ret32()
|
||||
; OPT-NEXT: [[CASTED:%.*]] = bitcast i32* [[PTR]] to i8*
|
||||
; OPT-NEXT: br label [[RETURN]]
|
||||
; OPT: return:
|
||||
; OPT-NEXT: [[RETVAL:%.*]] = phi i8* [ [[CASTED]], [[IF_THEN]] ], [ [[OBJ]], [[ENTRY:%.*]] ]
|
||||
; OPT-NEXT: ret i8* [[RETVAL]]
|
||||
;
|
||||
; CHECK-LABEL: f_ret8:
|
||||
; CHECK: ## %bb.0: ## %entry
|
||||
; CHECK-NEXT: movq %rdi, %rax
|
||||
; CHECK-NEXT: testq %rdi, %rdi
|
||||
; CHECK-NEXT: je LBB3_2
|
||||
; CHECK-NEXT: ## %bb.1: ## %if.then
|
||||
; CHECK-NEXT: pushq %rax
|
||||
; CHECK-NEXT: callq _g_ret32
|
||||
; CHECK-NEXT: addq $8, %rsp
|
||||
; CHECK-NEXT: LBB3_2: ## %return
|
||||
; CHECK-NEXT: retq
|
||||
entry:
|
||||
%cmp = icmp eq i8* %obj, null
|
||||
br i1 %cmp, label %return, label %if.then
|
||||
|
||||
if.then:
|
||||
%ptr = tail call i32* @g_ret32()
|
||||
%casted = bitcast i32* %ptr to i8*
|
||||
br label %return
|
||||
|
||||
return:
|
||||
%retval = phi i8* [ %casted, %if.then ], [ %obj, %entry ]
|
||||
ret i8* %retval
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue