]> granicus.if.org Git - clang/commitdiff
use the last passed -munaligned-access / -mno-unaligned-access
authorRenato Golin <renato.golin@linaro.org>
Wed, 28 Aug 2013 23:56:07 +0000 (23:56 +0000)
committerRenato Golin <renato.golin@linaro.org>
Wed, 28 Aug 2013 23:56:07 +0000 (23:56 +0000)
Passing inconsistent munaligned-access / mno-unaligned-access
flags, intentionally resulted in a warning and the flag
no-unaligned-access being used.

Gcc does, at least in practice, use the last flag in such a
case. This patch updates clang behaviour accordingly; use the
last flag or base alignment behaviour on the target (which
llvm will do if no flag is explicitly passed)

Patch by Jeroen Hofstee.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189542 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/arm-alignment.c

index 6862e76df6e8ff467be5d40b1a8e0388ce7953ff..9633d6b3e25c4889201256bcf18483ecb622e737 100644 (file)
@@ -2944,12 +2944,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   }
   // -mkernel implies -mstrict-align; don't add the redundant option.
   if (!KernelOrKext) {
-    if (Args.hasArg(options::OPT_mno_unaligned_access)) {
-      CmdArgs.push_back("-backend-option");
-      CmdArgs.push_back("-arm-strict-align");
-    } else if (Args.hasArg(options::OPT_munaligned_access)) {
-      CmdArgs.push_back("-backend-option");
-      CmdArgs.push_back("-arm-no-strict-align");
+    if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
+                                 options::OPT_munaligned_access)) {
+      if (A->getOption().matches(options::OPT_mno_unaligned_access)) {
+        CmdArgs.push_back("-backend-option");
+        CmdArgs.push_back("-arm-strict-align");
+      } else {
+        CmdArgs.push_back("-backend-option");
+        CmdArgs.push_back("-arm-no-strict-align");
+      }
     }
   }
 
index 024c46be7429c54aeebc869e8333aca562055c41..dad66ba58942347bff1daea2268d613fd60bf75e 100644 (file)
@@ -1,9 +1,25 @@
 // RUN: %clang -target arm-none-gnueeabi -munaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s
 
+// RUN: %clang -target arm-none-gnueeabi -mstrict-align -munaligned-access -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s
+
+// RUN: %clang -target arm-none-gnueeabi -mno-unaligned-access -munaligned-access -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s
+
 // CHECK-UNALIGNED: "-backend-option" "-arm-no-strict-align"
 
+
 // RUN: %clang -target arm-none-gnueeabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s
 
+// RUN: %clang -target arm-none-gnueeabi -mstrict-align -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s
+
+// RUN: %clang -target arm-none-gnueabi -munaligned-access -mno-unaligned-access -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s
+
+// RUN: %clang -target arm-none-gnueabi -munaligned-access -mstrict-align -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s
+
 // CHECK-ALIGNED: "-backend-option" "-arm-strict-align"