Skip to content
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

Fix invalid ptrtoint on non-integral pointers #23617

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ struct LateLowerGCFrame: public FunctionPass {
Type *T_int8;
Type *T_int32;
Type *T_pint8;
Type *T_pjlvalue;
Type *T_pjlvalue_der;
Type *T_ppjlvalue_der;
MDNode *tbaa_gcframe;
Expand Down Expand Up @@ -1156,7 +1157,9 @@ bool LateLowerGCFrame::CleanupIR(Function &F) {
(gc_use_func != nullptr && callee == gc_use_func)) {
/* No replacement */
} else if (pointer_from_objref_func != nullptr && callee == pointer_from_objref_func) {
auto *ptr = new PtrToIntInst(CI->getOperand(0), CI->getType(), "", CI);
auto *obj = CI->getOperand(0);
auto *ASCI = new AddrSpaceCastInst(obj, T_pjlvalue, "", CI);
auto *ptr = new PtrToIntInst(ASCI, CI->getType(), "", CI);
ptr->takeName(CI);
CI->replaceAllUsesWith(ptr);
} else if (alloc_obj_func && callee == alloc_obj_func) {
Expand Down Expand Up @@ -1447,15 +1450,15 @@ bool LateLowerGCFrame::doInitialization(Module &M) {
addRetNoAlias(big_alloc_func);
}
auto T_jlvalue = cast<PointerType>(T_prjlvalue)->getElementType();
auto T_pjlvalue = PointerType::get(T_jlvalue, 0);
T_pjlvalue = PointerType::get(T_jlvalue, 0);
T_ppjlvalue = PointerType::get(T_pjlvalue, 0);
T_pjlvalue_der = PointerType::get(T_jlvalue, AddressSpace::Derived);
T_ppjlvalue_der = PointerType::get(T_prjlvalue, AddressSpace::Derived);
}
else if (ptls_getter) {
auto functype = ptls_getter->getFunctionType();
T_ppjlvalue = cast<PointerType>(functype->getReturnType())->getElementType();
auto T_pjlvalue = cast<PointerType>(T_ppjlvalue)->getElementType();
T_pjlvalue = cast<PointerType>(T_ppjlvalue)->getElementType();
auto T_jlvalue = cast<PointerType>(T_pjlvalue)->getElementType();
T_prjlvalue = PointerType::get(T_jlvalue, AddressSpace::Tracked);
T_pjlvalue_der = PointerType::get(T_jlvalue, AddressSpace::Derived);
Expand All @@ -1464,6 +1467,7 @@ bool LateLowerGCFrame::doInitialization(Module &M) {
else {
T_ppjlvalue = nullptr;
T_prjlvalue = nullptr;
T_pjlvalue = nullptr;
T_pjlvalue_der = nullptr;
T_ppjlvalue_der = nullptr;
}
Expand Down