[llvm] [MCA] Enable customization of individual instructions (PR #155420)
Roman Belenov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 18 05:54:27 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:
PS As far as I see, without explicit conversion StringRef with latency value references the content of temporary string in temporary pair which is destroyed immediately after this statement.
https://github.com/llvm/llvm-project/pull/155420
More information about the llvm-commits
mailing list