diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index bb95ed3ccdc53a..7ef800a35d9a96 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -2588,6 +2588,17 @@ bool X86FastISel::TryEmitSmallMemcpy(X86AddressMode DestAM, return true; } +// Add an annotation to an intrinsic instruction, specifying whether the +// intrinsic has been inlined or not. +void annotateIntrinsic(const IntrinsicInst *II, bool Inlined) { + IntrinsicInst *CI = const_cast(II); + LLVMContext& C = CI->getContext(); + ConstantInt *CInt; + CInt = ConstantInt::get(C, APInt(1, Inlined ? 1: 0)); + MDNode* N = MDNode::get(C, ConstantAsMetadata::get(CInt)); + CI->setMetadata("yk.intrinsic.inlined", N); +} + bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { // FIXME: Handle more intrinsics. switch (II->getIntrinsicID()) { @@ -2725,6 +2736,7 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { // without a call if possible. uint64_t Len = cast(MCI->getLength())->getZExtValue(); if (IsMemcpySmall(Len)) { + annotateIntrinsic(II, true); X86AddressMode DestAM, SrcAM; if (!X86SelectAddress(MCI->getRawDest(), DestAM) || !X86SelectAddress(MCI->getRawSource(), SrcAM)) @@ -2741,6 +2753,7 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { if (MCI->getSourceAddressSpace() > 255 || MCI->getDestAddressSpace() > 255) return false; + annotateIntrinsic(II, false); return lowerCallTo(II, "memcpy", II->getNumArgOperands() - 1); } case Intrinsic::memset: {