[llvm-dev] Efficient way to identify an instruction

Alberto Barbaro via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 27 23:29:18 PDT 2019


Hi,
I was thinking that maybe there is always some sort of dependency analysis
that would allow me to visit a tree from the AllocaInst to the IcmpInst. Is
it already possible?

Thanks

Il giorno dom 28 lug 2019 alle ore 07:21 Alberto Barbaro <
barbaro.alberto at gmail.com> ha scritto:

> Hi Tim,
> as always thanks for your help. Unfortunately I made a mistake in my email
> but apart from that I still have problems.
>
> Il giorno sab 27 lug 2019 alle ore 11:53 Tim Northover <
> t.p.northover at gmail.com> ha scritto:
>
>> Hi Alberto,
>>
>> On Sat, 27 Jul 2019 at 10:09, Alberto Barbaro via llvm-dev
>> <llvm-dev at lists.llvm.org> wrote:
>> > Having the reference I to the instruction in bold.Can i efficiently
>> know that the variable %11 was "created" by the %3 = alloca [40 x i8],
>> align 16.
>>
>> Yes, I.getOperand(0) *is* the AllocaInst in this case. So for example
>> isa<AllocaInst>(I.getOperand(0)) will return true. And if you care
>> about more details you can dyn_cast<AllocaInst> it and check any other
>> properties you want.
>>
>>
> I would like to use the approach you described considering I to be a
> reference to the icmp instruction ( %13 = icmp eq i32 %12, 66 ). From what
> I understood i should do something like:
>
> Instruction* source;
>
> if(source = dyn_cast<AllocaInst>(I.getOperand(0))) {
>     cout << "Alloca Inst" << endl;
>     I.dump();
>     getchar();
> }
>
> I thought I.getOperand(0) was a reference to the instruction that have
> created %12. What am I missing?
>
>
>> Cheers.
>>
>> Tim.
>>
>
> Thanks again
> Alberto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190728/1802b0a1/attachment.html>


More information about the llvm-dev mailing list