Skip to content

Commit b9b9cb8

Browse files
bors[bot]ptersilie
andauthored
10: Annotate intrinsic calls with inlining decisions. r=ltratt a=ptersilie Co-authored-by: Lukas Diekmann <[email protected]>
2 parents 30c18e4 + 7804cf1 commit b9b9cb8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/lib/Target/X86/X86FastISel.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,17 @@ bool X86FastISel::TryEmitSmallMemcpy(X86AddressMode DestAM,
25882588
return true;
25892589
}
25902590

2591+
// Add an annotation to an intrinsic instruction, specifying whether the
2592+
// intrinsic has been inlined or not.
2593+
void annotateIntrinsic(const IntrinsicInst *II, bool Inlined) {
2594+
IntrinsicInst *CI = const_cast<IntrinsicInst *>(II);
2595+
LLVMContext& C = CI->getContext();
2596+
ConstantInt *CInt;
2597+
CInt = ConstantInt::get(C, APInt(1, Inlined ? 1: 0));
2598+
MDNode* N = MDNode::get(C, ConstantAsMetadata::get(CInt));
2599+
CI->setMetadata("yk.intrinsic.inlined", N);
2600+
}
2601+
25912602
bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
25922603
// FIXME: Handle more intrinsics.
25932604
switch (II->getIntrinsicID()) {
@@ -2725,6 +2736,7 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
27252736
// without a call if possible.
27262737
uint64_t Len = cast<ConstantInt>(MCI->getLength())->getZExtValue();
27272738
if (IsMemcpySmall(Len)) {
2739+
annotateIntrinsic(II, true);
27282740
X86AddressMode DestAM, SrcAM;
27292741
if (!X86SelectAddress(MCI->getRawDest(), DestAM) ||
27302742
!X86SelectAddress(MCI->getRawSource(), SrcAM))
@@ -2741,6 +2753,7 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
27412753
if (MCI->getSourceAddressSpace() > 255 || MCI->getDestAddressSpace() > 255)
27422754
return false;
27432755

2756+
annotateIntrinsic(II, false);
27442757
return lowerCallTo(II, "memcpy", II->getNumArgOperands() - 1);
27452758
}
27462759
case Intrinsic::memset: {

0 commit comments

Comments
 (0)