[llvm] r260244 - [FunctionAttrs] Fix SCC logic around operand bundles

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 10:40:40 PST 2016


Author: sanjoy
Date: Tue Feb  9 12:40:40 2016
New Revision: 260244

URL: http://llvm.org/viewvc/llvm-project?rev=260244&view=rev
Log:
[FunctionAttrs] Fix SCC logic around operand bundles

FunctionAttrs does an "optimistic" analysis of SCCs as a unit, which
means normally it is able to disregard calls from an SCC into itself.
However, calls and invokes with operand bundles are allowed to have
memory effects not fully described by the memory effects on the call
target, so we can't be optimistic around operand-bundled calls from an
SCC into itself.

Added:
    llvm/trunk/test/Transforms/FunctionAttrs/operand-bundles-scc.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp

Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=260244&r1=260243&r2=260244&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Feb  9 12:40:40 2016
@@ -120,8 +120,12 @@ static MemoryAccessKind checkFunctionMem
     // Detect these now, skipping to the next instruction if one is found.
     CallSite CS(cast<Value>(I));
     if (CS) {
-      // Ignore calls to functions in the same SCC.
-      if (CS.getCalledFunction() && SCCNodes.count(CS.getCalledFunction()))
+      // Ignore calls to functions in the same SCC, as long as the call sites
+      // don't have operand bundles.  Calls with operand bundles are allowed to
+      // have memory effects not described by the memory effects of the call
+      // target.
+      if (!CS.hasOperandBundles() && CS.getCalledFunction() &&
+          SCCNodes.count(CS.getCalledFunction()))
         continue;
       FunctionModRefBehavior MRB = AAR.getModRefBehavior(CS);
 

Added: llvm/trunk/test/Transforms/FunctionAttrs/operand-bundles-scc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/operand-bundles-scc.ll?rev=260244&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/operand-bundles-scc.ll (added)
+++ llvm/trunk/test/Transforms/FunctionAttrs/operand-bundles-scc.ll Tue Feb  9 12:40:40 2016
@@ -0,0 +1,13 @@
+; RUN: opt -S -functionattrs < %s | FileCheck %s
+
+define void @f() {
+; CHECK-LABEL:  define void @f() {
+ call void @g() [ "unknown"() ]
+ ret void
+}
+
+define void @g() {
+; CHECK-LABEL:  define void @g() {
+ call void @f()
+ ret void
+}




More information about the llvm-commits mailing list