Callee, CallArgs, MD);
if (nv_r || v_r) {
// Do the return result adjustment.
- RV = RValue::get(DynamicTypeAdjust(RV.getScalarVal(), nv_r, v_r));
+ llvm::BasicBlock *NonZeroBlock = createBasicBlock();
+ llvm::BasicBlock *ZeroBlock = createBasicBlock();
+ llvm::BasicBlock *ContBlock = createBasicBlock();
+
+ const llvm::Type *Ty = RV.getScalarVal()->getType();
+ llvm::Value *Zero = llvm::Constant::getNullValue(Ty);
+ Builder.CreateCondBr(Builder.CreateICmpNE(RV.getScalarVal(), Zero),
+ NonZeroBlock, ZeroBlock);
+ EmitBlock(NonZeroBlock);
+ llvm::Value *NZ = DynamicTypeAdjust(RV.getScalarVal(), nv_r, v_r);
+ EmitBranch(ContBlock);
+ EmitBlock(ZeroBlock);
+ llvm::Value *Z = RV.getScalarVal();
+ EmitBlock(ContBlock);
+ llvm::PHINode *RVOrZero = Builder.CreatePHI(Ty);
+ RVOrZero->reserveOperandSpace(2);
+ RVOrZero->addIncoming(NZ, NonZeroBlock);
+ RVOrZero->addIncoming(Z, ZeroBlock);
+ RV = RValue::get(RVOrZero);
}
if (!ResultType->isVoidType())
// CHECK-LPOPT64-NEXT: subq $8, %rsp
// CHECK-LPOPT64-NEXT:Llabel
// CHECK-LPOPT64-NEXT: call __ZN8test16_D4foo1Ev
-// FIXME: We need a == 0 check here
+// CHECK-LPOPT64-NEXT: testq %rax, %rax
+// CHECK-LPOPT64-NEXT: je LBB102_2
// CHECK-LPOPT64-NEXT: movq 16(%rax), %rcx
// CHECK-LPOPT64-NEXT: movq -32(%rcx), %rcx
// CHECK-LPOPT64-NEXT: leaq 16(%rcx,%rax), %rax
// CHECK-LPOPT64-NEXT: addq $8, %rsp
// CHECK-LPOPT64-NEXT: ret
+// CHECK-LPOPT64-NEXT:LBB102_2:
+// CHECK-LPOPT64-NEXT: addq $8, %rsp
+// CHECK-LPOPT64-NEXT: ret
class test17_B1 {