diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1637,8 +1637,7 @@ static void addNoReturnAttrs(const SCCNodeSet &SCCNodes, SmallSet &Changed) { for (Function *F : SCCNodes) { - if (!F || !F->hasExactDefinition() || F->hasFnAttribute(Attribute::Naked) || - F->doesNotReturn()) + if (!F || F->hasFnAttribute(Attribute::Naked) || F->doesNotReturn()) continue; if (!canReturn(*F)) { diff --git a/llvm/test/Transforms/FunctionAttrs/noreturn.ll b/llvm/test/Transforms/FunctionAttrs/noreturn.ll --- a/llvm/test/Transforms/FunctionAttrs/noreturn.ll +++ b/llvm/test/Transforms/FunctionAttrs/noreturn.ll @@ -87,3 +87,10 @@ declare token @llvm.coro.id.retcon.once(i32 %size, i32 %align, ptr %buffer, ptr %prototype, ptr %alloc, ptr %free) declare i1 @llvm.coro.end(ptr, i1) + +; CHECK: Function Attrs: {{.*}}noreturn +; CHECK-NEXT: @weak +define weak void @weak() { + tail call void @noreturn() + unreachable +}