Skip to content

Commit

Permalink
fix detection of srets containing tracked pointers in GC lowering
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 1, 2020
1 parent c54f80c commit b1a2e8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,9 @@ State LateLowerGCFrame::LocalScan(Function &F) {
}
if (CI->hasStructRetAttr()) {
AllocaInst *SRet = dyn_cast<AllocaInst>((CI->arg_begin()[0])->stripInBoundsOffsets());
if (SRet) {
Type *ElT = SRet->getAllocatedType();
assert(SRet);

This comment has been minimized.

Copy link
@vtjnash

vtjnash Apr 1, 2020

Member

You might want to check the element type first, to see if we care, since sometimes we'll emit something else there (like Argument)

{
Type *ElT = (CI->arg_begin()[0])->getType()->getPointerElementType();
if (!(SRet->isStaticAlloca() && isa<PointerType>(ElT) && ElT->getPointerAddressSpace() == AddressSpace::Tracked)) {
auto tracked = CountTrackedPointers(ElT);
if (tracked.count) {
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 b1a2e8e

Please sign in to comment.