[LLVMdev] llvm get annotations

Sebastian Dreßler dressler at zib.de
Fri Mar 1 08:53:58 PST 2013


Hi,

On 03/01/2013 02:46 PM, Alexandru Ionut Diaconescu wrote:
> Hi, I solved it. From the ConstantStruct you can call getOperand() multiple
> times, so "mine" as deep as you can.
> 

Great that you figured it out. And I'm glad, that I could help you.


Cheers,
Sebastian


> On Fri, Mar 1, 2013 at 1:41 PM, Alexandru Ionut Diaconescu <
> alexandruionutdiaconescu at gmail.com> wrote:
> 
>>
>> Hi Sebastian,
>>
>> Thanks for the response.
>>
>> I already did this :
>>
>> I cast the entire annotated expression to Value*. Then, in order to avoid
>> ugly things like getAsString(), I check if V->getValueID() ==
>> Value::ConstantArrayVal in order to cast it to ConstantArray. Because it
>> contains only array[0], I cast array0>getOperand(0) to ConstantStruct.
>> Therefore, from ConstantStruct you can get all the four operands. Now, as
>> a TODO, is only to get the names of @f, @str from every field.
>>
>> But right now I have only a small step to do.
>> ConstantStruct->getOperand(0) gives me   i8* bitcast (i32* @f to i8*)  . Do
>> you know how I can get the name @f from this? I cannot convert it again to
>> ConstantStruct and follow the same procedure, it will give me a segfault.
>>
>> Thank you again. Your advice was very helpful :)
>>
>>
>>
>> On Fri, Mar 1, 2013 at 9:22 AM, Sebastian Dreßler <dressler at zib.de> wrote:
>>
>>> Hi,
>>>
>>> On 02/28/2013 03:55 PM, Alexandru Ionut Diaconescu wrote:
>>>> Hi Sebastian,
>>>>
>>>> I think I am very close to get the annotation, but I need to parse a
>>>> Value*, which is of type  {[1 x { i8*, i8*, i8*, i32 }]. In one of those
>>>> fields is the variable that I'm interested into and the string keeping
>>> the
>>>> annotation. But I don't know how to parse .... use_begin() gives me the
>>>> same Value*....do you know how I can parse inside the element?
>>>>
>>>
>>> This is an Array Type (http://llvm.org/docs/LangRef.html#array-type)
>>> which contains a struct. I assume, that you could cast to ConstantArray
>>> which is a Value and then use getOperand(0) and cast its result to
>>> ConstantStruct, like I've done in the sample code. Then you have the
>>> struct and you can traverse it further.
>>>
>>>
>>> Cheers,
>>> Sebastian
>>>
>>>> Thank you :) !
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Feb 27, 2013 at 4:44 PM, Alexandru Ionut Diaconescu <
>>>> alexandruionutdiaconescu at gmail.com> wrote:
>>>>
>>>>> Hi Sebastian,
>>>>>
>>>>> Thank you for the dummy file. I will try to understand and use it. I
>>> guess
>>>>> I have some problems with C++11. If I cannot solve by simple "parsing"
>>> my
>>>>> code for @llvm.global.annotations, I will ask you again.
>>>>>
>>>>> Cheers,
>>>>> Alex
>>>>>
>>>>>
>>>>> On Wed, Feb 27, 2013 at 4:34 PM, Sebastian Dreßler <dressler at zib.de
>>>> wrote:
>>>>>
>>>>>> Hi Alexandru,
>>>>>>
>>>>>> On 02/27/2013 04:20 PM, Alexandru Ionut Diaconescu wrote:
>>>>>>> [...]
>>>>>>> Do you have a larger piece of code (maybe you have some dummy/test
>>>>>>> examples) from your previous work with annotations? It would be very
>>>>>> useful
>>>>>>> :D
>>>>>>>
>>>>>>
>>>>>> I've attached an example. But please be aware of:
>>>>>>
>>>>>> 1. It uses C++11 and cast (previously I simply replaced cast<> with
>>>>>> dynamic_cast<> which does not seem to work everywhere, so sorry for
>>> that).
>>>>>>
>>>>>> 2. assert is not used in the style as it should be used, so pleas do
>>> not
>>>>>> adopt this style.
>>>>>>
>>>>>>
>>>>>> If some things are still unclear, keep asking ;)
>>>>>>
>>>>>> Cheers,
>>>>>> Sebastian
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Mit freundlichen Grüßen / Kind regards
>>>>>>
>>>>>> Sebastian Dreßler
>>>>>>
>>>>>> Zuse Institute Berlin (ZIB)
>>>>>> Takustraße 7
>>>>>> D-14195 Berlin-Dahlem
>>>>>> Germany
>>>>>>
>>>>>> dressler at zib.de
>>>>>> Phone: +49 30 84185-261
>>>>>>
>>>>>> http://www.zib.de/
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best regards,
>>>>> Alexandru Ionut Diaconescu
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Mit freundlichen Grüßen / Kind regards
>>>
>>> Sebastian Dreßler
>>>
>>> Zuse Institute Berlin (ZIB)
>>> Takustraße 7
>>> D-14195 Berlin-Dahlem
>>> Germany
>>>
>>> dressler at zib.de
>>> Phone: +49 30 84185-261
>>>
>>> http://www.zib.de/
>>>
>>
>>
>>
>> --
>> Best regards,
>> Alexandru Ionut Diaconescu
>>
> 
> 
> 


-- 
Mit freundlichen Grüßen / Kind regards

Sebastian Dreßler

Zuse Institute Berlin (ZIB)
Takustraße 7
D-14195 Berlin-Dahlem
Germany

dressler at zib.de
Phone: +49 30 84185-261

http://www.zib.de/



More information about the llvm-dev mailing list