Skip to content

Commit

Permalink
always add align attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdesjardins committed Feb 19, 2022
1 parent dcbdc8c commit 6e740ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ impl ArgAttributesExt for ArgAttributes {
llattr.apply_llfn(idx, llfn);
}
}
if let Some(align) = self.pointee_align {
llvm::LLVMRustAddAlignmentAttr(llfn, idx.as_uint(), align.bytes() as u32);
}
match self.arg_ext {
ArgExtension::None => {}
ArgExtension::Zext => llvm::Attribute::ZExt.apply_llfn(idx, llfn),
Expand All @@ -77,9 +80,6 @@ impl ArgAttributesExt for ArgAttributes {
}
regular -= ArgAttribute::NonNull;
}
if let Some(align) = self.pointee_align {
llvm::LLVMRustAddAlignmentAttr(llfn, idx.as_uint(), align.bytes() as u32);
}
for (attr, llattr) in OPTIMIZATION_ATTRIBUTES {
if regular.contains(attr) {
llattr.apply_llfn(idx, llfn);
Expand All @@ -105,6 +105,13 @@ impl ArgAttributesExt for ArgAttributes {
llattr.apply_callsite(idx, callsite);
}
}
if let Some(align) = self.pointee_align {
llvm::LLVMRustAddAlignmentCallSiteAttr(
callsite,
idx.as_uint(),
align.bytes() as u32,
);
}
match self.arg_ext {
ArgExtension::None => {}
ArgExtension::Zext => llvm::Attribute::ZExt.apply_callsite(idx, callsite),
Expand All @@ -127,13 +134,6 @@ impl ArgAttributesExt for ArgAttributes {
}
regular -= ArgAttribute::NonNull;
}
if let Some(align) = self.pointee_align {
llvm::LLVMRustAddAlignmentCallSiteAttr(
callsite,
idx.as_uint(),
align.bytes() as u32,
);
}
for (attr, llattr) in OPTIMIZATION_ATTRIBUTES {
if regular.contains(attr) {
llattr.apply_callsite(idx, callsite);
Expand Down
4 changes: 2 additions & 2 deletions src/test/codegen/function-arguments-noopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool {
f(x)
}

// CHECK: define i32* @borrow(i32* %x)
// CHECK: define align 4 i32* @borrow(i32* align 4 %x)
#[no_mangle]
pub fn borrow(x: &i32) -> &i32 {
x
Expand All @@ -32,7 +32,7 @@ pub fn borrow(x: &i32) -> &i32 {
// CHECK-LABEL: @borrow_call
#[no_mangle]
pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 {
// CHECK: call i32* %f(i32* %x)
// CHECK: call align 4 i32* %f(i32* align 4 %x)
f(x)
}

Expand Down

0 comments on commit 6e740ae

Please sign in to comment.