1
1
//! Set and unset common attributes on LLVM values.
2
2
3
- pub use rustc_attr:: { InlineAttr , InstructionSetAttr , OptimizeAttr } ;
3
+ use rustc_attr:: { InlineAttr , InstructionSetAttr , OptimizeAttr } ;
4
4
use rustc_codegen_ssa:: traits:: * ;
5
5
use rustc_hir:: def_id:: DefId ;
6
6
use rustc_middle:: middle:: codegen_fn_attrs:: { CodegenFnAttrFlags , PatchableFunctionEntry } ;
@@ -17,13 +17,13 @@ use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace
17
17
use crate :: value:: Value ;
18
18
use crate :: { attributes, llvm_util} ;
19
19
20
- pub fn apply_to_llfn ( llfn : & Value , idx : AttributePlace , attrs : & [ & Attribute ] ) {
20
+ pub ( crate ) fn apply_to_llfn ( llfn : & Value , idx : AttributePlace , attrs : & [ & Attribute ] ) {
21
21
if !attrs. is_empty ( ) {
22
22
llvm:: AddFunctionAttributes ( llfn, idx, attrs) ;
23
23
}
24
24
}
25
25
26
- pub fn apply_to_callsite ( callsite : & Value , idx : AttributePlace , attrs : & [ & Attribute ] ) {
26
+ pub ( crate ) fn apply_to_callsite ( callsite : & Value , idx : AttributePlace , attrs : & [ & Attribute ] ) {
27
27
if !attrs. is_empty ( ) {
28
28
llvm:: AddCallSiteAttributes ( callsite, idx, attrs) ;
29
29
}
@@ -80,7 +80,7 @@ fn patchable_function_entry_attrs<'ll>(
80
80
81
81
/// Get LLVM sanitize attributes.
82
82
#[ inline]
83
- pub fn sanitize_attrs < ' ll > (
83
+ pub ( crate ) fn sanitize_attrs < ' ll > (
84
84
cx : & CodegenCx < ' ll , ' _ > ,
85
85
no_sanitize : SanitizerSet ,
86
86
) -> SmallVec < [ & ' ll Attribute ; 4 ] > {
@@ -120,15 +120,15 @@ pub fn sanitize_attrs<'ll>(
120
120
121
121
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
122
122
#[ inline]
123
- pub fn uwtable_attr ( llcx : & llvm:: Context , use_sync_unwind : Option < bool > ) -> & Attribute {
123
+ pub ( crate ) fn uwtable_attr ( llcx : & llvm:: Context , use_sync_unwind : Option < bool > ) -> & Attribute {
124
124
// NOTE: We should determine if we even need async unwind tables, as they
125
125
// take have more overhead and if we can use sync unwind tables we
126
126
// probably should.
127
127
let async_unwind = !use_sync_unwind. unwrap_or ( false ) ;
128
128
llvm:: CreateUWTableAttr ( llcx, async_unwind)
129
129
}
130
130
131
- pub fn frame_pointer_type_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
131
+ pub ( crate ) fn frame_pointer_type_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
132
132
let mut fp = cx. sess ( ) . target . frame_pointer ;
133
133
let opts = & cx. sess ( ) . opts ;
134
134
// "mcount" function relies on stack pointer.
@@ -280,19 +280,19 @@ fn backchain_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
280
280
if found_positive { Some ( llvm:: CreateAttrString ( cx. llcx , "backchain" ) ) } else { None }
281
281
}
282
282
283
- pub fn target_cpu_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Attribute {
283
+ pub ( crate ) fn target_cpu_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Attribute {
284
284
let target_cpu = llvm_util:: target_cpu ( cx. tcx . sess ) ;
285
285
llvm:: CreateAttrStringValue ( cx. llcx , "target-cpu" , target_cpu)
286
286
}
287
287
288
- pub fn tune_cpu_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
288
+ pub ( crate ) fn tune_cpu_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
289
289
llvm_util:: tune_cpu ( cx. tcx . sess )
290
290
. map ( |tune_cpu| llvm:: CreateAttrStringValue ( cx. llcx , "tune-cpu" , tune_cpu) )
291
291
}
292
292
293
293
/// Get the `NonLazyBind` LLVM attribute,
294
294
/// if the codegen options allow skipping the PLT.
295
- pub fn non_lazy_bind_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
295
+ pub ( crate ) fn non_lazy_bind_attr < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> Option < & ' ll Attribute > {
296
296
// Don't generate calls through PLT if it's not necessary
297
297
if !cx. sess ( ) . needs_plt ( ) {
298
298
Some ( AttributeKind :: NonLazyBind . create_attr ( cx. llcx ) )
@@ -327,7 +327,7 @@ fn create_alloc_family_attr(llcx: &llvm::Context) -> &llvm::Attribute {
327
327
/// Helper for `FnAbi::apply_attrs_llfn`:
328
328
/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
329
329
/// attributes.
330
- pub fn llfn_attrs_from_instance < ' ll , ' tcx > (
330
+ pub ( crate ) fn llfn_attrs_from_instance < ' ll , ' tcx > (
331
331
cx : & CodegenCx < ' ll , ' tcx > ,
332
332
llfn : & ' ll Value ,
333
333
instance : ty:: Instance < ' tcx > ,
0 commit comments