Skip to content

Commit 76244be

Browse files
committed
Emit diagnostic for -munaligned-access on v6m targets
Rather than silently disabling unaligned accesses for v6m targets as in the previous patch to llvm, instead produce a warning saying that this architecture doesn't support unaligned accesses. Patch by Ben Foster llvm-svn: 215531
1 parent 8edd497 commit 76244be

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
123123
def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
124124
def err_target_unsupported_fpmath : Error<
125125
"the '%0' unit is not supported with this instruction set">;
126+
def err_target_unsupported_unaligned : Error<
127+
"the %0 sub-architecture does not support unaligned accesses">;
126128

127129
// Source manager
128130
def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;

clang/lib/Driver/Tools.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,12 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
806806
CmdArgs.push_back("-backend-option");
807807
if (A->getOption().matches(options::OPT_mno_unaligned_access))
808808
CmdArgs.push_back("-arm-strict-align");
809-
else
809+
else {
810+
if (getToolChain().getTriple().getSubArch() ==
811+
llvm::Triple::SubArchType::ARMSubArch_v6m)
812+
D.Diag(diag::err_target_unsupported_unaligned) << "v6m";
810813
CmdArgs.push_back("-arm-no-strict-align");
814+
}
811815
}
812816
}
813817

0 commit comments

Comments
 (0)