[PATCH] Emit diagnostic for -munaligned-access on v6m targets

Benjamin Foster benjamin.foster at arm.com
Tue Jul 29 01:44:53 PDT 2014


As suggested by James, we catch this case in clang rather than silently disabling unaligned accesses in the backend.

http://reviews.llvm.org/D4693

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  lib/Driver/Tools.cpp

Index: include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- include/clang/Basic/DiagnosticCommonKinds.td
+++ include/clang/Basic/DiagnosticCommonKinds.td
@@ -123,6 +123,8 @@
 def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">;
 def err_target_unsupported_fpmath : Error<
     "the '%0' unit is not supported with this instruction set">;
+def err_target_unsupported_unaligned : Error<
+  "the %0 sub-architecture does not support unaligned accesses">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -806,8 +806,12 @@
       CmdArgs.push_back("-backend-option");
       if (A->getOption().matches(options::OPT_mno_unaligned_access))
         CmdArgs.push_back("-arm-strict-align");
-      else
+      else {
+        if (getToolChain().getTriple().getSubArch() ==
+            llvm::Triple::SubArchType::ARMSubArch_v6m)
+          D.Diag(diag::err_target_unsupported_unaligned) << "v6m";
         CmdArgs.push_back("-arm-no-strict-align");
+      }
     }
   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4693.11970.patch
Type: text/x-patch
Size: 1237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140729/41bc0143/attachment.bin>


More information about the cfe-commits mailing list