[llvm-dev] Value

Anastasiya Ruzhanskaya via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 20 07:56:26 PDT 2017


I am performing the bit analysis, so actually I want to propagate
information about bits from operands to the instruction (the result of
instruction), and every time I access the Instruction first , than get the
operands, then access to the next instruction.
That was the only problem, that I keep a map from Instruction to bit info
and was confused, is Instruction, that I am putting to map, is the same
object as the Value, that will be used later,
as here %a = alloca i32, align 4 ...%b= mul %a, 2. Now seems to be, that
yes.

2017-07-20 16:43 GMT+02:00 Evgeny Astigeevich <Evgeny.Astigeevich at arm.com>:

> You think in terms of the textual representation of IR and are trying to
> work on IR in these terms.
>
> See:
>
> http://www.llvm.org/docs/ProgrammersManual.html#coreclasses
>
> http://llvm.org/doxygen/classllvm_1_1Value.html
>
>
> In the LLVM representation Value is a thing which can be used as an
> operand to instructions. In API there is no such thing as the named right
> part. An instruction itself is a value which is produced as result of
> execution of the instruction. Look at the example:
>
>
> Instr 1:  add i32 1, 2
>
>
>
> Instr 2:  add  i32 <result of Instr1>, 10
>
>
> We have a def-use connection between Instr 2 and Instr 1. We don't need
> names. We can traverse def-use connection in this way (
> http://www.llvm.org/docs/ProgrammersManual.html#helpful-hints-for-common-
> operations):
>
>
> Instruction *pi = ...;
> for (Use &U : pi->operands()) {
>   Value *v = U.get();
>   // ...}
>
>
> Your case:
>
>
> > %a = alloca i32, align 4 - %a here
>
> >, but I don't quite understand the difference between Instruction object
> and Value object of a, which is used further , and in this case :
>
> Instr1: alloca i32, align 4
>
> If there are users of Instr1 then can access them calling user_begin()
> on Instr1. You can access Instr1 from users as in the example above. Of
> course you need to keep the pointer to Instr1 somewhere to check that it's
> used.
>
>
> > %1 = alloca i32, align 4 - I also wanted to use %1 and in this case the
> only possibility is Instruction object.
>
>
> You traverse basic blocks and process the instructions. Processing can
> include any type of actions: analysis, optimization etc.
>
> So what is your use case?
>
>
> -Evgeny
>
> ------------------------------
> *From:* Anastasiya Ruzhanskaya <anastasiya.ruzhanskaya at frtk.ru>
> *Sent:* Thursday, July 20, 2017 3:02:26 PM
> *To:* Evgeny Astigeevich
> *Cc:* llvm-dev at lists.llvm.org; nd
> *Subject:* Re: [llvm-dev] Value
>
> Thank you! I wanted to use the right part of the instruction ,
>  %a = alloca i32, align 4 - %a here , but I don't quite understand the
> difference between Instruction object and Value object of a, which is used
> further , and in this case :
> %1 = alloca i32, align 4 - I also wanted to use %1 and in this case the
> only possibility is Instruction object.
>
> 2017-07-20 15:32 GMT+02:00 Evgeny Astigeevich <Evgeny.Astigeevich at arm.com>
> :
>
>> Hi Anastasiya,
>>
>>
>> What do you mean 'identifiable'? You have Module, Function, BasicBlock
>> etc. You can access Values and Users. They form a data-flow graph. You can
>> store pointers to Values and Users if you wish. If you want a name for any
>> Value there is ValueSymbolTable (http://www.llvm.org/docs/Prog
>> rammersManual.html#advanced-topics) which provides a symbol table that
>> the Function and Module classes use for naming value definitions. You
>> should take into account that some Values might not have names and passes
>> can change names of Values.
>>
>>
>> Thanks,
>>
>> Evgeny Astigevich
>> ------------------------------
>> *From:* llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of
>> Anastasiya Ruzhanskaya via llvm-dev <llvm-dev at lists.llvm.org>
>> *Sent:* Thursday, July 20, 2017 2:21:44 PM
>> *To:* LLVM Developers Mailing List
>> *Subject:* [llvm-dev] Value
>>
>> Hello,
>> I am trying to write my own pass for some purposes, and found out that
>> there is no way to work with such variables as %1 and so on. How they are
>> identifiable? Only by the Value object, without any possibility for visual
>> representation as for example %a, %b values?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170720/f02f2c2a/attachment.html>


More information about the llvm-dev mailing list