diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index a934a5c..88939e9 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -212,6 +212,14 @@ void MachineFunction::init() { Alignment = std::max(Alignment, STI->getTargetLowering()->getPrefFunctionAlignment()); + // -fsanitize=function and -fsanitize=kcfi instrument indirect function calls + // to load a type hash before the function label. Ensure functions are aligned + // by a least 4 to avoid unaligned access, which is especially important for + // -mno-unaligned-access. + if (F.hasMetadata(LLVMContext::MD_func_sanitize) || + F.getMetadata(LLVMContext::MD_kcfi_type)) + Alignment = std::max(Alignment, Align(4)); + if (AlignAllFunctions) Alignment = Align(1ULL << AlignAllFunctions); |