mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Change CaptureTracking to pass a Use* instead of a Value* when a value is
captured. This allows the tracker to look at the specific use, which may be especially interesting for function calls. Use this to fix 'nocapture' deduction in FunctionAttrs. The existing one does not iterate until a fixpoint and does not guarantee that it produces the same result regardless of iteration order. The new implementation builds up a graph of how arguments are passed from function to function, and uses a bottom-up walk on the argument-SCCs to assign nocapture. This gets us nocapture more often, and does so rather efficiently and independent of iteration order. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147327 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -30,8 +30,8 @@ namespace {
|
||||
|
||||
bool shouldExplore(Use *U) { return true; }
|
||||
|
||||
bool captured(Instruction *I) {
|
||||
if (isa<ReturnInst>(I) && !ReturnCaptures)
|
||||
bool captured(Use *U) {
|
||||
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
|
||||
return false;
|
||||
|
||||
Captured = true;
|
||||
@ -117,7 +117,7 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
|
||||
for (CallSite::arg_iterator A = B; A != E; ++A)
|
||||
if (A->get() == V && !CS.doesNotCapture(A - B))
|
||||
// The parameter is not marked 'nocapture' - captured.
|
||||
if (Tracker->captured(I))
|
||||
if (Tracker->captured(U))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
@ -130,7 +130,7 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
|
||||
case Instruction::Store:
|
||||
if (V == I->getOperand(0))
|
||||
// Stored the pointer - conservatively assume it may be captured.
|
||||
if (Tracker->captured(I))
|
||||
if (Tracker->captured(U))
|
||||
return;
|
||||
// Storing to the pointee does not cause the pointer to be captured.
|
||||
break;
|
||||
@ -158,12 +158,12 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
|
||||
break;
|
||||
// Otherwise, be conservative. There are crazy ways to capture pointers
|
||||
// using comparisons.
|
||||
if (Tracker->captured(I))
|
||||
if (Tracker->captured(U))
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
// Something else - be conservative and say it is captured.
|
||||
if (Tracker->captured(I))
|
||||
if (Tracker->captured(U))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user