[PATCH] D155808: [clang][driver] Missing the condition in ISARMBigEndain function.

Simi Pallipurath via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 20 03:04:00 PDT 2023


simpal01 created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
simpal01 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

IsARMBIgEndian function returns true only if:

1. The triples are either arm or thumb and the commandline has the  option -mbig-endian
2. The triples are either armeb or thumbeb.

Missing the checking of arm or thumb triples in the
first case pass through the --be8 endian flag to
linker For AArch64 as well which is not expected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155808

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -37,9 +37,12 @@
 // '-mbig-endian'/'-EB'. Unlike other targets the flag does not result in a
 // normalized triple so we must handle the flag here.
 bool arm::isARMBigEndian(const llvm::Triple &Triple, const ArgList &Args) {
-  if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
-                               options::OPT_mbig_endian)) {
-    return !A->getOption().matches(options::OPT_mlittle_endian);
+  if ((Triple.getArch() == llvm::Triple::arm ||
+       Triple.getArch() == llvm::Triple::thumb)) {
+    if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
+                                 options::OPT_mbig_endian)) {
+      return !A->getOption().matches(options::OPT_mlittle_endian);
+    }
   }
 
   return Triple.getArch() == llvm::Triple::armeb ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155808.542403.patch
Type: text/x-patch
Size: 984 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230720/ae000207/attachment.bin>


More information about the cfe-commits mailing list