llvm.org GIT mirror llvm / 02aba73
Add a command line option "-arm-strict-align" to disallow unaligned memory accesses for ARM targets that would otherwise allow it. Radar 8465431. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114941 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 9 years ago
4 changed file(s) with 19 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
48064806 }
48074807
48084808 bool ARMTargetLowering::allowsUnalignedMemoryAccesses(EVT VT) const {
4809 if (!Subtarget->hasV6Ops())
4810 // Pre-v6 does not support unaligned mem access.
4811 return false;
4812
4813 // v6+ may or may not support unaligned mem access depending on the system
4814 // configuration.
4815 // FIXME: This is pretty conservative. Should we provide cmdline option to
4816 // control the behaviour?
4817 if (!Subtarget->isTargetDarwin())
4809 if (!Subtarget->allowsUnalignedMem())
48184810 return false;
48194811
48204812 switch (VT.getSimpleVT().SimpleTy) {
2626 UseMOVT("arm-use-movt",
2727 cl::init(true), cl::Hidden);
2828
29 static cl::opt
30 StrictAlign("arm-strict-align", cl::Hidden,
31 cl::desc("Disallow all unaligned memory accesses"));
32
2933 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
3034 bool isT)
3135 : ARMArchVersion(V4)
4650 , HasDataBarrier(false)
4751 , Pref32BitThumb(false)
4852 , FPOnlySP(false)
53 , AllowsUnalignedMem(false)
4954 , stackAlignment(4)
5055 , CPUString("generic")
5156 , TargetType(isELF) // Default to ELF unless otherwise specified.
121126
122127 if (!isThumb() || hasThumb2())
123128 PostRAScheduler = true;
129
130 // v6+ may or may not support unaligned mem access depending on the system
131 // configuration.
132 if (!StrictAlign && hasV6Ops() && isTargetDarwin())
133 AllowsUnalignedMem = true;
124134 }
125135
126136 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
104104 /// FPOnlySP - If true, the floating point unit only supports single
105105 /// precision.
106106 bool FPOnlySP;
107
108 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
109 /// accesses for some types. For details, see
110 /// ARMTargetLowering::allowsUnalignedMemoryAccesses().
111 bool AllowsUnalignedMem;
107112
108113 /// stackAlignment - The minimum alignment known to hold of the stack frame on
109114 /// entry to the function and which must be maintained by every function.
183188 bool isR9Reserved() const { return IsR9Reserved; }
184189
185190 bool useMovt() const { return UseMovt && hasV6T2Ops(); }
191
192 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
186193
187194 const std::string & getCPUString() const { return CPUString; }
188195
0 ; RUN: llc < %s -march=arm | FileCheck %s -check-prefix=GENERIC
11 ; RUN: llc < %s -mtriple=armv6-apple-darwin | FileCheck %s -check-prefix=DARWIN_V6
2 ; RUN: llc < %s -mtriple=armv6-apple-darwin -arm-strict-align | FileCheck %s -check-prefix=GENERIC
23 ; RUN: llc < %s -mtriple=armv6-linux | FileCheck %s -check-prefix=GENERIC
34
45 ; rdar://7113725