Add a command line option "-arm-strict-align" to disallow unaligned memory
accesses for ARM targets that would otherwise allow it. Radar 8465431. llvm-svn: 114941
This commit is contained in:
parent
4102dd5eb5
commit
3dc97324c1
|
@ -4807,15 +4807,7 @@ SDValue ARMTargetLowering::PerformDAGCombine(SDNode *N,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ARMTargetLowering::allowsUnalignedMemoryAccesses(EVT VT) const {
|
bool ARMTargetLowering::allowsUnalignedMemoryAccesses(EVT VT) const {
|
||||||
if (!Subtarget->hasV6Ops())
|
if (!Subtarget->allowsUnalignedMem())
|
||||||
// Pre-v6 does not support unaligned mem access.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// v6+ may or may not support unaligned mem access depending on the system
|
|
||||||
// configuration.
|
|
||||||
// FIXME: This is pretty conservative. Should we provide cmdline option to
|
|
||||||
// control the behaviour?
|
|
||||||
if (!Subtarget->isTargetDarwin())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (VT.getSimpleVT().SimpleTy) {
|
switch (VT.getSimpleVT().SimpleTy) {
|
||||||
|
|
|
@ -27,6 +27,10 @@ static cl::opt<bool>
|
||||||
UseMOVT("arm-use-movt",
|
UseMOVT("arm-use-movt",
|
||||||
cl::init(true), cl::Hidden);
|
cl::init(true), cl::Hidden);
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
StrictAlign("arm-strict-align", cl::Hidden,
|
||||||
|
cl::desc("Disallow all unaligned memory accesses"));
|
||||||
|
|
||||||
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
||||||
bool isT)
|
bool isT)
|
||||||
: ARMArchVersion(V4)
|
: ARMArchVersion(V4)
|
||||||
|
@ -47,6 +51,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
||||||
, HasDataBarrier(false)
|
, HasDataBarrier(false)
|
||||||
, Pref32BitThumb(false)
|
, Pref32BitThumb(false)
|
||||||
, FPOnlySP(false)
|
, FPOnlySP(false)
|
||||||
|
, AllowsUnalignedMem(false)
|
||||||
, stackAlignment(4)
|
, stackAlignment(4)
|
||||||
, CPUString("generic")
|
, CPUString("generic")
|
||||||
, TargetType(isELF) // Default to ELF unless otherwise specified.
|
, TargetType(isELF) // Default to ELF unless otherwise specified.
|
||||||
|
@ -122,6 +127,11 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS,
|
||||||
|
|
||||||
if (!isThumb() || hasThumb2())
|
if (!isThumb() || hasThumb2())
|
||||||
PostRAScheduler = true;
|
PostRAScheduler = true;
|
||||||
|
|
||||||
|
// v6+ may or may not support unaligned mem access depending on the system
|
||||||
|
// configuration.
|
||||||
|
if (!StrictAlign && hasV6Ops() && isTargetDarwin())
|
||||||
|
AllowsUnalignedMem = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol.
|
||||||
|
|
|
@ -106,6 +106,11 @@ protected:
|
||||||
/// precision.
|
/// precision.
|
||||||
bool FPOnlySP;
|
bool FPOnlySP;
|
||||||
|
|
||||||
|
/// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
|
||||||
|
/// accesses for some types. For details, see
|
||||||
|
/// ARMTargetLowering::allowsUnalignedMemoryAccesses().
|
||||||
|
bool AllowsUnalignedMem;
|
||||||
|
|
||||||
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
||||||
/// entry to the function and which must be maintained by every function.
|
/// entry to the function and which must be maintained by every function.
|
||||||
unsigned stackAlignment;
|
unsigned stackAlignment;
|
||||||
|
@ -185,6 +190,8 @@ protected:
|
||||||
|
|
||||||
bool useMovt() const { return UseMovt && hasV6T2Ops(); }
|
bool useMovt() const { return UseMovt && hasV6T2Ops(); }
|
||||||
|
|
||||||
|
bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
|
||||||
|
|
||||||
const std::string & getCPUString() const { return CPUString; }
|
const std::string & getCPUString() const { return CPUString; }
|
||||||
|
|
||||||
/// enablePostRAScheduler - True at 'More' optimization.
|
/// enablePostRAScheduler - True at 'More' optimization.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
; RUN: llc < %s -march=arm | FileCheck %s -check-prefix=GENERIC
|
; RUN: llc < %s -march=arm | FileCheck %s -check-prefix=GENERIC
|
||||||
; RUN: llc < %s -mtriple=armv6-apple-darwin | FileCheck %s -check-prefix=DARWIN_V6
|
; RUN: llc < %s -mtriple=armv6-apple-darwin | FileCheck %s -check-prefix=DARWIN_V6
|
||||||
|
; RUN: llc < %s -mtriple=armv6-apple-darwin -arm-strict-align | FileCheck %s -check-prefix=GENERIC
|
||||||
; RUN: llc < %s -mtriple=armv6-linux | FileCheck %s -check-prefix=GENERIC
|
; RUN: llc < %s -mtriple=armv6-linux | FileCheck %s -check-prefix=GENERIC
|
||||||
|
|
||||||
; rdar://7113725
|
; rdar://7113725
|
||||||
|
|
Loading…
Reference in New Issue