<font>Hello everyone,<br><br><font>I have the following LLVM IR :<br><br><font>@.str = private unnamed_addr constant [3 x i8] c"DS\00", section "llvm.metadata"<br><br>@llvm.global.annotations = appending global [1 x { i8*, i8*, i8*, i32 }] [{ i8*, i8*, i8*, i32 } { i8* bitcast (i32* @f to i8*), i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str1, i32 0, i32 0), i32 18 }], section "llvm.metadata"<br>
<br><font>I need to get @f (or maybe I can get somehow the definition of @f = global i32 0, align 4 ) and also I ne<font>ed to get "DS" from @.str. In my target code I have :<br><br><font>__attribute__((annotate("DS"))) int f=0;<br>
<br><font>I have problems to pa<font>rse </font></font></font></font></font></font></font></font><font><font><font><font><font><font><font><font><font><font><font>@llvm.global.annotations and I assum<font>e I will have with</font></font></font></font></font></font></font></font></font></font></font></font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font> @.str</font></font></font>. </font></font></font></font> </font>What I tried:<br>
<br><font>1<font>. <br><br><font>for (Module::global_iterator I = F.global_begin(), E = F.global_end(); I != E; ++I) {<br>    if (I->getName() == "llvm.global.annotations") {</font><br><font>       Value *V = cast<Value>(I->getOperand(0));<br>
<font>        errs()<<"\n "<<*(V)<<"\n";<br>        errs()<<"\n "<<*(V->getType())<<"\n";<br><br><font>RESULT : <br><br>[1 x { i8*, i8*, i8*, i32 }] [{ i8*, i8*, i8*, i32 } { i8* bitcast (i32* @f to i8*), i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str1, i32 0, i32 0), i32 18 }]<br>
<br> [1 x { i8*, i8*, i8*, i32 }]<br><br><font>2.<br><br><font>errs()<<"\n "<<(V->getValueID())<<"\n";<br><font>if(V->getValueID() == Value::ConstantArrayVal)<font> </font>{<br>
            ConstantArray *ca = (ConstantArray *)V;<br>            errs()<<"\n "<<(ca[0])<<"\n";  }<br></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><font><br>
<font>RESULT : <br></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font> <br>[1 x { i8*, i8*, i8*, i32 }] [{ i8*, i8*, i8*, i32 } { i8* bitcast (i32* @f to i8*), i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str1, i32 0, i32 0), i32 18 }]<br>
<br><font><font>Any he<font>lp is welcomed ! Thank you !</font></font></font><br></font><font>      </font><br></font></font></font></font></font></font></font></font></font></font>