Skip to content

Commit 0c115bf

Browse files
committed
Use poison instead of undef
In cases where it is legal, we should prefer poison values over undef values. This replaces undef with poison for aggregate construction and for uninhabited types. There are more places where we can likely use poison, but I wanted to stay conservative to start with. In particular the aggregate case is important for newer LLVM versions, which are not able to handle an undef base value during early optimization due to poison-propagation concerns.
1 parent ee38de5 commit 0c115bf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
7373
}
7474
}
7575

76+
fn const_poison(&self, typ: Type<'gcc>) -> RValue<'gcc> {
77+
// No distinction between undef and poison.
78+
self.const_undef(typ)
79+
}
80+
7681
fn const_int(&self, typ: Type<'gcc>, int: i64) -> RValue<'gcc> {
7782
self.gcc_int(typ, int)
7883
}

0 commit comments

Comments
 (0)