-
Notifications
You must be signed in to change notification settings - Fork 32
LLVM 15 Port #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
LLVM 15 Port #162
Conversation
| [](const llvm::Type *ty) { | ||
| return ty->isIntegerTy() || ty->isFloatingPointTy(); | ||
| }); | ||
| // TODO: Can infer pointer type by checking its uses. For now, not much |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea as a helpful utility. Given a ptr, traverse its uses and collect possible types. Committing to the found types is not sound in general, but often this should be correct. This is equivalent to relying on pointer types. Lets integrate this!
| // FIXME: This creates a node for a global function pointer. Needed by | ||
| // vtable in C++ | ||
| // Disabled for now since in LLVM 15 there is no way to determine if the pointer is a | ||
| // function. May be inferenced by checking if the pointer is ever loaded as a function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. This might also be a constant pointer to function, in which case its value can be examined to determined that it is an address of a function.
| } | ||
| } | ||
|
|
||
| static bool isBytePtrTy(const Type *ty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to determine by use
| a gcd of the variable offset. | ||
| */ | ||
| std::pair<int64_t, uint64_t> computeGepOffset(Type *ptrTy, | ||
| std::pair<int64_t, uint64_t> computeGepOffset(Type *srcElementTy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function needs to be reviewed. I do not see the immediate correspondence. I would expect srcElementTy to be srcElemTy (and be named the same), but then it is different from Ty in the old version. In the new version they seem to be used interchangeably. I think something got lost in conversion
| bool transfersNoPointers(MemTransferInst &MI, const DataLayout &DL) { | ||
| Value *srcPtr = MI.getSource(); | ||
| auto *srcTy = srcPtr->getType()->getPointerElementType(); | ||
| // FIXME: LLVM 15, Kevin: Since we can no longer access pointee types, it is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs more work. at least a basic solution based on pointer uses at first. need to build some test cases to evaluate. this is important.
| ((sourceCell.getNode()->links().size() == 0 && | ||
| hasNoPointerTy(I.getSource()->getType()->getPointerElementType())) || | ||
| transfersNoPointers(I, m_dl))) { | ||
| // FIXME: LLVM 15, Kevin: The removal of the pointer type means we can no longer avoid unification upon a memory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not good enough. need a solution that at least works for common rust examples
| break; | ||
| } | ||
| // FIXME: We're at a dead-end when we encounter a pointer type. | ||
| if (currentTy->isPointerTy()) break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... this requires more thought. are there examples/tests where this is used?
we can assume that opaque pointer is always a pointer to i8 instead of giving up completely
| auto *ci = mkShadowCall(B, c, m_memStoreFn, | ||
| {m_B->getInt32(getFieldId(c)), | ||
| m_B->CreateLoad(v->getType()->getPointerElementType(), v), | ||
| m_B->CreateLoad(m_Int32Ty, v), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that correct to use Int32Ty here? We run on both 32bit and 64bit platforms, make sure that this is correct and is not architecture dependent
Justification for changes
FieldType.hh→elemOf()RemovePtrToInt.cc→isConstantNoPtrDsaLibFuncInfo.cc→generateSpecgetPointerElementTypeDsaLocal.cccomputeGepOffsetBlockBuilderBase::visitGephas also been modified to reflect this changeGlobalBuilder::initIntraBlockBuilder::isBytePtrTyIntraBlockBuilder::visitStoreInstcomputeIndexedOffsetvisitExtractValueInstandvisitInsertValueInstto visit an instruction that indexes an opaque pointer).IntraBlockBuilder::visitMemTransferInst+transfersNoPointersFieldType.ccGetInnermostTypeImplIsOmnipotentPtrRemovePtrToInt.ccm_tyfield removed as it appears to be redundant afterwardsShadowMem.cc