[LLVMdev] llvm cannot iterate a [3 x i8]
Alexandru Ionut Diaconescu
alexandruionutdiaconescu at gmail.com
Mon Mar 4 02:23:57 PST 2013
Hello everyone,
I am trying to "parse" a part of LLVM IR. More exactly, from
@.str = private unnamed_addr constant [3 x i8] c"DS\00", section
"llvm.metadata"
I want to get "DS". It is the single place in the whole bytecode from where
I can get it. I have :
...
Value *VV = cast<Value>(LD100->getOperand(1)->getOperand(0));
errs()<<"\n VV "<<*(VV)<<"\n";
RESULT : VV @.str = private unnamed_addr constant [3 x i8] c"DS\00",
section "llvm.metadata"
if(VV->getValueID() == Value::GlobalVariableVal){
GlobalVariable* FD = cast<GlobalVariable>(VV);
Value *VVV = cast<Value>(FD->getOperand(0));
errs()<<"\n VVV "<<*(VVV)<<"\n";
RESULT : VVV [3 x i8] c"DS\00"
if(VVV->getValueID() == Value::ConstantDataArrayVal){
ConstantArray *caa = (ConstantArray *)VVV;
errs()<<"\n "<<(caa->getNumOperands())<<"\n";
errs()<<"\n "<<*(caa->getType())<<"\n";
RESULT : 0
[3 x i8]
}
>From this point, I tried to cast to every `enum llvm::Value::ValueTy` in
order to try to iterate through [3 X i8], in order to get "DS" (as a
StringRef or std::string would be nice), but I cannot. How I can parse this
structure?
Thank you for any help !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130304/fc99e5c5/attachment.html>
More information about the llvm-dev
mailing list