[llvm] f4f40c6 - [Attributor] Introduce a hook for AAs to avoid inline-asm

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 22:16:26 PDT 2023


Author: Johannes Doerfert
Date: 2023-09-01T22:14:38-07:00
New Revision: f4f40c6dfde46829438a7c4aa815fdffcc7a28e6

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

LOG: [Attributor] Introduce a hook for AAs to avoid inline-asm

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/IPO/Attributor.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 02c339caefec4d..296aeb99e40569 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1742,10 +1742,16 @@ struct Attributor {
 
     Function *AssociatedFn = IRP.getAssociatedFunction();
 
-    // Check if we require a callee but there is none.
-    if (!AssociatedFn && AAType::requiresCalleeForCallBase() &&
-        IRP.isAnyCallSitePosition())
-      return false;
+    if (IRP.isAnyCallSitePosition()) {
+      // Check if we require a callee but there is none.
+      if (!AssociatedFn && AAType::requiresCalleeForCallBase())
+        return false;
+
+      // Check if we require non-asm but it is inline asm.
+      if (AAType::requiresNonAsmForCallBase() &&
+          cast<CallBase>(IRP.getAnchorValue()).isInlineAsm())
+        return false;
+    }
 
     // Check if we require a calles but we can't see all.
     if (AAType::requiresCallersForArgOrFunction())
@@ -3291,6 +3297,9 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
   /// a call site positon. Default is optimistic to minimize AAs.
   static bool requiresCalleeForCallBase() { return true; }
 
+  /// Return true if this AA requires non-asm "callee" for a call site positon.
+  static bool requiresNonAsmForCallBase() { return true; }
+
   /// Return true if this AA requires all callees for an argument or function
   /// positon.
   static bool requiresCallersForArgOrFunction() { return false; }
@@ -5476,6 +5485,9 @@ struct AACallEdges : public StateWrapper<BooleanState, AbstractAttribute>,
   /// unknown callees.
   static bool requiresCalleeForCallBase() { return false; }
 
+  /// See AbstractAttribute::requiresNonAsmForCallBase.
+  static bool requiresNonAsmForCallBase() { return false; }
+
   /// Get the optimistic edges.
   virtual const SetVector<Function *> &getOptimisticEdges() const = 0;
 


        


More information about the llvm-commits mailing list