llvm.org GIT mirror llvm / 6cd2075
In the default address space, any GEP off of null results in a trap value if you try to load it. Thus, any load in the default address space that completes implies that the base value that it GEP'd from was not null. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112015 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
2 changed file(s) with 53 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
456456 // then we know that the pointer can't be NULL.
457457 if (Val->getType()->isPointerTy()) {
458458 const PointerType *PTy = cast(Val->getType());
459 for (Value::use_iterator UI = Val->use_begin(), UE = Val->use_end();
460 UI != UE; ++UI) {
461 LoadInst *L = dyn_cast(*UI);
462 if (L && L->getParent() == BB && L->getPointerAddressSpace() == 0) {
459 for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();BI != BE;++BI){
460 LoadInst *L = dyn_cast(BI);
461 if (L && L->getPointerAddressSpace() == 0 &&
462 L->getPointerOperand()->getUnderlyingObject() ==
463 Val->getUnderlyingObject()) {
463464 return LVILatticeVal::getNot(ConstantPointerNull::get(PTy));
464465 }
465466 }
0 ; RUN: opt -S -jump-threading -enable-jump-threading-lvi < %s | FileCheck %s
1 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
2 target triple = "x86_64-apple-darwin10.4"
3
4 %"struct.llvm::PATypeHolder" = type { %"struct.llvm::Type"* }
5 %"struct.llvm::PointerIntPair >" = type { i64 }
6 %"struct.llvm::Type" = type opaque
7 %"struct.llvm::Use" = type { %"struct.llvm::Value"*, %"struct.llvm::Use"*, %"struct.llvm::PointerIntPair >" }
8 %"struct.llvm::Value" = type { i32 (...)**, i8, i8, i16, %"struct.llvm::PATypeHolder", %"struct.llvm::Use"*, %"struct.llvm::ValueName"* }
9 %"struct.llvm::ValueName" = type opaque
10
11 @_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__ = internal constant [5 x i8] c"cast\00", align 8 ; <[5 x i8]*> [#uses=1]
12 @.str = private constant [31 x i8] c"include/llvm/Support/Casting.h\00", align 8 ; <[31 x i8]*> [#uses=1]
13 @.str1 = private constant [59 x i8] c"isa(Val) && \22cast() argument of incompatible type!\22\00", align 8 ; <[59 x i8]*> [#uses=1]
14
15 ; CHECK: Z3fooPN4llvm5ValueE
16 define zeroext i8 @_Z3fooPN4llvm5ValueE(%"struct.llvm::Value"* %V) ssp {
17 entry:
18 %0 = getelementptr inbounds %"struct.llvm::Value"* %V, i64 0, i32 1 ; [#uses=1]
19 %1 = load i8* %0, align 8 ; [#uses=2]
20 %2 = icmp ugt i8 %1, 20 ; [#uses=1]
21 br i1 %2, label %bb.i, label %bb2
22
23 bb.i: ; preds = %entry
24 %toBoolnot.i.i = icmp ult i8 %1, 21 ; [#uses=1]
25 br i1 %toBoolnot.i.i, label %bb6.i.i, label %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
26
27 bb6.i.i: ; preds = %bb.i
28 tail call void @__assert_rtn(i8* getelementptr inbounds ([5 x i8]* @_ZZN4llvm4castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_E8__func__, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8]* @.str, i64 0, i64 0), i32 202, i8* getelementptr inbounds ([59 x i8]* @.str1, i64 0, i64 0)) noreturn
29 unreachable
30
31 _ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %bb.i
32 ; CHECK-NOT: null
33 %3 = icmp eq %"struct.llvm::Value"* %V, null ; [#uses=1]
34 br i1 %3, label %bb2, label %bb
35
36 bb: ; preds = %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
37 tail call void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"* %V)
38 ; CHECK: ret
39 ret i8 1
40
41 bb2: ; preds = %entry, %_ZN4llvm8dyn_castINS_11InstructionEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit
42 ret i8 0
43 }
44
45 declare void @__assert_rtn(i8*, i8*, i32, i8*) noreturn
46
47 declare void @_ZNK4llvm5Value4dumpEv(%"struct.llvm::Value"*)