<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77794>77794</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
non-determinism regression exposed by f1b0a544514f3d343f32a41de9d6fb0b6cbb6021
</td>
</tr>
<tr>
<th>Labels</th>
<td>
tools:opt,
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
jmorse
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZequanWu
</td>
</tr>
</table>
<pre>
f1b0a544514f3d343f32a41de9d6fb0b6cbb6021 exposed a non-determinism on opt.
To repro, build opt at trunk and use different allocators between two runs:
```
$ opt -O2 -S reduced.ll -o opt.ll -opt-bisect-limit=382
$ LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 opt -O2 -S reduced.ll -o opt.ll.2 -opt-bisect-limit=382
$ diff opt.ll opt.ll.2
```
reduced.ll:
```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
$_ZN2v84base11CheckGEImplIiiEEPNSt4__Cr12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_T0_PKc = comdat any
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #0
; Function Attrs: null_pointer_is_valid
define linkonce_odr ptr @_ZN2v84base11CheckGEImplIiiEEPNSt4__Cr12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_T0_PKc(i32 %0, i32 %1, ptr %2) #1 comdat {
%4 = call i1 @_ZN2v84base9CmpGEImplIiiEENSt4__Cr9enable_ifIXaantsr21is_signed_vs_unsignedIT_T0_EE5valuentsr21is_unsigned_vs_signedIS4_S5_EE5valueEbE4typeES4_S5_(i32 %0)
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = load ptr, ptr null, align 8
br label %7
7: ; preds = %5, %3
%8 = phi ptr [ %6, %5 ], [ null, %3 ]
ret ptr %8
}
define i64 @_ZN2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE11PaddingSizeEv() {
%1 = call i32 @_Z7RoundUpILl4EiET0_S0_()
%2 = sext i32 %1 to i64
ret i64 %2
}
; Function Attrs: null_pointer_is_valid
define i32 @_ZN2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE20DataTableStartOffsetEv() #1 {
%1 = call i64 @_ZN2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE11PaddingSizeEv()
%2 = trunc i64 %1 to i32
ret i32 %2
}
; Function Attrs: null_pointer_is_valid
define i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE8CapacityEv(i32 %0) #1 {
%2 = call i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE15NumberOfBucketsEv()
%3 = call ptr @_ZN2v84base11CheckGEImplIiiEEPNSt4__Cr12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_T0_PKc(i32 %0, i32 0, ptr null)
%.not = icmp eq ptr %3, null
br i1 %.not, label %6, label %4
4: ; preds = %1
%5 = load volatile ptr, ptr null, align 8
br label %6
6: ; preds = %4, %1
%7 = call ptr @_ZN2v84base11CheckLEImplIiiEEPNSt4__Cr12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_T0_PKc(i32 %0)
ret i32 0
}
define ptr @_ZN2v84base11CheckLEImplIiiEEPNSt4__Cr12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEET_T0_PKc(i32 %0) {
%2 = call i1 @_ZN2v84base9CmpLEImplIiiEENSt4__Cr9enable_ifIXaantsr21is_signed_vs_unsignedIT_T0_EE5valuentsr21is_unsigned_vs_signedIS4_S5_EE5valueEbE4typeES4_S5_(i32 %0)
%3 = zext i1 %2 to i64
%4 = call i64 @llvm.expect.i64(i64 %3, i64 1)
%.not = icmp eq i64 %4, 0
br i1 %.not, label %5, label %common.ret
common.ret: ; preds = %5, %1
ret ptr null
5: ; preds = %1
%6 = load volatile ptr, ptr null, align 8
br label %common.ret
}
define i1 @_ZN2v84base9CmpGEImplIiiEENSt4__Cr9enable_ifIXaantsr21is_signed_vs_unsignedIT_T0_EE5valuentsr21is_unsigned_vs_signedIS4_S5_EE5valueEbE4typeES4_S5_(i32 %0) {
%2 = icmp sgt i32 %0, 0
ret i1 %2
}
; Function Attrs: null_pointer_is_valid
define i32 @_Z7RoundUpILl4EiET0_S0_() #1 {
%1 = load i32, ptr null, align 4
ret i32 %1
}
define i1 @_ZN2v84base9CmpLEImplIiiEENSt4__Cr9enable_ifIXaantsr21is_signed_vs_unsignedIT_T0_EE5valuentsr21is_unsigned_vs_signedIS4_S5_EE5valueEbE4typeES4_S5_(i32 %0) {
%2 = icmp slt i32 %0, 2
ret i1 %2
}
; Function Attrs: null_pointer_is_valid
define i8 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE7getByteEii() #1 {
store i32 1, ptr null, align 4
%1 = call i32 @_ZN2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE20DataTableStartOffsetEv()
%2 = icmp sgt i32 %1, 0
br i1 %2, label %.critedge, label %3
3: ; preds = %0
%4 = load i32, ptr null, align 4
%5 = call i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE21GetBucketsStartOffsetEv()
%6 = icmp sgt i32 %4, 0
br i1 %6, label %.critedge, label %7
7: ; preds = %3
call void null(ptr null, i32 0, ptr null)
br label %.critedge
.critedge: ; preds = %7, %3, %0
ret i8 0
}
define i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE21GetBucketsStartOffsetEv() {
%1 = call i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE8CapacityEv(i32 0)
ret i32 0
}
define i32 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE15NumberOfBucketsEv() {
%1 = call i8 @_ZNK2v88internal21SmallOrderedHashTableINS0_26SmallOrderedNameDictionaryEE7getByteEii()
ret i32 0
}
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { null_pointer_is_valid }
```
@jmorse sent a https://github.com/llvm/llvm-project/pull/77774 to fix it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWV1P8zja_jXhxGoVO1_tQQ-ApvOiQfBoyqtdzUnkJHeKB8fO2A7Q59ev7KRtWkqBWWBmEUodx_Z93Z--ElOt2UoAzLzowiPkj1oqDR4hXjQ_o625l2r2O_zZUvGv9iyX5XpW4dynURhGOKyCMgiDKiA0xCVMy7jK_Twu8jz2CUbw3EgNJaJISDEqwYCqmWC6RlIg2Zix5889_7y73kmkoFHSI5cobxkv7QhEDTKqFQ-IihK1GlDJqgoUCIMo57KgRiqNcjBPAAKZJ4lUK7QX9It6sd__d7ckdKuObgkaLZGCsi2gHHOORtIBcq3GjHKmoTAjzmpmvGAeTMhuget59uO39Pr2fO4Fc48sWq08suAs98jieRJncTjiTLTPo5VouwemqB3YsZbjNwGMydsQrBE2eDezjivsrjsxrxnGULUCg0pqKKdr2RrkBXPkEQKj2gvOYdSQxPeC84C4i73F-7e2FYfuMmLbBiYTLzjHZDKqJn7fEq4r3kyPw9HSDiNkD4pRrOGwgdHbtRUPQj6JoX3JUFGPhNnvN-RxEuZUA8aX91A8_JJe1Q2_YixNf9wsTZhllwqTnGpWZNooJlZXxc2SZBgX91RlRlFm9FWRprZzuo0y25Omd9mdn_34tXDAClmX1CAq1nsgggu0aEVhmBTo3BhlwxEJWVDOc1o8ICErBYCE1GtRICFb8cREiZ4Y5wpMqwSqoZZq7ZGJkAI8Mu0WLqHgVAFicYi80Of8sR7DcwOFGVuLk4m7XiL3M0UeCfx34Go5zxrJhAGVMZ09Us7KjbyKCUCciQcpCshkqVBjlJX9TVa2OgUEe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