-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generationregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
https://play.rust-lang.org/?gist=7555908f8176d50b10cd06a4a5dba401&version=nightly&mode=release
Given code like:
#![crate_type = "lib"]
use std::sync::atomic::*;
static A: AtomicUsize = ATOMIC_USIZE_INIT;
pub unsafe fn foo() {
A.load(Ordering::SeqCst);
}
the generated LLVM IR is:
; ModuleID = 'playground0-99a4292f5ecb26a54a3204a5a67308ec.rs'
source_filename = "playground0-99a4292f5ecb26a54a3204a5a67308ec.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@_ZN10playground1A17h5c8cc46ff3ae8084E = internal unnamed_addr constant <{ [8 x i8] }> zeroinitializer, align 8
; playground::foo
; Function Attrs: norecurse nounwind uwtable
define void @_ZN10playground3foo17h1cb1a21ad3c6e213E() unnamed_addr #0 {
start:
%0 = load atomic i64, i64* bitcast (<{ [8 x i8] }>* @_ZN10playground1A17h5c8cc46ff3ae8084E to i64*) seq_cst, align 8
ret void
}
attributes #0 = { norecurse nounwind uwtable "probe-stack"="__rust_probestack" }
and unfortunately our atomic load wasn't optimized away!
I believe this is a regression from stable to beta due to the way that miri defines statics (looks like LLVM doesn't recognize the bitcast) cc @oli-obk
stepancheg and Demindiro
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generationregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.