diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index ff1ad712f93d..709965ba1515 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -955,6 +955,14 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, .addUse(getOrCreateVReg(*CI.getArgOperand(0))); return true; } + case Intrinsic::invariant_start: { + LLT PtrTy = getLLTForType(*CI.getArgOperand(0)->getType(), *DL); + unsigned Undef = MRI->createGenericVirtualRegister(PtrTy); + MIRBuilder.buildUndef(Undef); + return true; + } + case Intrinsic::invariant_end: + return true; } return false; } diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll index a2bbc27fd3b2..a021eeda353b 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll @@ -2207,3 +2207,17 @@ define void @test_blockaddress() { block: ret void } + +%t = type { i32 } +declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) readonly nounwind +declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind +define void @test_invariant_intrin() { +; CHECK-LABEL: name: test_invariant_intrin +; CHECK: %{{[0-9]+}}:_(s64) = G_IMPLICIT_DEF +; CHECK-NEXT: RET_ReallyLR + %x = alloca %t + %y = bitcast %t* %x to i8* + %inv = call {}* @llvm.invariant.start.p0i8(i64 8, i8* %y) + call void @llvm.invariant.end.p0i8({}* %inv, i64 8, i8* %y) + ret void +}