aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/CodeGen/MachineInstrTest.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2020-04-07 13:09:29 -0700
committerVedant Kumar <vsk@apple.com>2020-04-08 11:06:14 -0700
commit48e65fc63076eec4fa527ab7b22fdcb4d8cdbb50 (patch)
tree43ba44e4ca1bdd32d2a1ff13df1bcf607894ba73 /llvm/unittests/CodeGen/MachineInstrTest.cpp
parentbe3f8a8e1b95db1a8bdcc7a66ba27f8a6ea65469 (diff)
downloadllvm-48e65fc63076eec4fa527ab7b22fdcb4d8cdbb50.zip
llvm-48e65fc63076eec4fa527ab7b22fdcb4d8cdbb50.tar.gz
llvm-48e65fc63076eec4fa527ab7b22fdcb4d8cdbb50.tar.bz2
MachineFunction: Copy call site info when duplicating insts
Summary: Preserve call site info for duplicated instructions. We copy over the call site info in CloneMachineInstrBundle to avoid repeated calls to copyCallSiteInfo in CloneMachineInstr. (Alternatively, we could copy call site info higher up the stack, e.g. into TargetInstrInfo::duplicate, or even into individual backend passes. However, I don't see how that would be safer or more general than the current approach.) Reviewers: aprantl, djtodoro, dstenb Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77685
Diffstat (limited to 'llvm/unittests/CodeGen/MachineInstrTest.cpp')
-rw-r--r--llvm/unittests/CodeGen/MachineInstrTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp
index 33baaf62..71c4b8e 100644
--- a/llvm/unittests/CodeGen/MachineInstrTest.cpp
+++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp
@@ -383,6 +383,26 @@ TEST(MachineInstrExtraInfo, RemoveExtraInfo) {
ASSERT_FALSE(MI->getHeapAllocMarker());
}
+TEST(MachineInstrClone, CopyCallSiteInfo) {
+ LLVMContext Ctx;
+ Module Mod("Module", Ctx);
+ auto MF = createMachineFunction(Ctx, Mod);
+ auto MBB = MF->CreateMachineBasicBlock();
+ auto MII = MBB->begin();
+
+ MCInstrDesc MCID = {0, 0, 0, 0, 0, (1ULL << MCID::Call),
+ 0, nullptr, nullptr, nullptr};
+
+ MachineFunction::CallSiteInfo CSInfo;
+ auto MI = MF->CreateMachineInstr(MCID, DebugLoc());
+ ASSERT_TRUE(MI->isCandidateForCallSiteEntry());
+ MBB->insert(MII, MI);
+ MF->addCallArgsForwardingRegs(MI, std::move(CSInfo));
+ EXPECT_EQ(MF->getCallSitesInfo().size(), 1u);
+ MF->CloneMachineInstrBundle(*MBB, MBB->end(), *MI);
+ EXPECT_EQ(MF->getCallSitesInfo().size(), 2u);
+}
+
static_assert(is_trivially_copyable<MCOperand>::value, "trivially copyable");
} // end namespace