From 308e82ecebeef1342004637db9fdf11567a299b3 Mon Sep 17 00:00:00 2001 From: Michael Platings Date: Fri, 8 Mar 2019 10:44:06 +0000 Subject: [IR][ARM] Add function pointer alignment to datalayout Use this feature to fix a bug on ARM where 4 byte alignment is incorrectly assumed. Differential Revision: https://reviews.llvm.org/D57335 llvm-svn: 355685 --- llvm/lib/Target/ARM/ARMTargetMachine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Target/ARM/ARMTargetMachine.cpp') diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 9954eee2e5f..401843c1e0f 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -141,6 +141,10 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU, // Pointers are 32 bits and aligned to 32 bits. Ret += "-p:32:32"; + // Function pointers are aligned to 8 bits (because the LSB stores the + // ARM/Thumb state). + Ret += "-Fi8"; + // ABIs other than APCS have 64 bit integers with natural alignment. if (ABI != ARMBaseTargetMachine::ARM_ABI_APCS) Ret += "-i64:64"; -- cgit v1.2.3