[llvm] [MCA] Enable customization of individual instructions (PR #155420)
Roman Belenov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 03:57:33 PDT 2025
================
@@ -234,3 +234,27 @@ TEST_F(X86TestBase, TestVariantInstructionsSameAddress) {
Expected<unsigned> Cycles = P->run();
ASSERT_TRUE(static_cast<bool>(Cycles));
}
+
+// Test customization of instruction latency with instruments
+TEST_F(X86TestBase, TestInstructionCustomization) {
+ const unsigned ExplicitLatency = 100;
+ SmallVector<MCInst> MCIs;
+ MCInst InstructionToAdd = MCInstBuilder(X86::XOR64rr)
+ .addReg(X86::RAX)
+ .addReg(X86::RAX)
+ .addReg(X86::RAX);
+ MCIs.push_back(InstructionToAdd);
+ SmallVector<std::pair<StringRef, StringRef>> InstrDescs;
+ auto LatStr = std::to_string(ExplicitLatency);
+ InstrDescs.push_back(std::make_pair(StringRef("LATENCY"), StringRef(LatStr)));
----------------
r-belenov wrote:
I tried and had no issues with local build and test, but it led to UT failure in github CI. Note that conversion omission leads to creation of temporary pair (since make_pair construct pair<char*,string>) and it looks that it causes UB here.
https://github.com/llvm/llvm-project/pull/155420
More information about the llvm-commits
mailing list