diff options
| author | bors <bors@rust-lang.org> | 2022-11-12 17:39:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-12 17:39:11 +0000 |
| commit | cd128880b13bc9f7a919567926e801c8a1487cdb (patch) | |
| tree | b9833baeaed29cbd90dc9afa19b2053adced3537 /compiler/rustc_codegen_llvm/src | |
| parent | 8ef2485bd59cad3674b9c7de29316c20d7ddc6e7 (diff) | |
| parent | d532d6782195effb702d4e402dd2d6371af1c349 (diff) | |
| download | rust-cd128880b13bc9f7a919567926e801c8a1487cdb.tar.gz rust-cd128880b13bc9f7a919567926e801c8a1487cdb.zip | |
Auto merge of #104325 - GuillaumeGomez:rollup-19bzwoa, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #104110 (prevent uninitialized access in black_box for zero-sized-types) - #104117 (Mark `trait_upcasting` feature no longer incomplete.) - #104144 (Suggest removing unnecessary `.` to use a floating point literal) - #104250 (Migrate no result page link color to CSS variables) - #104261 (More accurately report error when formal and expected signature types differ) - #104263 (Add a reference to ilog2 in leading_zeros integer docs) - #104308 (Remove the old `ValidAlign` name) - #104319 (Fix non clickable source link) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/intrinsic.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 825011941a2..cf590a43826 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -340,17 +340,26 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { sym::black_box => { args[0].val.store(self, result); - + let result_val_span = [result.llval]; // We need to "use" the argument in some way LLVM can't introspect, and on // targets that support it we can typically leverage inline assembly to do // this. LLVM's interpretation of inline assembly is that it's, well, a black // box. This isn't the greatest implementation since it probably deoptimizes // more than we want, but it's so far good enough. + // + // For zero-sized types, the location pointed to by the result may be + // uninitialized. Do not "use" the result in this case; instead just clobber + // the memory. + let (constraint, inputs): (&str, &[_]) = if result.layout.is_zst() { + ("~{memory}", &[]) + } else { + ("r,~{memory}", &result_val_span) + }; crate::asm::inline_asm_call( self, "", - "r,~{memory}", - &[result.llval], + constraint, + inputs, self.type_void(), true, false, |
