diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 27807f29024..96b652d39e0 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -1166,6 +1166,30 @@ bool X86FastISel::X86VisitIntrinsicCall(IntrinsicInst &I) { // FIXME: Handle more intrinsics. switch (I.getIntrinsicID()) { default: return false; + case Intrinsic::objectsize: { + ConstantInt *CI = dyn_cast(I.getOperand(2)); + const Type *Ty = I.getCalledFunction()->getReturnType(); + + assert(CI && "Non-constant type in Intrinsic::objectsize?"); + + EVT VT; + if (!isTypeLegal(Ty, VT)) + return false; + + unsigned OpC = 0; + if (VT == MVT::i32) + OpC = X86::MOV32ri; + else if (VT == MVT::i64) + OpC = X86::MOV64ri; + else + return false; + + unsigned ResultReg = createResultReg(TLI.getRegClassFor(VT)); + BuildMI(MBB, DL, TII.get(OpC), ResultReg). + addImm(CI->getZExtValue() == 0 ? -1ULL : 0); + UpdateValueMap(&I, ResultReg); + return true; + } case Intrinsic::dbg_declare: { DbgDeclareInst *DI = cast(&I); X86AddressMode AM; diff --git a/test/CodeGen/X86/object-size.ll b/test/CodeGen/X86/object-size.ll index eed3cfc8513..bbe6b2341e5 100644 --- a/test/CodeGen/X86/object-size.ll +++ b/test/CodeGen/X86/object-size.ll @@ -12,7 +12,7 @@ entry: %tmp = load i8** @p ; [#uses=1] %0 = call i64 @llvm.objectsize.i64(i8* %tmp, i1 0) ; [#uses=1] %cmp = icmp ne i64 %0, -1 ; [#uses=1] -; X64: movq $-1, %rax +; X64: movabsq $-1, %rax ; X64: cmpq $-1, %rax br i1 %cmp, label %cond.true, label %cond.false