mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Emit retags in codegen to support BorrowSanitizer (part 5) Tracking issue: rust-lang/rust#154760 [Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/592364811) This is one of several PRs that add experimental support for emitting retags as function calls in codegen. This PR adds support for emitting global arrays that specify the ranges of interior mutable and pinned data. For example, ```rust fn cell(x: &(i32, Cell<i32>)) { ... } ``` This program will have IR similar to the following: ```llvm @anon.0 = unnamed_addr constant [16 x i8] c"\04...\04..." define void @cell(ptr %0) { start: %x = call ptr @__rust_retag_reg(ptr %0, i64 8, i8 1, ptr @anon.0, ptr null) ... } ``` The last four bytes at offset four are interior mutable. Users can disable this behavior by passing `no-precise-im` or `no-precise-pin` as options to `-Zcodegen-emit-retag`. In that case, the last two parameters to the retag intrinsic will always be null pointers. BorrowSanitizer will be able to switch to using nightly once this is merged. Thank you @saethlin for reviewing these PRs! Note: we still do not support retagging SIMD types, since cg-ssa does not support `insertelement`. Related: rust-lang/rust#158100 Cc: @RalfJung r? @saethlin
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.