[OperandBundles] Have GlobalsModRef play nice with operand bundles
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 23 Dec 2015 09:58:46 +0000 (09:58 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 23 Dec 2015 09:58:46 +0000 (09:58 +0000)
A call site's use of a Value might not correspond to an argument
operand but to a bundle operand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256329 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/AliasAnalysisEvaluator.cpp
lib/Analysis/GlobalsModRef.cpp
test/Analysis/GlobalsModRef/nocapture.ll

index c2a95cc31ea2032eecb060abf1a842a14af93beb..12917b650e5eeba290b8c0bec8af3a37df728821 100644 (file)
@@ -167,10 +167,9 @@ bool AAEval::runOnFunction(Function &F) {
       if (!isa<Function>(Callee) && isInterestingPointer(Callee))
         Pointers.insert(Callee);
       // Consider formals.
-      for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
-           AI != AE; ++AI)
-        if (isInterestingPointer(*AI))
-          Pointers.insert(*AI);
+      for (Use &DataOp : CS.data_ops())
+        if (isInterestingPointer(DataOp))
+          Pointers.insert(DataOp);
       CallSites.insert(CS);
     } else {
       // Consider all operands.
index 51a83d5327719519d73aeca0d091a8c1b88f0528..ab2263ae374e6e7a9e835842533db79946deba22 100644 (file)
@@ -353,12 +353,12 @@ bool GlobalsAAResult::AnalyzeUsesOfPointer(Value *V,
     } else if (auto CS = CallSite(I)) {
       // Make sure that this is just the function being called, not that it is
       // passing into the function.
-      if (!CS.isCallee(&U)) {
+      if (CS.isDataOperand(&U)) {
         // Detect calls to free.
-        if (isFreeCall(I, &TLI)) {
+        if (CS.isArgOperand(&U) && isFreeCall(I, &TLI)) {
           if (Writers)
             Writers->insert(CS->getParent()->getParent());
-        } else if (CS.doesNotCapture(CS.getArgumentNo(&U))) {
+        } else if (CS.doesNotCapture(CS.getDataOperandNo(&U))) {
           Function *ParentF = CS->getParent()->getParent();
           // A nocapture argument may be read from or written to, but does not
           // escape unless the call can somehow recurse.
index 5b9c5e34cc7599522db2b8baa7aaa0bd8c357351..0cb80a10f8da2f53f89e62105ce25814ad333a1e 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt < %s -globals-aa -aa-eval -print-all-alias-modref-info -S 2>&1 | FileCheck %s
+; RUN: opt < %s -globals-aa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.10.0"
@@ -45,3 +45,13 @@ entry:
   store i32 %add, i32* %q, align 4
   ret i32 4
 }
+
+declare void @g3()
+
+; CHECK-LABEL: Function: f3
+; CHECK: NoAlias: i32* %p, i32* @b
+define void @f3(i32* nocapture readonly %p) {
+entry:
+  tail call void @g3() [ "deopt"(i32* @b, i32 *%p) ]
+  unreachable
+}