我正在编写一个llvm通道以读取二维数组的全局变量,因为在二维数组上我可以读取值,但是在二维数组中我确实找到了一种读取值的方法,任何人都知道如何读取它们?
virtual bool runOnModule(Module &M)
{
for (auto gv_iter = M.global_begin();gv_iter != M.global_end(); gv_iter++)
{
GlobalVariable *gv = &*gv_iter;
Constant *const_gv = gv->getInitializer();
if (ConstantDataArray *constArray = dyn_cast<ConstantDataArray>(const_gv))
{
datafile << gv_iter->getName().str() << std::endl;
if (constArray->getElementType()->isIntegerTy())
{
for (int i=0; i< (int)constArray->getNumElements();i++)
{
constArray->getElementAsInteger(i)
}
}
}
else if (ConstantArray *constArrayd = dyn_cast<ConstantArray>(const_gv))
{
//I need help here to read the values of constArrayd
}
}