comments, deleting duplicate comments, moving comments to consistently
live on the definition since these are all really internal routines,
etc. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247520
91177308-0d34-0410-b5e6-
96231b3b80d8
initializeFunctionAttrsPass(*PassRegistry::getPassRegistry());
}
initializeFunctionAttrsPass(*PassRegistry::getPassRegistry());
}
- // runOnSCC - Analyze the SCC, performing the transformation if possible.
bool runOnSCC(CallGraphSCC &SCC) override;
bool runOnSCC(CallGraphSCC &SCC) override;
- // AddReadAttrs - Deduce readonly/readnone attributes for the SCC.
bool AddReadAttrs(const CallGraphSCC &SCC);
bool AddReadAttrs(const CallGraphSCC &SCC);
-
- // AddArgumentAttrs - Deduce nocapture attributes for the SCC.
bool AddArgumentAttrs(const CallGraphSCC &SCC);
bool AddArgumentAttrs(const CallGraphSCC &SCC);
-
- // IsFunctionMallocLike - Does this function allocate new memory?
bool IsFunctionMallocLike(Function *F, SmallPtrSet<Function *, 8> &) const;
bool IsFunctionMallocLike(Function *F, SmallPtrSet<Function *, 8> &) const;
-
- // AddNoAliasAttrs - Deduce noalias attributes for the SCC.
bool AddNoAliasAttrs(const CallGraphSCC &SCC);
bool AddNoAliasAttrs(const CallGraphSCC &SCC);
-
- /// \brief Does this function return null?
bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
bool &Speculative) const;
bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
bool &Speculative) const;
-
- /// \brief Deduce nonnull attributes for the SCC.
bool AddNonNullAttrs(const CallGraphSCC &SCC);
// Utility methods used by inferPrototypeAttributes to add attributes
bool AddNonNullAttrs(const CallGraphSCC &SCC);
// Utility methods used by inferPrototypeAttributes to add attributes
- // inferPrototypeAttributes - Analyze the name and prototype of the
- // given function and set any applicable attributes. Returns true
- // if any attributes were set and false otherwise.
bool inferPrototypeAttributes(Function &F);
bool inferPrototypeAttributes(Function &F);
- // annotateLibraryCalls - Adds attributes to well-known standard library
- // call declarations.
bool annotateLibraryCalls(const CallGraphSCC &SCC);
void getAnalysisUsage(AnalysisUsage &AU) const override {
bool annotateLibraryCalls(const CallGraphSCC &SCC);
void getAnalysisUsage(AnalysisUsage &AU) const override {
Pass *llvm::createFunctionAttrsPass() { return new FunctionAttrs(); }
Pass *llvm::createFunctionAttrsPass() { return new FunctionAttrs(); }
-/// AddReadAttrs - Deduce readonly/readnone attributes for the SCC.
+/// Deduce readonly/readnone attributes for the SCC.
bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
-// For a given pointer Argument, this retains a list of Arguments of functions
-// in the same SCC that the pointer data flows into. We use this to build an
-// SCC of the arguments.
+/// For a given pointer Argument, this retains a list of Arguments of functions
+/// in the same SCC that the pointer data flows into. We use this to build an
+/// SCC of the arguments.
struct ArgumentGraphNode {
Argument *Definition;
SmallVector<ArgumentGraphNode *, 4> Uses;
struct ArgumentGraphNode {
Argument *Definition;
SmallVector<ArgumentGraphNode *, 4> Uses;
-// This tracker checks whether callees are in the SCC, and if so it does not
-// consider that a capture, instead adding it to the "Uses" list and
-// continuing with the analysis.
+/// This tracker checks whether callees are in the SCC, and if so it does not
+/// consider that a capture, instead adding it to the "Uses" list and
+/// continuing with the analysis.
struct ArgumentUsesTracker : public CaptureTracker {
ArgumentUsesTracker(const SmallPtrSet<Function *, 8> &SCCNodes)
: Captured(false), SCCNodes(SCCNodes) {}
struct ArgumentUsesTracker : public CaptureTracker {
ArgumentUsesTracker(const SmallPtrSet<Function *, 8> &SCCNodes)
: Captured(false), SCCNodes(SCCNodes) {}
-// Returns Attribute::None, Attribute::ReadOnly or Attribute::ReadNone.
+/// Returns Attribute::None, Attribute::ReadOnly or Attribute::ReadNone.
static Attribute::AttrKind
determinePointerReadAttrs(Argument *A,
const SmallPtrSet<Argument *, 8> &SCCNodes) {
static Attribute::AttrKind
determinePointerReadAttrs(Argument *A,
const SmallPtrSet<Argument *, 8> &SCCNodes) {
return IsRead ? Attribute::ReadOnly : Attribute::ReadNone;
}
return IsRead ? Attribute::ReadOnly : Attribute::ReadNone;
}
-/// AddArgumentAttrs - Deduce nocapture attributes for the SCC.
+/// Deduce nocapture attributes for the SCC.
bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
bool Changed = false;
bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
bool Changed = false;
-/// IsFunctionMallocLike - A function is malloc-like if it returns either null
-/// or a pointer that doesn't alias any other pointer visible to the caller.
+/// Tests whether a function is "malloc-like".
+///
+/// A function is "malloc-like" if it returns either null or a pointer that
+/// doesn't alias any other pointer visible to the caller.
bool FunctionAttrs::IsFunctionMallocLike(
Function *F, SmallPtrSet<Function *, 8> &SCCNodes) const {
SmallSetVector<Value *, 8> FlowsToReturn;
bool FunctionAttrs::IsFunctionMallocLike(
Function *F, SmallPtrSet<Function *, 8> &SCCNodes) const {
SmallSetVector<Value *, 8> FlowsToReturn;
-/// AddNoAliasAttrs - Deduce noalias attributes for the SCC.
+/// Deduce noalias attributes for the SCC.
bool FunctionAttrs::AddNoAliasAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
bool FunctionAttrs::AddNoAliasAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
+/// Tests whether this function is known to not return null.
bool FunctionAttrs::ReturnsNonNull(Function *F,
SmallPtrSet<Function *, 8> &SCCNodes,
bool &Speculative) const {
bool FunctionAttrs::ReturnsNonNull(Function *F,
SmallPtrSet<Function *, 8> &SCCNodes,
bool &Speculative) const {
+/// Deduce nonnull attributes for the SCC.
bool FunctionAttrs::AddNonNullAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
bool FunctionAttrs::AddNonNullAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Function *, 8> SCCNodes;
-/// inferPrototypeAttributes - Analyze the name and prototype of the
-/// given function and set any applicable attributes. Returns true
-/// if any attributes were set and false otherwise.
+/// Analyze the name and prototype of the given function and set any applicable
+/// attributes.
+///
+/// Returns true if any attributes were set and false otherwise.
bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
if (F.hasFnAttribute(Attribute::OptimizeNone))
return false;
bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
if (F.hasFnAttribute(Attribute::OptimizeNone))
return false;
-/// annotateLibraryCalls - Adds attributes to well-known standard library
-/// call declarations.
+/// Adds attributes to well-known standard library call declarations.
bool FunctionAttrs::annotateLibraryCalls(const CallGraphSCC &SCC) {
bool MadeChange = false;
bool FunctionAttrs::annotateLibraryCalls(const CallGraphSCC &SCC) {
bool MadeChange = false;