Hi all,<br><br>There might be a bug in DeadStoreElimination.cpp. This pass eliminates stores backwards aggressively in an end BB. It does not check dependencies on stores in an end BB though. For example, in this code snippet:<br>
  ...<br>1.  %sum.safe_r47.pre-phi = phi i64* [ %sum.safe_r47.pre, %entry.for.end_crit_edge ], [ %sum.safe_r42, %for.body ]<br>2.  %call9 = call i32 @gettimeofday(%struct.timeval* %end, %struct.timeval* null) nounwind<br>
3.  %0 = bitcast %struct.timeval* %start to i64*           // eliminated by HandleEndBlock in DeadStoreElimination.cpp<br>4.  %1 = bitcast %struct.timeval* %agg.tmp to i64*     // eliminated ...<br>5.  %tmp49 = load i64* %0, align 8                             // eliminated ...<br>
6.  store i64 %tmp49, i64* %1, align 8                         // eliminated ...<br>7.  %2 = bitcast %struct.timeval* %end to i64*             // eliminated ...<br>8.  %3 = bitcast %struct.timeval* %agg.tmp12 to i64*   // eliminated ...<br>
9.  %tmp50 = load i64* %2, align 8                               // eliminated ...<br>10.  store i64 %tmp50, i64* %3, align 8                           // eliminated ...<br>11.  %tv_sec = getelementptr inbounds %struct.timeval* %agg.tmp, i32 0, i32 0       <br>
12.  %tv_sec.safe_r = call i32* @llvm.guard.load.p0i32(i32* %tv_sec)   // intrinsic  function call inserted by me<br>13.  %tmp15 = load i32* %tv_sec.safe_r, align 4, !tbaa !4                     // this loads the value stored at line 6<br>
14.  %tv_usec = getelementptr inbounds %struct.timeval* %agg.tmp, i32 0, i32 1<br>15.  %tv_usec.safe_r = call i32* @llvm.guard.load.p0i32(i32* %tv_usec)  // intrinsic function call ...<br>16.  %tmp16 = load i32* %tv_usec.safe_r, align 4, !tbaa !4<br>
17.  %tv_sec17 = getelementptr inbounds %struct.timeval* %agg.tmp12, i32 0, i32 0<br>18.  %tv_sec17.safe_r = call i32* @llvm.guard.load.p0i32(i32* %tv_sec17)  // intrinsic function call ...<br>19.  %tmp18 = load i32* %tv_sec17.safe_r, align 4, !tbaa !4<br>
20.  %tv_usec19 = getelementptr inbounds %struct.timeval* %agg.tmp12, i32 0, i32 1<br>21.  %tv_usec19.safe_r = call i32* @llvm.guard.load.p0i32(i32* %tv_usec19)  // intrinsic function call <br>22.  %tmp20 = load i32* %tv_usec19.safe_r, align 4, !tbaa !4<br>
23.  %call21 = call i32 @delta(i32 %tmp15, i32 %tmp16, i32 %tmp18, i32 %tmp20)<br>  ...<br><br>It is compiled by clang 2.9. This BB is an end block in a function. Intrinsic function llvm.guard.load.p0i32 is defined as follows:<br>
let Properties = [IntrNoMem, NoCapture<0>] in {<br>    def int_guard_load   : Intrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>]><br>}<br><br>Thanks a lot.<br>Bin<br>