[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

Fanbo Meng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 07:26:23 PDT 2020


fanbo-meng created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
fanbo-meng requested review of this revision.

Aligned allocation is not supported on z/OS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87611

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp


Index: clang/test/Lexer/aligned-allocation.cpp
===================================================================
--- clang/test/Lexer/aligned-allocation.cpp
+++ clang/test/Lexer/aligned-allocation.cpp
@@ -6,10 +6,19 @@
 //
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++17 -verify %s \
 // RUN:   -faligned-allocation -faligned-alloc-unavailable
+//
+// RUN: %clang_cc1 -triple s390x-ibm-zos -fexceptions -std=c++17 -verify %s \
+// RUN:   -DEXPECT_DEFINED
+//
+// RUN: %clang_cc1 -triple s390x-ibm-zos -fexceptions -std=c++17 -verify %s \
+// RUN:   -faligned-alloc-unavailable
+//
+// RUN: %clang_cc1 -triple s390x-ibm-zos -fexceptions -std=c++17 -verify %s \
+// RUN:   -faligned-allocation -faligned-alloc-unavailable
 
 // Test that __cpp_aligned_new is not defined when CC1 is passed
-// -faligned-alloc-unavailable by the Darwin driver, even when aligned
-// allocation is actually enabled.
+// -faligned-alloc-unavailable by the Darwin and the z/OS driver, even when
+// aligned allocation is actually enabled.
 
 // expected-no-diagnostics
 #ifdef EXPECT_DEFINED
Index: clang/test/Driver/unavailable_aligned_allocation.cpp
===================================================================
--- clang/test/Driver/unavailable_aligned_allocation.cpp
+++ clang/test/Driver/unavailable_aligned_allocation.cpp
@@ -22,6 +22,9 @@
 // RUN: -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
+// RUN: %clang -target s390x-ibm-zos -c -### %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
+
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
 // RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
@@ -59,5 +62,11 @@
 //
 // RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
+//
+// RUN: %clang -target s390x-ibm-zos -faligned-allocation -c -### %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=AVAILABLE
+//
+// RUN: %clang -target s390x-ibm-zos -fno-aligned-allocation -c -### %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"
Index: clang/lib/Driver/ToolChains/ZOS.h
===================================================================
--- clang/lib/Driver/ToolChains/ZOS.h
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -27,6 +27,10 @@
   bool isPICDefaultForced() const override { return false; }
 
   bool IsIntegratedAssemblerDefault() const override { return true; }
+
+  void addClangTargetOptions(
+      const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
+      Action::OffloadKind DeviceOffloadingKind) const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===================================================================
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -21,3 +21,13 @@
     : ToolChain(D, Triple, Args) {}
 
 ZOS::~ZOS() {}
+
+void ZOS::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+                                llvm::opt::ArgStringList &CC1Args,
+                                Action::OffloadKind DeviceOffloadKind) const {
+  // Pass "-faligned-alloc-unavailable" only when the user hasn't manually
+  // enabled or disabled aligned allocations.
+  if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
+                                options::OPT_fno_aligned_allocation))
+    CC1Args.push_back("-faligned-alloc-unavailable");
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87611.291558.patch
Type: text/x-patch
Size: 3511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200914/1c3a5865/attachment.bin>


More information about the cfe-commits mailing list