diff options
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index b84620c4811..60cc874d4d4 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -120,8 +120,12 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, AAResults &AAR, // 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); diff --git a/llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll b/llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll new file mode 100644 index 00000000000..2502ea719ca --- /dev/null +++ b/llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll @@ -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 +} |