Have fast-isel understand llvm.objectsize. Update testcase for slightly

different codegen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98244 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2010-03-11 06:20:22 +00:00
parent 6220754525
commit f27805b5c5
2 changed files with 25 additions and 1 deletions

View File

@ -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<ConstantInt>(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<DbgDeclareInst>(&I);
X86AddressMode AM;

View File

@ -12,7 +12,7 @@ entry:
%tmp = load i8** @p ; <i8*> [#uses=1]
%0 = call i64 @llvm.objectsize.i64(i8* %tmp, i1 0) ; <i64> [#uses=1]
%cmp = icmp ne i64 %0, -1 ; <i1> [#uses=1]
; X64: movq $-1, %rax
; X64: movabsq $-1, %rax
; X64: cmpq $-1, %rax
br i1 %cmp, label %cond.true, label %cond.false