Skip to content

Commit

Permalink
fix detection of srets containing tracked pointers in GC lowering (Ju…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and oxinabox committed Apr 8, 2020
1 parent 74ced5d commit d332a6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,12 +1350,13 @@ State LateLowerGCFrame::LocalScan(Function &F) {
MaybeNoteDef(S, BBS, CI, BBS.Safepoints);
}
if (CI->hasStructRetAttr()) {
AllocaInst *SRet = dyn_cast<AllocaInst>((CI->arg_begin()[0])->stripInBoundsOffsets());
if (SRet) {
Type *ElT = SRet->getAllocatedType();
if (!(SRet->isStaticAlloca() && isa<PointerType>(ElT) && ElT->getPointerAddressSpace() == AddressSpace::Tracked)) {
auto tracked = CountTrackedPointers(ElT);
if (tracked.count) {
Type *ElT = (CI->arg_begin()[0])->getType()->getPointerElementType();
auto tracked = CountTrackedPointers(ElT);
if (tracked.count) {
AllocaInst *SRet = dyn_cast<AllocaInst>((CI->arg_begin()[0])->stripInBoundsOffsets());
assert(SRet);
{
if (!(SRet->isStaticAlloca() && isa<PointerType>(ElT) && ElT->getPointerAddressSpace() == AddressSpace::Tracked)) {
assert(!tracked.derived);
if (tracked.all) {
S.ArrayAllocas[SRet] = tracked.count * cast<ConstantInt>(SRet->getArraySize())->getZExtValue();
Expand Down
11 changes: 11 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,14 @@ const c29864 = VecElement{Union{Int,Nothing}}(2)
@noinline g29864() = VecElement{Union{Int,Nothing}}(3)
@test f29864().value === 2
@test g29864().value === 3

# test sret pointing into a struct containing a tracked pointer
# reduced from TerminalLoggers/ProgressLogging
const _PROGRESS_LOGGING_UUID_NS_test = Base.UUID("1e962757-ea70-431a-b9f6-aadf988dcb7f")
_asuuid_test(id) = Base.uuid5(_PROGRESS_LOGGING_UUID_NS_test, repr(id))
@noinline _handle_progress_test(progress) = progress
function _handle_message_test()
progress = (_asuuid_test(:id), "name")
return _handle_progress_test(progress)
end
@test _handle_message_test() isa Tuple{Base.UUID, String}

0 comments on commit d332a6f

Please sign in to comment.