Skip to content

Commit a3b9405

Browse files
committed
Use more robust checks in rustc for wasm
1 parent d2a3c24 commit a3b9405

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
769769
// we like. To ensure that LLVM picks the right instruction we choose
770770
// the raw wasm intrinsic functions which avoid LLVM inserting all the
771771
// other control flow automatically.
772-
if self.sess().target.arch.starts_with("wasm32") {
772+
if self.sess().target.is_like_wasm {
773773
let src_ty = self.cx.val_ty(val);
774774
if self.cx.type_kind(src_ty) != TypeKind::Vector {
775775
let float_width = self.cx.float_width(src_ty);
@@ -791,7 +791,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
791791

792792
fn fptosi(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {
793793
// see `fptoui` above for why wasm is different here
794-
if self.sess().target.arch.starts_with("wasm") {
794+
if self.sess().target.is_like_wasm {
795795
let src_ty = self.cx.val_ty(val);
796796
if self.cx.type_kind(src_ty) != TypeKind::Vector {
797797
let float_width = self.cx.float_width(src_ty);

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
490490

491491
// Wasm statics with custom link sections get special treatment as they
492492
// go into custom sections of the wasm executable.
493-
if self.tcx.sess.opts.target_triple.triple().starts_with("wasm") {
493+
if self.tcx.sess.target.is_like_wasm {
494494
if let Some(section) = attrs.link_section {
495495
let section = llvm::LLVMMDStringInContext(
496496
self.llcx,

compiler/rustc_typeck/src/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ fn fn_maybe_err(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
536536
}
537537

538538
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId, span: Span) {
539-
// Only restricted on wasm32 target for now
540-
if !tcx.sess.opts.target_triple.triple().starts_with("wasm") {
539+
// Only restricted on wasm target for now
540+
if !tcx.sess.target.is_like_wasm {
541541
return;
542542
}
543543

0 commit comments

Comments
 (0)