<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Tatyana,<div class=""><br class=""></div><div class="">Thank you for your reply! π</div><div class=""><br class=""></div><div class="">If I understand correctly, <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">TargetOpcode::G_{LOAD, STORE}</span></font> do not cover x86βs <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">mov</span></font> instructions (and other relevant instructions of both x86 the rest of supported architectures) and such, which also access memory, however I will look into it more.</div><div class=""><br class=""></div><div class="">Additionally, thank you for the suggestion regarding <font face="FiraCode-Regular" class=""><span style="font-style: normal;" class="">llvm-dev</span></font> βI will forward my email to that list, too.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">β Vangelis</div><div class=""><br class=""></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 7 Nov 2019, at 13:49, Tatyana Krasnukha <<a href="mailto:Tatyana.Krasnukha@synopsys.com" class="">Tatyana.Krasnukha@synopsys.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: SFProText-Regular; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi Vangelis,<o:p class=""></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Not sure this will help you, but you can try to compare llvm::MachineInstr::getOpcode() with TargetOpcode::G_LOAD and TargetOpcode::G_STORE if you can obtain a MachineInstr instance.<o:p class=""></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">It also may have sense to ask llvm-dev for a proper solution.<o:p class=""></o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0in 0in;" class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>lldb-dev <<a href="mailto:lldb-dev-bounces@lists.llvm.org" class="">lldb-dev-bounces@lists.llvm.org</a>><span class="Apple-converted-space"> </span><b class="">On Behalf Of<span class="Apple-converted-space"> </span></b>Vangelis Tsiatsianas via lldb-dev<br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, November 5, 2019 3:43 PM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>Vangelis Tsiatsianas <<a href="mailto:vangelists@icloud.com" class="">vangelists@icloud.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [lldb-dev] Identifying instructions that definitely access memory<o:p class=""></o:p></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hello,<o:p class=""></o:p></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I decided to try once more with a follow-up email, since my previous one got no responses (I hope itβs not considered rude to send more than one message in a row for a particular question).<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">To sum up and clarify my previous question, what I need is a way to track memory stores and save both the old and the new value of the memory location being modified.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">My thinking so far:<o:p class=""></o:p></div></div><div class=""><ol start="1" type="1" style="margin-bottom: 0in;" class=""><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Recognize the instructions that definitely access memory before they execute, based on their opcode.<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Tell whether each operand is a register or a memory location.<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">If itβs a memory location, check whether it is a load or store destination.<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">In case it is a store destination, fetch and save current value from memory.<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Execute instruction.<o:p class=""></o:p></li><li class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">Fetch and save new value from memory.<o:p class=""></o:p></li></ol><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">However, I was not able to find a cross-architecture API that covers all of the conditions above and more specifically <span style="font-family: FiraCode-Regular, serif;" class="">Instruction::DoesStore()</span> and <span style="font-family: FiraCode-Regular, serif;" class="">Operand::IsStoreDestination()</span>.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Last but not least, I should notice that the target is executed in single-step mode, so I do have control right before and after the execution of every instruction.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Thanks, again, in advance!<span class="Apple-converted-space"> </span><span style="font-family: "Segoe UI Emoji", sans-serif;" class="">π</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">β Vangelis<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""><br class=""><o:p class=""></o:p></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">On 21 Oct 2019, at 08:54, Vangelis Tsiatsianas <<a href="mailto:vangelists@icloud.com" style="color: purple; text-decoration: underline;" class="">vangelists@icloud.com</a>> wrote:<o:p class=""></o:p></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hello,<o:p class=""></o:p></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I am looking for a way to identify loads, stores and any other kind of instruction that<span class="Apple-converted-space"> </span><b class="">definitely</b><span class="Apple-converted-space"> </span>perform memory access and extract the address operand(s), however I was not able to find a cross-architecture API. The closest I stumbled upon are "<span style="font-family: FiraCode-Regular, serif;" class="">MCInstrDesc::mayLoad()</span>" and "<span style="font-family: FiraCode-Regular, serif;" class="">MCInstrDesc::mayStore()</span>", but I understand that their results are just a hint, so I would then need to examine the instruction name or opcode in order to find out whether itβs actually a load or store and which operand(s) is (are) memory address(es) and also do so for each architecture separately, which I would really like to avoid.<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Is there a way to identify such instructions either by examining them through the disassembler (e.g. "<span style="font-family: FiraCode-Regular, serif;" class="">DoesLoad()</span>" | "<span style="font-family: FiraCode-Regular, serif;" class="">DoesStore()</span>") before they execute or right after they perform any kind of memory access?<o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Thank you very much, in advance!<span class="Apple-converted-space"> </span><span style="font-family: "Segoe UI Emoji", sans-serif;" class="">π</span><o:p class=""></o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">β Vangelis</div></div></div></div></blockquote></div></div></div></div></div></blockquote></div><br class=""></div></body></html>