2016-09-14 3 views

답변

2

LLVM로드/저장 명령어가 주어지면 계산할 두 개의 개별 조각이 있습니다. 첫째, 위치 유형이 무엇입니까? 둘째, 유형이 특정 속성 등을 충족 시키는가?

if (StoreInst *si = dyn_cast<StoreInst>(&*I)) 
{ 
    Value* v = si->getPointerOperand(); 
    Type* ptrType = v->getType()->getPointerElementType(); 

이제 포인터 유형은 데이터가 저장되는 유형입니다. 그러나 기본 유형이 실제로 함수인지, 따라서 함수 포인터 (또는 포인터 포인터 등)인지 여부를 알아야합니다. store i8* (i8*)* @tFunc, i8* (i8*)** %8, align 8 다른 위치로 tFunc가 함수에 대한 포인터를 저장 -

if (PointerType* pt = dyn_cast<PointerType>(ptrType)) 
    { 
     do { 
      // The call to getTypeAtIndex has to be made on a composite type 
      // And needs explicitly an unsigned int, otherwise 0 
      // can ambiguously be NULL. 
      Type* pointedType = pt->getTypeAtIndex((unsigned int)0); 
      if (pointedType->isFunctionTy()) 
      { 
       errs() << "Found the underlying function type\n"; 
       break; 
      } 

      // This may be a pointer to a pointer to ... 
      ptrType = pointedType; 
     } while (pt = dyn_cast<PointerType>(ptrType)); 

이 코드는 다음 저장소를 검출한다.