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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228606 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ramkumar Ramachandra 2015-02-09 21:08:03 +00:00
parent 4b97d2ca91
commit ba59efdfc8
2 changed files with 10 additions and 2 deletions

View File

@ -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(const Value *V, const DataLayout *DL,
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);

View File

@ -12,8 +12,7 @@ define void @test(i32 addrspace(1)* byval %dparam) {
; 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