[llvm] r228606 - isDereferenceablePointer: look through gc.relocate calls

Ramkumar Ramachandra artagnon at gmail.com
Mon Feb 9 13:08:03 PST 2015


Author: artagnon
Date: Mon Feb  9 15:08:03 2015
New Revision: 228606

URL: http://llvm.org/viewvc/llvm-project?rev=228606&view=rev
Log:
isDereferenceablePointer: look through gc.relocate calls

While a theoretical GC might change dereferenceability on collection,
there is no such known collector and no need to account for the case
with a flag yet.

Differential Revision: http://reviews.llvm.org/D7454

Modified:
    llvm/trunk/lib/IR/Value.cpp
    llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll

Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=228606&r1=228605&r2=228606&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Mon Feb  9 15:08:03 2015
@@ -23,8 +23,10 @@
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/IR/Statepoint.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/Support/Debug.h"
@@ -570,6 +572,13 @@ static bool isDereferenceablePointer(con
     return true;
   }
 
+  // For gc.relocate, look through relocations
+  if (const IntrinsicInst *I = dyn_cast<IntrinsicInst>(V))
+    if (I->getIntrinsicID() == Intrinsic::experimental_gc_relocate) {
+      GCRelocateOperands RelocateInst(I);
+      return isDereferenceablePointer(RelocateInst.derivedPtr(), DL, Visited);
+    }
+
   if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
     return isDereferenceablePointer(ASC->getOperand(0), DL, Visited);
 

Modified: llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll?rev=228606&r1=228605&r2=228606&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll (original)
+++ llvm/trunk/test/Analysis/ValueTracking/memory-dereferenceable.ll Mon Feb  9 15:08:03 2015
@@ -12,8 +12,7 @@ define void @test(i32 addrspace(1)* byva
 ; CHECK: %globalptr
 ; CHECK: %alloca
 ; CHECK: %dparam
-; We haven't yet taught it to look through relocations
-; CHECK-NOT: %relocate
+; CHECK: %relocate
 ; CHECK-NOT: %nparam
 entry:
     %globalptr = getelementptr inbounds [6 x i8]* @globalstr, i32 0, i32 0





More information about the llvm-commits mailing list