From 17da06ffbd1f7269b6b9037f883a3d8a5c985f62 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Wed, 31 Dec 2008 18:08:59 +0000 Subject: [PATCH] Don't analyze arguments already marked 'nocapture'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61532 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Argument.h | 4 ++++ lib/Transforms/IPO/FunctionAttrs.cpp | 3 ++- lib/VMCore/Function.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index 9faff549f26..9c063677984 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -56,6 +56,10 @@ public: /// it in its containing function. bool hasNoAliasAttr() const; + /// hasNoCaptureAttr - Return true if this argument has the nocapture + /// attribute on it in its containing function. + bool hasNoCaptureAttr() const; + /// hasSRetAttr - Return true if this argument has the sret attribute on it in /// its containing function. bool hasStructRetAttr() const; diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index 9ed605cf9f3..1824a710c51 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -263,7 +263,8 @@ bool FunctionAttrs::AddNoCaptureAttrs(const std::vector &SCC) { continue; for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A!=E; ++A) - if (isa(A->getType()) && !isCaptured(*F, A)) { + if (isa(A->getType()) && !A->hasNoCaptureAttr() && + !isCaptured(*F, A)) { A->addAttr(Attribute::NoCapture); NumNoCapture++; Changed = true; diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index ddc6ace3278..f83fe435cd0 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -102,6 +102,13 @@ bool Argument::hasNoAliasAttr() const { return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoAlias); } +/// hasNoCaptureAttr - Return true if this argument has the nocapture attribute +/// on it in its containing function. +bool Argument::hasNoCaptureAttr() const { + if (!isa(getType())) return false; + return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoCapture); +} + /// hasSRetAttr - Return true if this argument has the sret attribute on /// it in its containing function. bool Argument::hasStructRetAttr() const { -- 2.34.1