mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-01 21:04:04 -04:00
[Attributor] Shortcut no-return through will-return
No-return and will-return are exclusive, assuming the latter is more prominent we can avoid updates of the former unless will-return is not known for sure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374739 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2859,6 +2859,14 @@ struct AAAlignCallSiteReturned final : AAAlignImpl {
|
||||
struct AANoReturnImpl : public AANoReturn {
|
||||
AANoReturnImpl(const IRPosition &IRP) : AANoReturn(IRP) {}
|
||||
|
||||
/// See AbstractAttribute::initialize(...).
|
||||
void initialize(Attributor &A) override {
|
||||
AANoReturn::initialize(A);
|
||||
Function *F = getAssociatedFunction();
|
||||
if (!F || F->hasFnAttribute(Attribute::WillReturn))
|
||||
indicatePessimisticFixpoint();
|
||||
}
|
||||
|
||||
/// See AbstractAttribute::getAsStr().
|
||||
const std::string getAsStr() const override {
|
||||
return getAssumed() ? "noreturn" : "may-return";
|
||||
@@ -2866,6 +2874,9 @@ struct AANoReturnImpl : public AANoReturn {
|
||||
|
||||
/// See AbstractAttribute::updateImpl(Attributor &A).
|
||||
virtual ChangeStatus updateImpl(Attributor &A) override {
|
||||
const auto &WillReturnAA = A.getAAFor<AAWillReturn>(*this, getIRPosition());
|
||||
if (WillReturnAA.isKnownWillReturn())
|
||||
return indicatePessimisticFixpoint();
|
||||
auto CheckForNoReturn = [](Instruction &) { return false; };
|
||||
if (!A.checkForAllInstructions(CheckForNoReturn, *this,
|
||||
{(unsigned)Instruction::Ret}))
|
||||
@@ -2885,14 +2896,6 @@ struct AANoReturnFunction final : AANoReturnImpl {
|
||||
struct AANoReturnCallSite final : AANoReturnImpl {
|
||||
AANoReturnCallSite(const IRPosition &IRP) : AANoReturnImpl(IRP) {}
|
||||
|
||||
/// See AbstractAttribute::initialize(...).
|
||||
void initialize(Attributor &A) override {
|
||||
AANoReturnImpl::initialize(A);
|
||||
Function *F = getAssociatedFunction();
|
||||
if (!F)
|
||||
indicatePessimisticFixpoint();
|
||||
}
|
||||
|
||||
/// See AbstractAttribute::updateImpl(...).
|
||||
ChangeStatus updateImpl(Attributor &A) override {
|
||||
// TODO: Once we have call site specific value information we can provide
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 -S < %s | FileCheck %s
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 -S < %s | FileCheck %s
|
||||
;
|
||||
; Test cases specifically designed for the "no-return" function attribute.
|
||||
; We use FIXME's to indicate problems and missing attributes.
|
||||
@@ -124,4 +124,16 @@ cond.end: ; preds = %cond.false, %cond.t
|
||||
ret i32 %cond
|
||||
}
|
||||
|
||||
|
||||
; TEST 6: willreturn means *not* no-return
|
||||
; CHECK: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
|
||||
; CHECK-NEXT: define i32 @endless_loop_but_willreturn
|
||||
define i32 @endless_loop_but_willreturn(i32 %a) willreturn {
|
||||
entry:
|
||||
br label %while.body
|
||||
|
||||
while.body: ; preds = %entry, %while.body
|
||||
br label %while.body
|
||||
}
|
||||
|
||||
attributes #0 = { noinline nounwind uwtable }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=5 < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 < %s | FileCheck %s
|
||||
|
||||
define dso_local i32 @visible(i32* noalias %A, i32* noalias %B) #0 {
|
||||
entry:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 -S < %s | FileCheck %s
|
||||
; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 -S < %s | FileCheck %s
|
||||
|
||||
declare void @no_return_call() nofree noreturn nounwind readnone
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
; RUN: opt < %s -basicaa -functionattrs -rpo-functionattrs -S | FileCheck %s --check-prefixes=CHECK,BOTH
|
||||
; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs),rpo-functionattrs' -S | FileCheck %s --check-prefixes=CHECK,BOTH
|
||||
; RUN: opt -passes=attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR,BOTH
|
||||
; RUN: opt -passes=attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=4 -S < %s | FileCheck %s --check-prefixes=ATTRIBUTOR,BOTH
|
||||
|
||||
; CHECK: Function Attrs
|
||||
; CHECK-SAME: norecurse nounwind readnone
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 -S < %s | FileCheck %s
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 -S < %s | FileCheck %s
|
||||
;
|
||||
; This file is the same as noreturn_sync.ll but with a personality which
|
||||
; indicates that the exception handler *can* catch asynchronous exceptions. As
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=2 -S < %s | FileCheck %s
|
||||
; RUN: opt -functionattrs -attributor -attributor-disable=false -attributor-max-iterations-verify -attributor-max-iterations=3 -S < %s | FileCheck %s
|
||||
;
|
||||
; This file is the same as noreturn_async.ll but with a personality which
|
||||
; indicates that the exception handler *cannot* catch asynchronous exceptions.
|
||||
|
||||
Reference in New Issue
Block a user