Skip to content

Commit a146a48

Browse files
committed
Add gcc ARM flags -munaligned-access / -mno-unaligned-access
clang already had a mstrict-align which mentiones "Force all memory accesses to be aligned (ARM only)". On gcc arm this is controlled by -munaligned-access / -mno-unaligned-access. Add the gcc versions to the frontend and make -mstrict-align and alias to -mno-unaligned-access and only show it in clang -cc1 -help. Since the default value for unaligned accesses / strict alignment depends on the tripple, both the enable and disable flags are added. If both are set, the no-unaligned-access is used. Patch by Jeroen Hofstee. llvm-svn: 189175
1 parent dbb77e6 commit a146a48

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,6 @@ def mstackrealign : Flag<["-"], "mstackrealign">, Group<m_Group>, Flags<[CC1Opti
942942
HelpText<"Force realign the stack at entry to every function">;
943943
def mstack_alignment : Joined<["-"], "mstack-alignment=">, Group<m_Group>, Flags<[CC1Option]>,
944944
HelpText<"Set the stack alignment">;
945-
def mstrict_align : Flag<["-"], "mstrict-align">, Group<m_Group>, Flags<[CC1Option]>,
946-
HelpText<"Force all memory accesses to be aligned (ARM only)">;
947945
def mmmx : Flag<["-"], "mmmx">, Group<m_x86_Features_Group>;
948946
def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group<m_x86_Features_Group>;
949947
def mno_3dnow : Flag<["-"], "mno-3dnow">, Group<m_x86_Features_Group>;
@@ -987,6 +985,12 @@ def mno_rtm : Flag<["-"], "mno-rtm">, Group<m_x86_Features_Group>;
987985
def mno_prfchw : Flag<["-"], "mno-prfchw">, Group<m_x86_Features_Group>;
988986
def mno_rdseed : Flag<["-"], "mno-rdseed">, Group<m_x86_Features_Group>;
989987

988+
def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
989+
HelpText<"Allow memory accesses to be unaligned (ARM only)">;
990+
def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group<m_arm_Features_Group>,
991+
HelpText<"Force all memory accesses to be aligned (ARM only)">;
992+
def mstrict_align : Flag<["-"], "mstrict-align">, Alias<mno_unaligned_access>, Flags<[CC1Option,HelpHidden]>,
993+
HelpText<"Force all memory accesses to be aligned (ARM only, same as mno-unaligned-access)">;
990994
def mno_thumb : Flag<["-"], "mno-thumb">, Group<m_arm_Features_Group>;
991995
def marm : Flag<["-"], "marm">, Alias<mno_thumb>;
992996
def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group<m_arm_Features_Group>,

clang/lib/Driver/Tools.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,9 +2941,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
29412941
CmdArgs.push_back(Args.MakeArgString("-mstack-alignment=" + alignment));
29422942
}
29432943
// -mkernel implies -mstrict-align; don't add the redundant option.
2944-
if (Args.hasArg(options::OPT_mstrict_align) && !KernelOrKext) {
2945-
CmdArgs.push_back("-backend-option");
2946-
CmdArgs.push_back("-arm-strict-align");
2944+
if (!KernelOrKext) {
2945+
if (Args.hasArg(options::OPT_mno_unaligned_access)) {
2946+
CmdArgs.push_back("-backend-option");
2947+
CmdArgs.push_back("-arm-strict-align");
2948+
} else if (Args.hasArg(options::OPT_munaligned_access)) {
2949+
CmdArgs.push_back("-backend-option");
2950+
CmdArgs.push_back("-arm-no-strict-align");
2951+
}
29472952
}
29482953

29492954
// Forward -f options with positive and negative forms; we translate

0 commit comments

Comments
 (0)