@@ -363,50 +363,44 @@ pub fn from_fn_attrs<'ll, 'tcx>(
363363 if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: ALLOCATOR )
364364 || codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: ALLOCATOR_ZEROED )
365365 {
366- if llvm_util:: get_version ( ) >= ( 15 , 0 , 0 ) {
367- to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
368- // apply to argument place instead of function
369- let alloc_align = AttributeKind :: AllocAlign . create_attr ( cx. llcx ) ;
370- attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 1 ) , & [ alloc_align] ) ;
371- to_add. push ( llvm:: CreateAllocSizeAttr ( cx. llcx , 0 ) ) ;
372- let mut flags = AllocKindFlags :: Alloc | AllocKindFlags :: Aligned ;
373- if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: ALLOCATOR ) {
374- flags |= AllocKindFlags :: Uninitialized ;
375- } else {
376- flags |= AllocKindFlags :: Zeroed ;
377- }
378- to_add. push ( llvm:: CreateAllocKindAttr ( cx. llcx , flags) ) ;
366+ to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
367+ // apply to argument place instead of function
368+ let alloc_align = AttributeKind :: AllocAlign . create_attr ( cx. llcx ) ;
369+ attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 1 ) , & [ alloc_align] ) ;
370+ to_add. push ( llvm:: CreateAllocSizeAttr ( cx. llcx , 0 ) ) ;
371+ let mut flags = AllocKindFlags :: Alloc | AllocKindFlags :: Aligned ;
372+ if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: ALLOCATOR ) {
373+ flags |= AllocKindFlags :: Uninitialized ;
374+ } else {
375+ flags |= AllocKindFlags :: Zeroed ;
379376 }
377+ to_add. push ( llvm:: CreateAllocKindAttr ( cx. llcx , flags) ) ;
380378 // apply to return place instead of function (unlike all other attributes applied in this function)
381379 let no_alias = AttributeKind :: NoAlias . create_attr ( cx. llcx ) ;
382380 attributes:: apply_to_llfn ( llfn, AttributePlace :: ReturnValue , & [ no_alias] ) ;
383381 }
384382 if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: REALLOCATOR ) {
385- if llvm_util:: get_version ( ) >= ( 15 , 0 , 0 ) {
386- to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
387- to_add. push ( llvm:: CreateAllocKindAttr (
388- cx. llcx ,
389- AllocKindFlags :: Realloc | AllocKindFlags :: Aligned ,
390- ) ) ;
391- // applies to argument place instead of function place
392- let allocated_pointer = AttributeKind :: AllocatedPointer . create_attr ( cx. llcx ) ;
393- attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 0 ) , & [ allocated_pointer] ) ;
394- // apply to argument place instead of function
395- let alloc_align = AttributeKind :: AllocAlign . create_attr ( cx. llcx ) ;
396- attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 2 ) , & [ alloc_align] ) ;
397- to_add. push ( llvm:: CreateAllocSizeAttr ( cx. llcx , 3 ) ) ;
398- }
383+ to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
384+ to_add. push ( llvm:: CreateAllocKindAttr (
385+ cx. llcx ,
386+ AllocKindFlags :: Realloc | AllocKindFlags :: Aligned ,
387+ ) ) ;
388+ // applies to argument place instead of function place
389+ let allocated_pointer = AttributeKind :: AllocatedPointer . create_attr ( cx. llcx ) ;
390+ attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 0 ) , & [ allocated_pointer] ) ;
391+ // apply to argument place instead of function
392+ let alloc_align = AttributeKind :: AllocAlign . create_attr ( cx. llcx ) ;
393+ attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 2 ) , & [ alloc_align] ) ;
394+ to_add. push ( llvm:: CreateAllocSizeAttr ( cx. llcx , 3 ) ) ;
399395 let no_alias = AttributeKind :: NoAlias . create_attr ( cx. llcx ) ;
400396 attributes:: apply_to_llfn ( llfn, AttributePlace :: ReturnValue , & [ no_alias] ) ;
401397 }
402398 if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: DEALLOCATOR ) {
403- if llvm_util:: get_version ( ) >= ( 15 , 0 , 0 ) {
404- to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
405- to_add. push ( llvm:: CreateAllocKindAttr ( cx. llcx , AllocKindFlags :: Free ) ) ;
406- // applies to argument place instead of function place
407- let allocated_pointer = AttributeKind :: AllocatedPointer . create_attr ( cx. llcx ) ;
408- attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 0 ) , & [ allocated_pointer] ) ;
409- }
399+ to_add. push ( create_alloc_family_attr ( cx. llcx ) ) ;
400+ to_add. push ( llvm:: CreateAllocKindAttr ( cx. llcx , AllocKindFlags :: Free ) ) ;
401+ // applies to argument place instead of function place
402+ let allocated_pointer = AttributeKind :: AllocatedPointer . create_attr ( cx. llcx ) ;
403+ attributes:: apply_to_llfn ( llfn, AttributePlace :: Argument ( 0 ) , & [ allocated_pointer] ) ;
410404 }
411405 if codegen_fn_attrs. flags . contains ( CodegenFnAttrFlags :: CMSE_NONSECURE_ENTRY ) {
412406 to_add. push ( llvm:: CreateAttrString ( cx. llcx , "cmse_nonsecure_entry" ) ) ;
0 commit comments