diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 0202046158b14..64966bddfe0c4 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1271,15 +1271,10 @@ static bool InstrBreaksNoFree(Instruction &I, const SCCNodeSet &SCCNodes) { if (CB->hasFnAttr(Attribute::NoFree)) return false; - Function *Callee = CB->getCalledFunction(); - if (!Callee) - return true; - - if (Callee->doesNotFreeMemory()) - return false; - - if (SCCNodes.contains(Callee)) - return false; + // Speculatively assume in SCC. + if (Function *Callee = CB->getCalledFunction()) + if (SCCNodes.contains(Callee)) + return false; return true; } @@ -1403,10 +1398,8 @@ static bool addNoRecurseAttrs(const SCCNodeSet &SCCNodes) { } static bool instructionDoesNotReturn(Instruction &I) { - if (auto *CB = dyn_cast(&I)) { - Function *Callee = CB->getCalledFunction(); - return Callee && Callee->doesNotReturn(); - } + if (auto *CB = dyn_cast(&I)) + return CB->hasFnAttr(Attribute::NoReturn); return false; } @@ -1517,13 +1510,6 @@ static bool InstrBreaksNoSync(Instruction &I, const SCCNodeSet &SCCNodes) { if (CB->hasFnAttr(Attribute::NoSync)) return false; - // readnone + not convergent implies nosync - // (This is needed to initialize inference from declarations which aren't - // explicitly nosync, but are readnone and not convergent.) - if (CB->hasFnAttr(Attribute::ReadNone) && - !CB->hasFnAttr(Attribute::Convergent)) - return false; - // Non volatile memset/memcpy/memmoves are nosync // NOTE: Only intrinsics with volatile flags should be handled here. All // others should be marked in Intrinsics.td. diff --git a/llvm/test/Transforms/FunctionAttrs/noreturn.ll b/llvm/test/Transforms/FunctionAttrs/noreturn.ll index acc538d3cceef..098788f93af8f 100644 --- a/llvm/test/Transforms/FunctionAttrs/noreturn.ll +++ b/llvm/test/Transforms/FunctionAttrs/noreturn.ll @@ -64,3 +64,10 @@ define i32 @caller6() naked { define i32 @alreadynoreturn() noreturn { unreachable } + +; CHECK: Function Attrs: {{.*}}noreturn +; CHECK-NEXT: @callsite_noreturn() +define void @callsite_noreturn() { + call i32 @f() noreturn + ret void +} diff --git a/llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll b/llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll index 10fd6930d4e58..1dbeffc927cd3 100644 --- a/llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll +++ b/llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll @@ -1,4 +1,4 @@ -; RUN: opt -function-attrs -S %s | FileCheck %s +; RUN: opt -inferattrs -function-attrs -S %s | FileCheck %s declare void @decl_readonly() readonly declare void @decl_readnone() readnone