1
LLVM StoreInst
의 저장 대상이 함수 포인터인지 확인하는 방법은 무엇입니까?LLVM StoreInst 대상이 함수 포인터인지 확인하는 방법
LLVM StoreInst
의 저장 대상이 함수 포인터인지 확인하는 방법은 무엇입니까?LLVM StoreInst 대상이 함수 포인터인지 확인하는 방법
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));
이 코드는 다음 저장소를 검출한다.
저장할 위치의 유형을 의미합니까? 또는 해당 위치에서 함수 포인터의 별명을 지정할 수 있습니까? – Brian
나는 rvalue가 저장되는 위치의 타입을 의미합니다. – Razer