Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 17 additions & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4627,6 +4627,17 @@ void IRGenSILFunction::visitIsEscapingClosureInst(
setLoweredExplosion(i, out);
}

static bool isCallToSwiftTaskAlloc(llvm::Value *val) {
auto *call = dyn_cast<llvm::CallInst>(val);
if (!call)
return false;
auto *callee = call->getCalledFunction();
if (!callee)
return false;
auto isTaskAlloc = callee->getName().equals("swift_task_alloc");
return isTaskAlloc;
}

void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
const TypeInfo &type,
llvm::Value *addr) {
Expand All @@ -4644,6 +4655,11 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
else if (auto *CoroAllocaGet = dyn_cast<llvm::IntrinsicInst>(Op0)) {
if (CoroAllocaGet->getIntrinsicID() == llvm::Intrinsic::coro_alloca_get)
addr = CoroAllocaGet;
} else if (auto *call = dyn_cast<llvm::CallInst>(Op0)) {
addr = call;
bool isTaskAlloc = isCallToSwiftTaskAlloc(call);
assert(isTaskAlloc && "expecting call to swift_task_alloc");
(void)isTaskAlloc;
}
}

Expand All @@ -4659,7 +4675,7 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,

// At this point addr must be an alloca or an undef.
assert(isa<llvm::AllocaInst>(addr) || isa<llvm::UndefValue>(addr) ||
isa<llvm::IntrinsicInst>(addr));
isa<llvm::IntrinsicInst>(addr) || isCallToSwiftTaskAlloc(addr));

auto Indirection = DirectValue;
if (!IGM.IRGen.Opts.DisableDebuggerShadowCopies &&
Expand Down
14 changes: 14 additions & 0 deletions test/IRGen/async/debug.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %target-swift-frontend -primary-file %s -emit-ir -enable-experimental-concurrency -g | %FileCheck %s

// Don't assert on dynamically sized variables.
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @"$s5debug1fyxxYKlF"

public func f<Success>(_ value: Success) async throws -> Success {
switch Result<Success, Error>.success(value) {
case .success(let success):
return success

case .failure(let error):
throw error;
}
}