Align functions according to their ISA's requirements (#4826)
Add a function_alignment function to the TargetIsa trait, and use it to align functions when generating objects. Additionally, collect the maximum alignment required for pc-relative constants in functions and pass that value out. Use the max of these two values when padding functions for alignment. This fixes a bug on x86_64 where rip-relative loads to sse registers could cause a segfault, as functions weren't always guaranteed to be aligned to 16-byte addresses. Fixes #4812
This commit is contained in:
@@ -95,6 +95,7 @@ impl TargetIsa for AArch64Backend {
|
||||
dynamic_stackslot_offsets,
|
||||
bb_starts: emit_result.bb_offsets,
|
||||
bb_edges: emit_result.bb_edges,
|
||||
alignment: emit_result.alignment,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -179,6 +180,12 @@ impl TargetIsa for AArch64Backend {
|
||||
fn map_regalloc_reg_to_dwarf(&self, reg: Reg) -> Result<u16, systemv::RegisterMappingError> {
|
||||
inst::unwind::systemv::map_reg(reg).map(|reg| reg.0)
|
||||
}
|
||||
|
||||
fn function_alignment(&self) -> u32 {
|
||||
// We use 32-byte alignment for performance reasons, but for correctness we would only need
|
||||
// 4-byte alignment.
|
||||
32
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for AArch64Backend {
|
||||
|
||||
Reference in New Issue
Block a user