@@ -14,7 +14,6 @@ use rustc_middle::bug;
1414use rustc_middle:: ty:: layout:: LayoutOf ;
1515pub use rustc_middle:: ty:: layout:: { FAT_PTR_ADDR , FAT_PTR_EXTRA } ;
1616use rustc_middle:: ty:: Ty ;
17- use rustc_session:: config;
1817use rustc_target:: abi:: call:: ArgAbi ;
1918pub use rustc_target:: abi:: call:: * ;
2019use rustc_target:: abi:: { self , HasDataLayout , Int } ;
@@ -71,26 +70,23 @@ fn get_attrs<'ll>(this: &ArgAttributes, cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'
7170 ArgExtension :: Sext => attrs. push ( llvm:: AttributeKind :: SExt . create_attr ( cx. llcx ) ) ,
7271 }
7372
74- // Only apply remaining attributes when optimizing
75- if cx. sess ( ) . opts . optimize != config:: OptLevel :: No {
76- let deref = this. pointee_size . bytes ( ) ;
77- if deref != 0 {
78- if regular. contains ( ArgAttribute :: NonNull ) {
79- attrs. push ( llvm:: CreateDereferenceableAttr ( cx. llcx , deref) ) ;
80- } else {
81- attrs. push ( llvm:: CreateDereferenceableOrNullAttr ( cx. llcx , deref) ) ;
82- }
83- regular -= ArgAttribute :: NonNull ;
84- }
85- for ( attr, llattr) in OPTIMIZATION_ATTRIBUTES {
86- if regular. contains ( attr) {
87- attrs. push ( llattr. create_attr ( cx. llcx ) ) ;
88- }
73+ let deref = this. pointee_size . bytes ( ) ;
74+ if deref != 0 {
75+ if regular. contains ( ArgAttribute :: NonNull ) {
76+ attrs. push ( llvm:: CreateDereferenceableAttr ( cx. llcx , deref) ) ;
77+ } else {
78+ attrs. push ( llvm:: CreateDereferenceableOrNullAttr ( cx. llcx , deref) ) ;
8979 }
90- if regular. contains ( ArgAttribute :: NoAliasMutRef ) && should_use_mutable_noalias ( cx) {
91- attrs. push ( llvm:: AttributeKind :: NoAlias . create_attr ( cx. llcx ) ) ;
80+ regular -= ArgAttribute :: NonNull ;
81+ }
82+ for ( attr, llattr) in OPTIMIZATION_ATTRIBUTES {
83+ if regular. contains ( attr) {
84+ attrs. push ( llattr. create_attr ( cx. llcx ) ) ;
9285 }
9386 }
87+ if regular. contains ( ArgAttribute :: NoAliasMutRef ) && should_use_mutable_noalias ( cx) {
88+ attrs. push ( llvm:: AttributeKind :: NoAlias . create_attr ( cx. llcx ) ) ;
89+ }
9490
9591 attrs
9692}
0 commit comments