You can get the name of a variable by using the method getName() of llvm::Value. However it returns a blank string if the variable is a numbered variable, such as %11. How can I make it return %11 in such case. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130222/d6d434e8/attachment.html>
Hello, On Fri, 22 Feb 2013 16:11:17 +0100 Blind Faith <person.of.book at gmail.com> wrote:> You can get the name of a variable by using the method getName() of > llvm::Value. However it returns a blank string if the variable is a > numbered variable, such as %11. How can I make it return %11 in such > case.I'd like to second this question. Looking at the source, the numbered vars are just checked for being sequential and dropped. Well, that may be understood given sequentiality constraint (what if other instructions inserted inbetween later), but is there other human-readable unique identifier for each instruction? More generally, is it possible to get parsed, but linear LLVM IR (corresponding to LLVM assembly)? - otherwise it seems DAG is constructed straight on IR load. -- Best regards, Paul mailto:pmiscml at gmail.com
On 2/22/2013 9:11 AM, Blind Faith wrote:> You can get the name of a variable by using the method getName() of > llvm::Value. However it returns a blank string if the variable is a > numbered variable, such as %11. How can I make it return %11 in such case.The numbers come from SlotTracker in AsmWriter.cpp. They are basically generated when the IR needs to be printed in the human readable form, and don't necessarily exist otherwise. They may also change over time, as the IR changes (i.e. the same value may get a different number next time). -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
The numbers are not explicitly stored in the in-memory representation. Their only purpose is to name the variable in the textual representation (I believe the bitcode representation uses a different scheme based on relative numbering). The numbers are created during serialization; see SlotTracker::getLocalSlot() in lib/IR/AsmWriter.cpp. Also related: <http://llvm.org/docs/FAQ.html#what-api-do-i-use-to-store-a-value-to-one-of-the-virtual-registers-in-llvm-ir-s-ssa-representation>. -- Sean Silva