mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
When checking if an Argument escapes, check if
the argument is marked nocapture - no need to analyze the argument if the answer is already known! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61753 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7e66c0d43a
commit
91c9c31033
@ -35,10 +35,11 @@ using namespace llvm;
|
|||||||
// Useful predicates
|
// Useful predicates
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// Determine if an AllocationInst instruction escapes from the function it is
|
// Determine if a value escapes from the function it is contained in (being
|
||||||
// contained in. If it does not escape, there is no way for another function to
|
// returned by the function does not count as escaping here). If a value local
|
||||||
// mod/ref it. We do this by looking at its uses and determining if the uses
|
// to the function does not escape, there is no way another function can mod/ref
|
||||||
// can escape (recursively).
|
// it. We do this by looking at its uses and determining if they can escape
|
||||||
|
// (recursively).
|
||||||
static bool AddressMightEscape(const Value *V) {
|
static bool AddressMightEscape(const Value *V) {
|
||||||
for (Value::use_const_iterator UI = V->use_begin(), E = V->use_end();
|
for (Value::use_const_iterator UI = V->use_begin(), E = V->use_end();
|
||||||
UI != E; ++UI) {
|
UI != E; ++UI) {
|
||||||
@ -163,10 +164,15 @@ static bool isNonEscapingLocalObject(const Value *V) {
|
|||||||
return !AddressMightEscape(V);
|
return !AddressMightEscape(V);
|
||||||
|
|
||||||
// If this is an argument that corresponds to a byval or noalias argument,
|
// If this is an argument that corresponds to a byval or noalias argument,
|
||||||
// it can't escape either.
|
// then it has not escaped before entering the function. Check if it escapes
|
||||||
|
// inside the function.
|
||||||
if (const Argument *A = dyn_cast<Argument>(V))
|
if (const Argument *A = dyn_cast<Argument>(V))
|
||||||
if (A->hasByValAttr() || A->hasNoAliasAttr())
|
if (A->hasByValAttr() || A->hasNoAliasAttr()) {
|
||||||
|
// Don't bother analyzing arguments already known not to escape.
|
||||||
|
if (A->hasNoCaptureAttr())
|
||||||
|
return true;
|
||||||
return !AddressMightEscape(V);
|
return !AddressMightEscape(V);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user