[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

Tim Northover via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 03:37:22 PST 2020


t.p.northover created this revision.
Herald added subscribers: dexonsmith, danielkiss, s.egerton, simoncook, hiraditya, kristof.beyls, mcrosier.
Herald added a project: LLVM.
t.p.northover requested review of this revision.

We want `arm64_32` to omit leaf frame pointers. At the moment this is predicated on `isAArch64` and fails because `Triple::aarch64_32` doesn't count. That's logically incorrect, and fortunately that function is used infrequently enough that we can update its callers where appropriate, as here.


https://reviews.llvm.org/D91147

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/frame-pointer-elim.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/BinaryFormat/MachO.cpp


Index: llvm/lib/BinaryFormat/MachO.cpp
===================================================================
--- llvm/lib/BinaryFormat/MachO.cpp
+++ llvm/lib/BinaryFormat/MachO.cpp
@@ -55,7 +55,7 @@
 }
 
 static MachO::CPUSubTypeARM64 getARM64SubType(const Triple &T) {
-  assert(T.isAArch64() || T.getArch() == Triple::aarch64_32);
+  assert(T.isAArch64());
   if (T.isArch32Bit())
     return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
   if (T.getArchName() == "arm64e")
@@ -84,9 +84,7 @@
   if (T.isARM() || T.isThumb())
     return MachO::CPU_TYPE_ARM;
   if (T.isAArch64())
-    return MachO::CPU_TYPE_ARM64;
-  if (T.getArch() == Triple::aarch64_32)
-    return MachO::CPU_TYPE_ARM64_32;
+    return T.isArch32Bit() ? MachO::CPU_TYPE_ARM64_32 : MachO::CPU_TYPE_ARM64;
   if (T.getArch() == Triple::ppc)
     return MachO::CPU_TYPE_POWERPC;
   if (T.getArch() == Triple::ppc64)
Index: llvm/include/llvm/ADT/Triple.h
===================================================================
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -714,7 +714,8 @@
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {
-    return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
+    return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+           getArch() == Triple::aarch64_32;
   }
 
   /// Tests whether the target is MIPS 32-bit (little and big endian).
Index: clang/test/Driver/frame-pointer-elim.c
===================================================================
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -97,6 +97,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1063,9 +1063,10 @@
       getTriple().isAArch64())
     Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-      getTriple().isAArch64() || getTriple().isRISCV())
+      (getTriple().isAArch64() && getTriple().isArch64Bit()) ||
+      getTriple().isRISCV())
     Res |= SanitizerKind::ShadowCallStack;
-  if (getTriple().isAArch64())
+  if (getTriple().isAArch64() && getTriple().isArch64Bit())
     Res |= SanitizerKind::MemTag;
   return Res;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91147.304125.patch
Type: text/x-patch
Size: 2760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201110/61b74cd4/attachment-0001.bin>


More information about the cfe-commits mailing list