ConstantPointerNull::get(cast<PointerType>(I->getType())), true);
}
+ // inttoptrs in an integral address space are currently ill-defined. We
+ // treat them as defining base pointers here for consistency with the
+ // constant rule above and because we don't really have a better semantic
+ // to give them. Note that the optimizer is always free to insert undefined
+ // behavior on dynamically dead paths as well.
+ if (isa<IntToPtrInst>(I))
+ return BaseDefiningValueResult(I, true);
+
if (CastInst *CI = dyn_cast<CastInst>(I)) {
Value *Def = CI->stripPointerCasts();
// If stripping pointer casts changes the address space there is an
--- /dev/null
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @foo()
+
+define i8 addrspace(1)* @test(i64 %i) gc "statepoint-example" {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: [[P:%.*]] = inttoptr i64 [[I:%.*]] to i8 addrspace(1)*
+; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i8 addrspace(1)* [[P]]) ]
+; CHECK-NEXT: [[P_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
+; CHECK-NEXT: ret i8 addrspace(1)* [[P_RELOCATED]]
+;
+ %p = inttoptr i64 %i to i8 addrspace(1)*
+ call void @foo()
+ ret i8 addrspace(1)* %p
+}