[llvm] fa26da0 - Add a couple of missing attribute query methods [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 17:33:30 PDT 2021


Author: Philip Reames
Date: 2021-03-18T17:33:20-07:00
New Revision: fa26da0582a4d5d922379db1d9fae87416b650d6

URL: https://github.com/llvm/llvm-project/commit/fa26da0582a4d5d922379db1d9fae87416b650d6
DIFF: https://github.com/llvm/llvm-project/commit/fa26da0582a4d5d922379db1d9fae87416b650d6.diff

LOG: Add a couple of missing attribute query methods [NFC]

Added: 
    

Modified: 
    llvm/include/llvm/IR/Argument.h
    llvm/include/llvm/IR/Function.h
    llvm/lib/IR/Function.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Argument.h b/llvm/include/llvm/IR/Argument.h
index 76d780485ea0..e8ca8a6e81b9 100644
--- a/llvm/include/llvm/IR/Argument.h
+++ b/llvm/include/llvm/IR/Argument.h
@@ -120,6 +120,9 @@ class Argument final : public Value {
   /// Return true if this argument has the nocapture attribute.
   bool hasNoCaptureAttr() const;
 
+  /// Return true if this argument has the nofree attribute.
+  bool hasNoFreeAttr() const;
+
   /// Return true if this argument has the sret attribute.
   bool hasStructRetAttr() const;
 

diff  --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index b1ef3b113190..b3a1b6c03618 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -624,6 +624,14 @@ class Function : public GlobalObject, public ilist_node<Function> {
     addFnAttr(Attribute::NoFree);
   }
 
+  /// Determine if the call can synchroize with other threads
+  bool hasNoSync() const {
+    return hasFnAttribute(Attribute::NoSync);
+  }
+  void setNoSync() {
+    addFnAttr(Attribute::NoSync);
+  }
+
   /// Determine if the function is known not to recurse, directly or
   /// indirectly.
   bool doesNotRecurse() const {

diff  --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 553db4e8f3f1..46aec7294572 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -240,6 +240,11 @@ bool Argument::hasNoCaptureAttr() const {
   return hasAttribute(Attribute::NoCapture);
 }
 
+bool Argument::hasNoFreeAttr() const {
+  if (!getType()->isPointerTy()) return false;
+  return hasAttribute(Attribute::NoFree);
+}
+
 bool Argument::hasStructRetAttr() const {
   if (!getType()->isPointerTy()) return false;
   return hasAttribute(Attribute::StructRet);


        


More information about the llvm-commits mailing list