Skip to content

Commit ba72d97

Browse files
Don't add unnamed address attributes to intrinsics.
Intrinsics never have an address, so it doesn't make sense to say that their address is unnamed.
1 parent 01b9cc5 commit ba72d97

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/librustc_trans/trans/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
798798
if key == $name {
799799
let f = declare::declare_cfn(ccx, $name, Type::func(&[], &$ret),
800800
ccx.tcx().mk_nil());
801+
llvm::SetUnnamedAddr(f, false);
801802
ccx.intrinsics().borrow_mut().insert($name, f.clone());
802803
return Some(f);
803804
}
@@ -806,6 +807,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
806807
if key == $name {
807808
let f = declare::declare_cfn(ccx, $name, Type::func(&[$($arg),*], &$ret),
808809
ccx.tcx().mk_nil());
810+
llvm::SetUnnamedAddr(f, false);
809811
ccx.intrinsics().borrow_mut().insert($name, f.clone());
810812
return Some(f);
811813
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: -C no-prepopulate-passes
12+
13+
#![feature(intrinsics)]
14+
15+
extern "rust-intrinsic" {
16+
fn sqrtf32(x: f32) -> f32;
17+
}
18+
// CHECK: @llvm.sqrt.f32(float) #{{[0-9]*}}
19+
20+
fn main() {
21+
unsafe { sqrtf32(0.0f32); }
22+
}

0 commit comments

Comments
 (0)