From: Tim Northover Date: Tue, 18 Oct 2016 20:03:51 +0000 (+0000) Subject: GlobalISel: translate the @llvm.objectsize intrinsic. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e9043009ed79a64a6df648f5c5c5a55bc0cee70;p=platform%2Fupstream%2Fllvm.git GlobalISel: translate the @llvm.objectsize intrinsic. llvm-svn: 284527 --- diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index e073717..dd64cc7 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -392,6 +392,13 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, case Intrinsic::smul_with_overflow: Op = TargetOpcode::G_SMULO; break; case Intrinsic::memcpy: return translateMemcpy(CI); + case Intrinsic::objectsize: { + // If we don't know by now, we're never going to know. + const ConstantInt *Min = cast(CI.getArgOperand(1)); + + MIRBuilder.buildConstant(getOrCreateVReg(CI), Min->isZero() ? -1ULL : 0); + return true; + } } LLT Ty{*CI.getOperand(0)->getType(), *DL}; diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll index 29c2d9b..be69cfa 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll @@ -881,3 +881,20 @@ define void @test_memcpy(i8* %dst, i8* %src, i64 %size) { call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %size, i32 1, i1 0) ret void } + +declare i64 @llvm.objectsize.i64(i8*, i1) +declare i32 @llvm.objectsize.i32(i8*, i1) +define void @test_objectsize(i8* %addr0, i8* %addr1) { +; CHECK-LABEL: name: test_objectsize +; CHECK: [[ADDR0:%[0-9]+]](p0) = COPY %x0 +; CHECK: [[ADDR1:%[0-9]+]](p0) = COPY %x1 +; CHECK: {{%[0-9]+}}(s64) = G_CONSTANT -1 +; CHECK: {{%[0-9]+}}(s64) = G_CONSTANT 0 +; CHECK: {{%[0-9]+}}(s32) = G_CONSTANT -1 +; CHECK: {{%[0-9]+}}(s32) = G_CONSTANT 0 + %size64.0 = call i64 @llvm.objectsize.i64(i8* %addr0, i1 0) + %size64.intmin = call i64 @llvm.objectsize.i64(i8* %addr0, i1 1) + %size32.0 = call i32 @llvm.objectsize.i32(i8* %addr0, i1 0) + %size32.intmin = call i32 @llvm.objectsize.i32(i8* %addr0, i1 1) + ret void +}