9
9
// except according to those terms.
10
10
//! Set and unset common attributes on LLVM values.
11
11
12
- use std:: ffi:: { CStr , CString } ;
12
+ use std:: ffi:: CString ;
13
13
14
14
use rustc:: hir:: CodegenFnAttrFlags ;
15
15
use rustc:: hir:: def_id:: { DefId , LOCAL_CRATE } ;
@@ -75,7 +75,7 @@ pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value)
75
75
if cx. sess ( ) . must_not_eliminate_frame_pointers ( ) {
76
76
llvm:: AddFunctionAttrStringValue (
77
77
llfn, llvm:: AttributePlace :: Function ,
78
- cstr ( "no-frame-pointer-elim\0 " ) , cstr ( "true\0 " ) ) ;
78
+ const_cstr ! ( "no-frame-pointer-elim" ) , const_cstr ! ( "true" ) ) ;
79
79
}
80
80
}
81
81
@@ -108,7 +108,7 @@ pub fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
108
108
// This is defined in the `compiler-builtins` crate for each architecture.
109
109
llvm:: AddFunctionAttrStringValue (
110
110
llfn, llvm:: AttributePlace :: Function ,
111
- cstr ( "probe-stack\0 " ) , cstr ( "__rust_probestack\0 " ) ) ;
111
+ const_cstr ! ( "probe-stack" ) , const_cstr ! ( "__rust_probestack" ) ) ;
112
112
}
113
113
114
114
pub fn llvm_target_features ( sess : & Session ) -> impl Iterator < Item = & str > {
@@ -202,7 +202,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
202
202
let val = CString :: new ( features) . unwrap ( ) ;
203
203
llvm:: AddFunctionAttrStringValue (
204
204
llfn, llvm:: AttributePlace :: Function ,
205
- cstr ( "target-features\0 " ) , & val) ;
205
+ const_cstr ! ( "target-features" ) , & val) ;
206
206
}
207
207
208
208
// Note that currently the `wasm-import-module` doesn't do anything, but
@@ -213,17 +213,13 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
213
213
llvm:: AddFunctionAttrStringValue (
214
214
llfn,
215
215
llvm:: AttributePlace :: Function ,
216
- cstr ( "wasm-import-module\0 " ) ,
216
+ const_cstr ! ( "wasm-import-module" ) ,
217
217
& module,
218
218
) ;
219
219
}
220
220
}
221
221
}
222
222
223
- fn cstr ( s : & ' static str ) -> & CStr {
224
- CStr :: from_bytes_with_nul ( s. as_bytes ( ) ) . expect ( "null-terminated string" )
225
- }
226
-
227
223
pub fn provide ( providers : & mut Providers ) {
228
224
providers. target_features_whitelist = |tcx, cnum| {
229
225
assert_eq ! ( cnum, LOCAL_CRATE ) ;
0 commit comments