llvm.org GIT mirror llvm / 4188784
[RS4GC] Remove an overly strong assertion As shown by the included test case, it's reasonable to end up with constant references during base pointer calculation. The code actually handled this case just fine, we only had the assert to help isolate problems under the belief that constant references shouldn't be present in IR generated by managed frontends. This turned out to be wrong on two fronts: 1) Manual Jacobs is working on a language with constant references, and b) we found a case where the optimizer does create them in practice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256079 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 3 years ago
2 changed file(s) with 40 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
443443 if (isa(I)) {
444444 assert(!isa(I) && !isa(I) &&
445445 "order of checks wrong!");
446 // Note: Finding a constant base for something marked for relocation
447 // doesn't really make sense. The most likely case is either a) some
448 // screwed up the address space usage or b) your validating against
449 // compiled C++ code w/o the proper separation. The only real exception
450 // is a null pointer. You could have generic code written to index of
451 // off a potentially null value and have proven it null. We also use
452 // null pointers in dead paths of relocation phis (which we might later
453 // want to find a base pointer for).
454 assert(isa(I) &&
455 "null is the only case which makes sense");
446 // Note: Even for frontends which don't have constant references, we can
447 // see constants appearing after optimizations. A simple example is
448 // specialization of an address computation on null feeding into a merge
449 // point where the actual use of the now-constant input is protected by
450 // another null check. (e.g. test4 in constants.ll)
456451 return BaseDefiningValueResult(I, true);
457452 }
458453
5656 ret i8 %res
5757 }
5858
59 ; Even for source languages without constant references, we can
60 ; see constants can show up along paths where the value is dead.
61 ; This is particular relevant when computing bases of PHIs.
62 define i8 addrspace(1)* @test4(i8 addrspace(1)* %p) gc "statepoint-example" {
63 ; CHECK-LABEL: @test4
64 entry:
65 %is_null = icmp eq i8 addrspace(1)* %p, null
66 br i1 %is_null, label %split, label %join
5967
68 split:
69 call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0)
70 %arg_value_addr.i = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8
71 %arg_value_addr_casted.i = bitcast i8 addrspace(1)* %arg_value_addr.i to i8 addrspace(1)* addrspace(1)*
72 br label %join
73
74 join:
75 ; CHECK-LABEL: join
76 ; CHECK: %addr2.base =
77 %addr2 = phi i8 addrspace(1)* addrspace(1)* [ %arg_value_addr_casted.i, %split ], [ inttoptr (i64 8 to i8 addrspace(1)* addrspace(1)*), %entry ]
78 ;; NOTE: This particular example can be jump-threaded, but in general,
79 ;; we can't, and have to deal with the resulting IR.
80 br i1 %is_null, label %early-exit, label %use
81
82 early-exit:
83 ret i8 addrspace(1)* null
84
85 use:
86 ; CHECK-LABEL: use:
87 ; CHECK: gc.statepoint
88 ; CHECK: gc.relocate
89 call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0)
90 %res = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %addr2, align 1
91 ret i8 addrspace(1)* %res
92 }
93
94