[PATCH] D119147: [AIX][clang][driver] Check the command string to the linker for exportlist opts and

2022-05-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/test/Driver/aix-ld.c:675-676
+// CHECK-LD32-SHARED-EXPORTS-NOT: "{{.*}}llvm-nm"
+// CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
+// CHECK-LD32-SHARED-EXPORTS-NOT: "32"
+// CHECK-LD32-SHARED-EXPORTS: "{{.*}}ld{{(.exe)?}}"

DiggerLin wrote:
> stevewan wrote:
> > And please keep this consistent across the tests.
> using:
> // CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
> // CHECK-LD32-SHARED-EXPORTS-NOT: "32"
> 
> will be fail on the -X 64 too.
> 
> using  // CHECK-LD32-SHARED-EXPORTS-NOT: "-X" "32"
>  will be success on the -X 64. 
> So I am prefer use the
>  CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
>  CHECK-LD32-SHARED-EXPORTS-NOT: "32" 
> 
If this is meant to check also for `-X 64`. I suggest using proper regex 
instead of relying solely on the `-X` check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119147/new/

https://reviews.llvm.org/D119147

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119147: [AIX][clang][driver] Check the command string to the linker for exportlist opts and

2022-05-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.
This revision is now accepted and ready to land.

LGTM other than some nits.




Comment at: clang/lib/Driver/Job.cpp:361
+
+  if (!RedirectFiles.empty()) {
+std::vector> RedirectFilesOptional;





Comment at: clang/test/Driver/aix-ld.c:675-676
+// CHECK-LD32-SHARED-EXPORTS-NOT: "{{.*}}llvm-nm"
+// CHECK-LD32-SHARED-EXPORTS-NOT: "-X"
+// CHECK-LD32-SHARED-EXPORTS-NOT: "32"
+// CHECK-LD32-SHARED-EXPORTS: "{{.*}}ld{{(.exe)?}}"

And please keep this consistent across the tests.



Comment at: clang/test/Driver/aix-ld.c:776-777
+// CHECK-LD64-SHARED-EXPORTS-NOT: "{{.*}}llvm-nm"
+// CHECK-LD64-SHARED-EXPORTS-NOT: "-X"
+// CHECK-LD64-SHARED-EXPORTS-NOT: "64"
+// CHECK-LD64-SHARED-EXPORTS: "{{.*}}ld{{(.exe)?}}"

Ditto.



Comment at: clang/test/Driver/aix-ld.c:826-827
+// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "{{.*}}llvm-nm"
+// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "-X"
+// CHECK-LD64-SHARED-EXPORTS-ALT-NOT: "64"
+// CHECK-LD64-SHARED-EXPORTS-ALT: "{{.*}}ld{{(.exe)?}}"

Ditto.



Comment at: clang/test/Driver/aix-ld.c:903-904
+// CHECK-LD64-SHARED-EXPALL-NOT: "{{.*}}llvm-nm"
+// CHECK-LD64-SHARED-EXPALL-NOT: "-X"
+// CHECK-LD64-SHARED-EXPALL-NOT: "64"
+// CHECK-LD64-SHARED-EXPALL: "{{.*}}ld{{(.exe)?}}"

Ditto.



Comment at: clang/test/Driver/aix-ld.c:981-982
+// CHECK-LD64-SHARED-EXPFULL-NOT: "{{.*}}llvm-nm"
+// CHECK-LD64-SHARED-EXPFULL-NOT: "-X"
+// CHECK-LD64-SHARED-EXPFULL-NOT: "64"
+// CHECK-LD64-SHARED-EXPFULL: "{{.*}}ld{{(.exe)?}}"

Ditto.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119147/new/

https://reviews.llvm.org/D119147

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119147: [AIX][clang][driver] Check the command string to the linker for exportlist opts

2022-04-19 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

I don't think the redirect files portion of this patch is well-described in the 
description, could you please add it?




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:80
+static bool hasExportListLinkerOpts(const ArgStringList ) {
+  for (size_t i = 0, Size = CmdArgs.size(); i < Size; ++i) {
+llvm::StringRef ArgString(CmdArgs[i]);

Since `!=` is preferred, let's switch to that.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:88
+// If we split -b option, check the next opt.
+if (ArgString == "-b" && i + 1 < CmdArgs.size()) {
+  ++i;




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119147/new/

https://reviews.llvm.org/D119147

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG245b8e5691ed: [NFC][AIX]Disable failed tests due to 
aggressive byval alignment warning on AIX (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118670/new/

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=optin.performance.Padding \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=-10 \


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 

[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 404951.
stevewan added a comment.

Add the flag to all


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118670/new/

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=optin.performance.Padding \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=-10 \


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions 

[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 404947.
stevewan added a comment.

Use "-Wno-aix-compat" so that we don't lose coverage on AIX


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118670/new/

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 

[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-01-31 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These tests emit unexpected diagnostics on AIX because the byval alignment 
warning is emitted too aggressively. https://reviews.llvm.org/D118350 is 
supposed to provide a proper fix to the problem, but for the time being disable 
the tests to unblock.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics
+
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 template 
 struct A {
   char a __attribute__((aligned(16)));
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 namespace std {
   struct type_info {};
   __extension__ typedef __SIZE_TYPE__ size_t;
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
 
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -12,6 +12,9 @@
 // CHECK-PAD-NEGATIVE-VALUE-SAME: 'optin.performance.Padding:AllowedPad', that
 // CHECK-PAD-NEGATIVE-VALUE-SAME: expects a non-negative value
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 #if __has_include()
 #include 
 #endif


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics
+
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 template 
 struct A {
   char a __attribute__((aligned(16)));
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 namespace std {
   struct type_info {};
   __extension__ typedef __SIZE_TYPE__ size_t;
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
 
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -12,6 +12,9 @@
 // CHECK-PAD-NEGATIVE-VALUE-SAME: 'optin.performance.Padding:AllowedPad', that
 // CHECK-PAD-NEGATIVE-VALUE-SAME: expects a non-negative value
 
+// Byval alignment warning is emitted too aggressively on AIX.
+// XFAIL: aix
+
 #if __has_include()
 #include 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118477: [NFC][AIX]Disable new pcm tests on AIX

2022-01-28 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG760e69223d83: [NFC][AIX]Disable new pcm tests on AIX 
(authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118477/new/

https://reviews.llvm.org/D118477

Files:
  clang/test/ClangScanDeps/modules-symlink.c


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118477: [NFC][AIX]Disable new pcm tests on AIX

2022-01-28 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Same as D114481 , the PCH reader looks for a 
`__clangast` section in the precompiled module file, which isn't present on 
AIX, and we don't support writing this custom section in XCOFF yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118477

Files:
  clang/test/ClangScanDeps/modules-symlink.c


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [


Index: clang/test/ClangScanDeps/modules-symlink.c
===
--- clang/test/ClangScanDeps/modules-symlink.c
+++ clang/test/ClangScanDeps/modules-symlink.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
-// UNSUPPORTED: system-windows
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: system-windows, aix
 
 //--- cdb_pch.json
 [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118152: [clang][deps] Adapt test to be compatible when the assembler is called by default

2022-01-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/test/ClangScanDeps/headerwithdirname.cpp:16
 
-// CHECK: headerwithdirname_input.o
+// CHECK: headerwithdirname_input{{.*}}{{.o|.s}}
 // CHECK-NEXT: headerwithdirname_input.cpp

Jake-Egan wrote:
> jansvoboda11 wrote:
> > Why is `{{.*}}` necessary?
> It's to match the random characters between "input" and the file extension. 
> The output on AIX looks like this:
> `/tmp/headerwithdirname_input-ffd608.s: \`
To be clear, this isn't AIX specific behaviour. We get the temp assembly file 
when `-fno-integrated-as` is on. 

Maybe slightly more accurate is,
```
// CHECK: headerwithdirname_input{{\.o|.*\.s}}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118152/new/

https://reviews.llvm.org/D118152

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114454: [analyzer]Skip unstable CSA tests failing on several platforms

2021-12-02 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c4d194f44c4: [analyzer]Skip unstable CSA tests failing on 
several platforms (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114454/new/

https://reviews.llvm.org/D114454

Files:
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/SValTest.cpp


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -91,6 +92,21 @@
   mutable SVals CollectedSVals;
 };
 
+// Fixture class for parameterized SValTest
+class SValTest : public testing::TestWithParam {
+protected:
+  // FIXME: The tests "GetConstType" and "GetLocAsIntType" infer the type of
+  // integrals based on their bitwidth. This is not a reliable method on
+  // platforms where different integrals have the same width.
+  bool skipTest(StringRef TestName) {
+std::string target = GetParam().Target;
+return (target == "powerpc-ibm-aix" || target == "i686-apple-darwin9" ||
+target == "wasm32-unknown-unknown" ||
+target == "wasm64-unknown-unknown") &&
+   (TestName == "GetConstType" || TestName == "GetLocAsIntType");
+  }
+};
+
 // SVAL_TEST is a combined way of providing a short code snippet and
 // to test some programmatic predicates on symbolic values produced by the
 // engine for the actual code.
@@ -135,7 +151,16 @@
 });
\
   }
\

\
-  TEST(SValTest, NAME) { runCheckerOnCode(CODE); }   
\
+  TEST_P(SValTest, NAME) { 
\
+if (skipTest(#NAME)) { 
\
+  std::string target = GetParam().Target;  
\
+  GTEST_SKIP() << "certain integrals have the same bitwidth on "   
\
+   << target;  
\
+  return;  
\
+}  
\
+runCheckerOnCodeWithArgs(
\
+CODE, GetParam().getCommandLineArgs());
\
+  }
\
   void NAME##SValCollector::test(ExprEngine ,   
\
  const ASTContext ) const
 
@@ -361,6 +386,31 @@
   EXPECT_EQ(Context.VoidPtrTy, B.getType(Context));
 }
 
+std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  TestClangConfig config;
+  config.Language = Lang_CXX14;
+  for (std::string target :
+   {"i686-pc-windows-msvc",   "i686-apple-darwin9",
+"x86_64-apple-darwin9",   "x86_64-scei-ps4",
+"x86_64-windows-msvc","x86_64-unknown-linux",
+"x86_64-apple-macosx","x86_64-apple-ios14.0",
+"wasm32-unknown-unknown", "wasm64-unknown-unknown",
+"thumb-pc-win32", "sparc64-none-openbsd",
+"sparc-none-none","riscv64-unknown-linux",
+"ppc64-windows-msvc", "powerpc-ibm-aix",
+"powerpc64-ibm-aix",  "s390x-ibm-zos",
+"armv7-pc-windows-msvc",  "aarch64-pc-windows-msvc",
+"xcore-xmos-elf"}) {
+config.Target = target;
+all_configs.push_back(config);
+  }
+  return all_configs;
+}
+
+INSTANTIATE_TEST_SUITE_P(SValTests, SValTest,
+ testing::ValuesIn(allTestClangConfigs()));
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -31,5 +31,6 @@
   clangSerialization
   clangStaticAnalyzerCore
   clangStaticAnalyzerFrontend
+  clangTesting
   clangTooling
   )


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include 

[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-12-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

> but we could pick a couple of esoteric targets where integrals differ 
> significantly from what we have on x86_64

Turns out `wasm` and `darwin` also have a similar problem, I added them to the 
skip list for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114454/new/

https://reviews.llvm.org/D114454

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-12-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 391120.
stevewan added a comment.
Herald added subscribers: luke957, s.egerton, simoncook, fedor.sergeev, aheejin.

Add targets we are interested in testing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114454/new/

https://reviews.llvm.org/D114454

Files:
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/SValTest.cpp


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -91,6 +92,21 @@
   mutable SVals CollectedSVals;
 };
 
+// Fixture class for parameterized SValTest
+class SValTest : public testing::TestWithParam {
+protected:
+  // FIXME: The tests "GetConstType" and "GetLocAsIntType" infer the type of
+  // integrals based on their bitwidth. This is not a reliable method on
+  // platforms where different integrals have the same width.
+  bool skipTest(StringRef TestName) {
+std::string target = GetParam().Target;
+return (target == "powerpc-ibm-aix" || target == "i686-apple-darwin9" ||
+target == "wasm32-unknown-unknown" ||
+target == "wasm64-unknown-unknown") &&
+   (TestName == "GetConstType" || TestName == "GetLocAsIntType");
+  }
+};
+
 // SVAL_TEST is a combined way of providing a short code snippet and
 // to test some programmatic predicates on symbolic values produced by the
 // engine for the actual code.
@@ -135,7 +151,16 @@
 });
\
   }
\

\
-  TEST(SValTest, NAME) { runCheckerOnCode(CODE); }   
\
+  TEST_P(SValTest, NAME) { 
\
+if (skipTest(#NAME)) { 
\
+  std::string target = GetParam().Target;  
\
+  GTEST_SKIP() << "certain integrals have the same bitwidth on "   
\
+   << target;  
\
+  return;  
\
+}  
\
+runCheckerOnCodeWithArgs(
\
+CODE, GetParam().getCommandLineArgs());
\
+  }
\
   void NAME##SValCollector::test(ExprEngine ,   
\
  const ASTContext ) const
 
@@ -361,6 +386,31 @@
   EXPECT_EQ(Context.VoidPtrTy, B.getType(Context));
 }
 
+std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  TestClangConfig config;
+  config.Language = Lang_CXX14;
+  for (std::string target :
+   {"i686-pc-windows-msvc",   "i686-apple-darwin9",
+"x86_64-apple-darwin9",   "x86_64-scei-ps4",
+"x86_64-windows-msvc","x86_64-unknown-linux",
+"x86_64-apple-macosx","x86_64-apple-ios14.0",
+"wasm32-unknown-unknown", "wasm64-unknown-unknown",
+"thumb-pc-win32", "sparc64-none-openbsd",
+"sparc-none-none","riscv64-unknown-linux",
+"ppc64-windows-msvc", "powerpc-ibm-aix",
+"powerpc64-ibm-aix",  "s390x-ibm-zos",
+"armv7-pc-windows-msvc",  "aarch64-pc-windows-msvc",
+"xcore-xmos-elf"}) {
+config.Target = target;
+all_configs.push_back(config);
+  }
+  return all_configs;
+}
+
+INSTANTIATE_TEST_SUITE_P(SValTests, SValTest,
+ testing::ValuesIn(allTestClangConfigs()));
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -31,5 +31,6 @@
   clangSerialization
   clangStaticAnalyzerCore
   clangStaticAnalyzerFrontend
+  clangTesting
   clangTooling
   )


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include 

[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Finally had some time to get back to this. Thanks @steakhal for your 
suggestion, the sample code in `ASTMatchersNodeTest.cpp` was helpful. I was 
actually looking for a good way of querying the target triple as I do agree 
that it is an better way of fixing this. Hopefully I understood what you had 
suggested correctly.

Also by

> setting a bunch of target triples and letting gtest to run each one to see if 
> it still passes on all triples.

Did you mean adding all the triples that we're interested in to 
`allTestClangConfigs()`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114454/new/

https://reviews.llvm.org/D114454

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 390795.
stevewan added a comment.
Herald added a subscriber: mgorny.

Pin target triple before analysis


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114454/new/

https://reviews.llvm.org/D114454

Files:
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/SValTest.cpp


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -91,6 +92,17 @@
   mutable SVals CollectedSVals;
 };
 
+// Fixture class for parameterized SValTest
+class SValTest : public testing::TestWithParam {
+protected:
+  // FIXME: This is a hack to work around the fact that there is no way to
+  // differentiate int and long on 32-bit AIX solely based on bitwidth.
+  bool skipOnPPC32AIX(StringRef TestName) {
+return GetParam().Target == "powerpc-ibm-aix" &&
+   (TestName == "GetConstType" || TestName == "GetLocAsIntType");
+  }
+};
+
 // SVAL_TEST is a combined way of providing a short code snippet and
 // to test some programmatic predicates on symbolic values produced by the
 // engine for the actual code.
@@ -135,7 +147,12 @@
 });
\
   }
\

\
-  TEST(SValTest, NAME) { runCheckerOnCode(CODE); }   
\
+  TEST_P(SValTest, NAME) { 
\
+if (skipOnPPC32AIX(#NAME)) 
\
+  return;  
\
+runCheckerOnCodeWithArgs(
\
+CODE, GetParam().getCommandLineArgs());
\
+  }
\
   void NAME##SValCollector::test(ExprEngine ,   
\
  const ASTContext ) const
 
@@ -361,6 +378,20 @@
   EXPECT_EQ(Context.VoidPtrTy, B.getType(Context));
 }
 
+std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  TestClangConfig config;
+  config.Language = Lang_CXX14;
+  config.Target = "powerpc-ibm-aix";
+  all_configs.push_back(config);
+  config.Target = "powerpc-ibm-linux";
+  all_configs.push_back(config);
+  return all_configs;
+}
+
+INSTANTIATE_TEST_SUITE_P(SValTests, SValTest,
+ testing::ValuesIn(allTestClangConfigs()));
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -31,5 +31,6 @@
   clangSerialization
   clangStaticAnalyzerCore
   clangStaticAnalyzerFrontend
+  clangTesting
   clangTooling
   )


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -91,6 +92,17 @@
   mutable SVals CollectedSVals;
 };
 
+// Fixture class for parameterized SValTest
+class SValTest : public testing::TestWithParam {
+protected:
+  // FIXME: This is a hack to work around the fact that there is no way to
+  // differentiate int and long on 32-bit AIX solely based on bitwidth.
+  bool skipOnPPC32AIX(StringRef TestName) {
+return GetParam().Target == "powerpc-ibm-aix" &&
+   (TestName == "GetConstType" || TestName == "GetLocAsIntType");
+  }
+};
+
 // SVAL_TEST is a combined way of providing a short code snippet and
 // to test some programmatic predicates on symbolic values produced by the
 // engine for the actual code.
@@ -135,7 +147,12 @@
 });\
   }\
\
-  TEST(SValTest, 

[PATCH] D114615: [NFC][clang]Increase the number of driver diagnostics

2021-11-29 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c32c568844c: [NFC][clang]Increase the number of driver 
diagnostics (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114615/new/

https://reviews.llvm.org/D114615

Files:
  clang/include/clang/Basic/DiagnosticIDs.h


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -30,7 +30,7 @@
 // Size of each of the diagnostic categories.
 enum {
   DIAG_SIZE_COMMON=  300,
-  DIAG_SIZE_DRIVER=  250,
+  DIAG_SIZE_DRIVER=  300,
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -30,7 +30,7 @@
 // Size of each of the diagnostic categories.
 enum {
   DIAG_SIZE_COMMON=  300,
-  DIAG_SIZE_DRIVER=  250,
+  DIAG_SIZE_DRIVER=  300,
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114484: [NFC][AIX]Disable unsupported hip test on AIX

2021-11-29 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23dc88622630: [NFC][AIX]Disable unsupported hip test on AIX 
(authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114484/new/

https://reviews.llvm.org/D114484

Files:
  clang/test/Driver/hip-version.hip


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -1,6 +1,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: aix
 
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -1,6 +1,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: aix
 
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114615: Increase the number of driver diagnostics

2021-11-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We're close to hitting the limited number of driver diagnostics, increase 
`DIAG_SIZE_DRIVER` to accommodate more.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114615

Files:
  clang/include/clang/Basic/DiagnosticIDs.h


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -30,7 +30,7 @@
 // Size of each of the diagnostic categories.
 enum {
   DIAG_SIZE_COMMON=  300,
-  DIAG_SIZE_DRIVER=  250,
+  DIAG_SIZE_DRIVER=  300,
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -30,7 +30,7 @@
 // Size of each of the diagnostic categories.
 enum {
   DIAG_SIZE_COMMON=  300,
-  DIAG_SIZE_DRIVER=  250,
+  DIAG_SIZE_DRIVER=  300,
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06d4a76309cd: [NFC][AIX]Disable precompiled module file 
tests on AIX (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114481/new/

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-24 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 389535.
stevewan added a comment.

Explain the rationale


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114481/new/

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114484: [NFC][AIX]Disable unsupported hip test on AIX

2021-11-23 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
Herald added a subscriber: yaxunl.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

AIX doesn't support GPU. There is no point testing HIP on it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114484

Files:
  clang/test/Driver/hip-version.hip


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -1,6 +1,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: aix
 
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s


Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -1,6 +1,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: aix
 
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114481: [NFC][AIX]Disable precompiled module file tests on AIX

2021-11-23 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The PCH reader looks for `__clangast` section in the precompiled module file, 
which is not present in the file on AIX, and we don't support writing this 
custom section in XCOFF yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114481

Files:
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/PCH/debug-info-pch-path.c


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause


Index: clang/test/PCH/debug-info-pch-path.c
===
--- clang/test/PCH/debug-info-pch-path.c
+++ clang/test/PCH/debug-info-pch-path.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cd %t
Index: clang/test/ClangScanDeps/modules-pch.c
===
--- clang/test/ClangScanDeps/modules-pch.c
+++ clang/test/ClangScanDeps/modules-pch.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/modules-pch/* %t
 
Index: clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // Check that we discover dependency on a precompiled module (and generate the
 // appropriate `-fmodule-file=` argument) when it's imported by a **submodule**
 // instead of a top-level module.
Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: aix
+
 // Check that when depending on a precompiled module, we depend on the
 // **top-level** module. Submodules don't have some information present (for
 // example the path to the modulemap file) and depending on them might cause
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114454: [NFC][AIX]Disable unstable CSA tests failing on AIX

2021-11-23 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

CSA uses bitwidth to infer the integer value type. In the ILP32 model, for 
example 32-bit AIX, any 32-bit integer type will be
considerred as `int`, which isn't always true. In these particular failed 
tests, CSA thinks the pointers should be `int`, while in fact they are long on 
AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114454

Files:
  clang/unittests/StaticAnalyzer/SValTest.cpp


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -143,11 +143,19 @@
 // Actual tests
 
//===--===//
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetConstType, R"(
+void foo() {
+  int x = 42;
+  int *y = nullptr;
+})") {
+#else
 SVAL_TEST(GetConstType, R"(
 void foo() {
   int x = 42;
   int *y = nullptr;
 })") {
+#endif
   SVal X = getByName("x");
   ASSERT_FALSE(X.getType(Context).isNull());
   EXPECT_EQ(Context.IntTy, X.getType(Context));
@@ -157,12 +165,21 @@
   EXPECT_EQ(Context.getUIntPtrType(), Y.getType(Context));
 }
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetLocAsIntType, R"(
+void foo(int *x) {
+  long int a = (long int)x;
+  unsigned b = (long unsigned)
+  int c = (long int)nullptr;
+})") {
+#else
 SVAL_TEST(GetLocAsIntType, R"(
 void foo(int *x) {
   long int a = (long int)x;
   unsigned b = (long unsigned)
   int c = (long int)nullptr;
 })") {
+#endif
   SVal A = getByName("a");
   ASSERT_FALSE(A.getType(Context).isNull());
   // TODO: Turn it into signed long


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -143,11 +143,19 @@
 // Actual tests
 //===--===//
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetConstType, R"(
+void foo() {
+  int x = 42;
+  int *y = nullptr;
+})") {
+#else
 SVAL_TEST(GetConstType, R"(
 void foo() {
   int x = 42;
   int *y = nullptr;
 })") {
+#endif
   SVal X = getByName("x");
   ASSERT_FALSE(X.getType(Context).isNull());
   EXPECT_EQ(Context.IntTy, X.getType(Context));
@@ -157,12 +165,21 @@
   EXPECT_EQ(Context.getUIntPtrType(), Y.getType(Context));
 }
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetLocAsIntType, R"(
+void foo(int *x) {
+  long int a = (long int)x;
+  unsigned b = (long unsigned)
+  int c = (long int)nullptr;
+})") {
+#else
 SVAL_TEST(GetLocAsIntType, R"(
 void foo(int *x) {
   long int a = (long int)x;
   unsigned b = (long unsigned)
   int c = (long int)nullptr;
 })") {
+#endif
   SVal A = getByName("a");
   ASSERT_FALSE(A.getType(Context).isNull());
   // TODO: Turn it into signed long
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114381: [AIX] Disable unsupported offloading gpu tests

2021-11-22 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114381/new/

https://reviews.llvm.org/D114381

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104550: [analyzer] Implement getType for SVal

2021-11-18 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D104550#3139684 , @martong wrote:

> In D104550#3139239 , @stevewan 
> wrote:
>
>> In D104550#2849582 , @vsavchenko 
>> wrote:
>>
>>> In D104550#2849561 , 
>>> @DavidSpickett wrote:
>>>
 @vsavchenko One of the added tests is failing on our 32 bit Armv7 Thumb 
 bot: https://lab.llvm.org/buildbot/#/builders/170/builds/61

   
 /home/tcwg-buildslave/worker/clang-thumbv7-full-2stage/llvm/clang/unittests/StaticAnalyzer/SValTest.cpp:169:
  Failure
   Expected equality of these values:
 Context.UnsignedLongTy
   Which is: unsigned long
 A.getType(Context)
   Which is: unsigned int
   [  FAILED  ] SValTest.GetLocAsIntType (22 ms)
   [--] 1 test from SValTest (22 ms total)

 A 32/64 bit issue?
>>>
>>> Hi @DavidSpickett , thanks for looking into this!
>>> This patch was almost instantly followed by 
>>> https://github.com/llvm/llvm-project/commit/b2842298cebf420ecb3750bf309021a7f37870c1
>>>  which fixed the issue.  Please, let me know, if you still see it after 
>>> that commit!
>>
>> Sorry for posting to this slightly aged thread. I'm seeing a similar error 
>> of this on 32 bit AIX PPC, where `getUIntPtrType()` returns unsigned long, 
>> so the aforementioned follow-on patch no longer applies. The results from 
>> `getIntTypeForBitwidth()` seem unreliable in certain cases (e.g. int vs long 
>> in ILP32), and I couldn't think of a good way around it. Have you had any 
>> future plans on mitigating such problems?
>
> Hi there, what is the exact target triple?
> I wonder if it would be possible to create a new unit test case where we pass 
> somehow the target triple to `runCheckerOnCode`?

Hi, the target triple is `powerpc-ibm-aix`. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104550/new/

https://reviews.llvm.org/D104550

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104550: [analyzer] Implement getType for SVal

2021-11-17 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D104550#2849582 , @vsavchenko 
wrote:

> In D104550#2849561 , @DavidSpickett 
> wrote:
>
>> @vsavchenko One of the added tests is failing on our 32 bit Armv7 Thumb bot: 
>> https://lab.llvm.org/buildbot/#/builders/170/builds/61
>>
>>   
>> /home/tcwg-buildslave/worker/clang-thumbv7-full-2stage/llvm/clang/unittests/StaticAnalyzer/SValTest.cpp:169:
>>  Failure
>>   Expected equality of these values:
>> Context.UnsignedLongTy
>>   Which is: unsigned long
>> A.getType(Context)
>>   Which is: unsigned int
>>   [  FAILED  ] SValTest.GetLocAsIntType (22 ms)
>>   [--] 1 test from SValTest (22 ms total)
>>
>> A 32/64 bit issue?
>
> Hi @DavidSpickett , thanks for looking into this!
> This patch was almost instantly followed by 
> https://github.com/llvm/llvm-project/commit/b2842298cebf420ecb3750bf309021a7f37870c1
>  which fixed the issue.  Please, let me know, if you still see it after that 
> commit!

Sorry for posting to this slightly aged thread. I'm seeing a similar error of 
this on 32 bit AIX PPC, where `getUIntPtrType()` returns unsigned long, so the 
aforementioned follow-on patch no longer helps. The results from 
`getIntTypeForBitwidth()` seem unreliable in certain cases (e.g. int vs long in 
ILP32), and I couldn't think of a good way around it. Have you had any future 
plans on mitigating such problems?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104550/new/

https://reviews.llvm.org/D104550

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113614: [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF support.

2021-11-11 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42102bce98e5: [AIX][NFC] Disable clang-repl tests failing 
due to lack of 64-bit XCOFF support. (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113614/new/

https://reviews.llvm.org/D113614

Files:
  clang/unittests/Interpreter/InterpreterTest.cpp


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113614: Disable clang-repl tests failing due to lack of 64-bit XCOFF support.

2021-11-10 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The following interpreter tests failed on AIX because 64-bit XCOFF object files 
are currently not supported on AIX. This patch disables the tests on AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113614

Files:
  clang/unittests/Interpreter/InterpreterTest.cpp


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -145,7 +145,11 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
+#else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
+#endif
 
   std::unique_ptr Interp = createInterpreter();
 
@@ -201,7 +205,11 @@
   return R.getFoundDecl();
 }
 
+#ifdef _AIX
+TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
+#else
 TEST(IncrementalProcessing, InstantiateTemplate) {
+#endif
   // FIXME: We cannot yet handle delayed template parsing. If we run with
   // -fdelayed-template-parsing we try adding the newly created decl to the
   // active PTU which causes an assert.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-08 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG806ff3c4a42c: [AIX] Check for typedef properly when getting 
preferred type align (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109387/new/

https://reviews.llvm.org/D109387

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-power-alignment-typedef-2.cpp


Index: clang/test/Layout/aix-power-alignment-typedef-2.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef-2.cpp
+++ clang/test/Layout/aix-power-alignment-typedef-2.cpp
@@ -4,12 +4,26 @@
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
 // RUN:   FileCheck %s
 
-struct C {
+namespace test1 {
+struct S {
   double x;
 };
 
-typedef struct C __attribute__((__aligned__(2))) CC;
+typedef struct S __attribute__((__aligned__(2))) SS;
 
-CC cc;
+SS ss;
 
-// CHECK: @cc = global %struct.C zeroinitializer, align 2
+// CHECK: @{{.*}}test1{{.*}}ss{{.*}} = global %"struct.test1::S" 
zeroinitializer, align 2
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2))) S {
+  double x;
+};
+
+typedef struct S SS;
+
+SS ss;
+
+// CHECK: @{{.*}}test2{{.*}}ss{{.*}} = global %"struct.test2::S" 
zeroinitializer, align 8
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 


Index: clang/test/Layout/aix-power-alignment-typedef-2.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef-2.cpp
+++ clang/test/Layout/aix-power-alignment-typedef-2.cpp
@@ -4,12 +4,26 @@
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
 // RUN:   FileCheck %s
 
-struct C {
+namespace test1 {
+struct S {
   double x;
 };
 
-typedef struct C __attribute__((__aligned__(2))) CC;
+typedef struct S __attribute__((__aligned__(2))) SS;
 
-CC cc;
+SS ss;
 
-// CHECK: @cc = global %struct.C zeroinitializer, align 2
+// CHECK: @{{.*}}test1{{.*}}ss{{.*}} = global %"struct.test1::S" zeroinitializer, align 2
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2))) S {
+  double x;
+};
+
+typedef struct S SS;
+
+SS ss;
+
+// CHECK: @{{.*}}test2{{.*}}ss{{.*}} = global %"struct.test2::S" zeroinitializer, align 8
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-08 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 371418.
stevewan added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109387/new/

https://reviews.llvm.org/D109387

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-power-alignment-typedef-2.cpp


Index: clang/test/Layout/aix-power-alignment-typedef-2.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef-2.cpp
+++ clang/test/Layout/aix-power-alignment-typedef-2.cpp
@@ -4,12 +4,26 @@
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
 // RUN:   FileCheck %s
 
-struct C {
+namespace test1 {
+struct S {
   double x;
 };
 
-typedef struct C __attribute__((__aligned__(2))) CC;
+typedef struct S __attribute__((__aligned__(2))) SS;
 
-CC cc;
+SS ss;
 
-// CHECK: @cc = global %struct.C zeroinitializer, align 2
+// CHECK: @{{.*}}test1{{.*}}ss{{.*}} = global %"struct.test1::S" 
zeroinitializer, align 2
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2))) S {
+  double x;
+};
+
+typedef struct S SS;
+
+SS ss;
+
+// CHECK: @{{.*}}test2{{.*}}ss{{.*}} = global %"struct.test2::S" 
zeroinitializer, align 8
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 


Index: clang/test/Layout/aix-power-alignment-typedef-2.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef-2.cpp
+++ clang/test/Layout/aix-power-alignment-typedef-2.cpp
@@ -4,12 +4,26 @@
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
 // RUN:   FileCheck %s
 
-struct C {
+namespace test1 {
+struct S {
   double x;
 };
 
-typedef struct C __attribute__((__aligned__(2))) CC;
+typedef struct S __attribute__((__aligned__(2))) SS;
 
-CC cc;
+SS ss;
 
-// CHECK: @cc = global %struct.C zeroinitializer, align 2
+// CHECK: @{{.*}}test1{{.*}}ss{{.*}} = global %"struct.test1::S" zeroinitializer, align 2
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2))) S {
+  double x;
+};
+
+typedef struct S SS;
+
+SS ss;
+
+// CHECK: @{{.*}}test2{{.*}}ss{{.*}} = global %"struct.test2::S" zeroinitializer, align 8
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109387: [NFC][AIX] Check for typedef properly when getting preferred type align

2021-09-08 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D109387#2987843 , @rjmccall wrote:

> Oh, no, I don't think this is NFC.  It seems very likely that there's some 
> case where the behavior is distinguishable.  Maybe a typedef of a record with 
> an alignment attribute?
>
>   __attribute__((aligned(2), packed)) struct float4 { float x, y, z, w; };
>   typedef struct float4 float4typedef;
>   
>   struct {
> float4typedef field; // presumably still eligible for alignment upgrade
>   };

Right, the behaviour difference is exactly what I'm trying to fix, silly me :). 
Though the diff isn't very obvious in the given example because ABIAlign equals 
to PreferredAlign in that particular case, the following test may provide a 
better exposure,

  struct __attribute__((aligned(2))) S { double x; };
  typedef struct S SS;




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109387/new/

https://reviews.llvm.org/D109387

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D109387#2987780 , @rjmccall wrote:

> LGTM, except it's missing tests.

Thanks. This is an NFC patch, the tests added in 
https://reviews.llvm.org/D107598 should still suffice IMHO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109387/new/

https://reviews.llvm.org/D109387

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The current check for typedef is naive and doesn't deal with any convoluted 
cases. This patch makes use of the new 'AlignRequirement' enum field from 
'TypeInfo' to determine whether or not this is an 'aligned' attribute on a 
typedef.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109387

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-29 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71b170ccf36e: [AIX] aligned attribute does not 
decrease alignment (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,19 @@
 }
   }
 
+  // When used as part of a typedef, or together with a 'packed' attribute, the
+  // 'aligned' attribute can be used to decrease alignment. In that case, it
+  // overrides any computed alignment we have, and there is no need to upgrade
+  // the alignment.
+  auto alignedAttrCanDecreaseAIXAlignment = [AlignRequirement, FieldPacked] {
+// Enum alignment sources can be safely ignored here, because this only
+// helps decide whether we need the AIX alignment upgrade, which only
+

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-29 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369319.
stevewan added a comment.

Rename lambda and add comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,19 @@
 }
   }
 
+  // When used as part of a typedef, or together with a 'packed' attribute, the
+  // 'aligned' attribute can be used to decrease alignment. In that case, it
+  // overrides any computed alignment we have, and there is no need to upgrade
+  // the alignment.
+  auto alignedAttrCanDecreaseAIXAlignment = [AlignRequirement, FieldPacked] {
+// Enum alignment sources can be safely ignored here, because this only
+// helps decide whether we need the AIX alignment upgrade, which only
+// applies to floating-point types.
+return AlignRequirement == 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-28 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369293.
stevewan added a comment.

Adapt to new TypeInfo design


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,16 @@
 }
   }
 
+  // When used as part of a typedef, or together with a 'packed' attribute, the
+  // 'aligned' attribute can be used to decrease alignment. In that case, it
+  // overrides any computed alignment we have, and there is no need to upgrade
+  // the alignment.
+  auto alignedAttrCanDecreaseAlignment = [AlignRequirement, FieldPacked] {
+return AlignRequirement == AlignRequirementType::RequiredByTypedef ||
+   (AlignRequirement == AlignRequirementType::RequiredByRecord &&
+FieldPacked);
+  };
+
   // The AIX `power` 

[PATCH] D108858: TypeInfo records more information about align requirement

2021-08-28 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73733ae526a5: TypeInfo records more information about align 
requirement (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108858/new/

https://reviews.llvm.org/D108858

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1839,7 +1839,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6992,7 +6992,7 @@
 TyAlignForABI = CharUnits::fromQuantity(4);
   }
 
-  TypeInfoChars TyInfo(TySize, TyAlignForABI, false);
+  TypeInfoChars TyInfo(TySize, TyAlignForABI, AlignRequirementKind::None);
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, TyInfo,
   SlotSize, /*AllowHigherAlign*/ true);
 }
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -847,7 +847,7 @@
 // arguments was not supported and resulted in a compiler error. In 19.14
 // and later versions, such arguments are now passed indirectly.
 TypeInfo Info = getContext().getTypeInfo(RD->getTypeForDecl());
-if (Info.AlignIsRequired && Info.Align > 4)
+if (Info.isAlignRequired() && Info.Align > 4)
   return RAA_Indirect;
 
 // If C++ prohibits us from making a copy, construct the arguments directly
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,7 +52,7 @@
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext ) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.AlignIsRequired ? TI.Align : 0;
+  return TI.isAlignRequired() ? TI.Align : 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext ) {
@@ -4676,7 +4676,7 @@
 llvm::DIType *fieldType;
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
-  auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
+  auto Align = PtrInfo.isAlignRequired() ? PtrInfo.Align : 0;
   // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
   fieldType =
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,7 +1538,7 @@
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
-  bool AlignIsRequired = FieldInfo.AlignIsRequired;
+  bool AlignIsRequired = FieldInfo.isAlignRequired();
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1889,7 +1889,7 @@
 
   bool FieldPacked = Packed || D->hasAttr();
 
-  bool AlignIsRequired = false;
+  AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
   CharUnits FieldAlign;
   // The amount of this class's dsize occupied by the field.
@@ -1904,7 +1904,7 @@
 // aligned appropriately for their element type.
 EffectiveFieldSize = FieldSize =
 IsIncompleteArrayType ? CharUnits::Zero() : TI.Width;
-AlignIsRequired = TI.AlignIsRequired;
+AlignRequirement = TI.AlignRequirement;
   };
 
   if (D->getType()->isIncompleteArrayType()) {
@@ -1978,7 +1978,8 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
+  AlignRequirement == AlignRequirementKind::None &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1858,7 

[PATCH] D108858: TypeInfo records more information about align requirement

2021-08-28 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369258.
stevewan added a comment.

Add RequiredByEnum case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108858/new/

https://reviews.llvm.org/D108858

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1839,7 +1839,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6992,7 +6992,7 @@
 TyAlignForABI = CharUnits::fromQuantity(4);
   }
 
-  TypeInfoChars TyInfo(TySize, TyAlignForABI, false);
+  TypeInfoChars TyInfo(TySize, TyAlignForABI, AlignRequirementKind::None);
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, TyInfo,
   SlotSize, /*AllowHigherAlign*/ true);
 }
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -847,7 +847,7 @@
 // arguments was not supported and resulted in a compiler error. In 19.14
 // and later versions, such arguments are now passed indirectly.
 TypeInfo Info = getContext().getTypeInfo(RD->getTypeForDecl());
-if (Info.AlignIsRequired && Info.Align > 4)
+if (Info.isAlignRequired() && Info.Align > 4)
   return RAA_Indirect;
 
 // If C++ prohibits us from making a copy, construct the arguments directly
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,7 +52,7 @@
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext ) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.AlignIsRequired ? TI.Align : 0;
+  return TI.isAlignRequired() ? TI.Align : 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext ) {
@@ -4676,7 +4676,7 @@
 llvm::DIType *fieldType;
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
-  auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
+  auto Align = PtrInfo.isAlignRequired() ? PtrInfo.Align : 0;
   // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
   fieldType =
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,7 +1538,7 @@
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
-  bool AlignIsRequired = FieldInfo.AlignIsRequired;
+  bool AlignIsRequired = FieldInfo.isAlignRequired();
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1889,7 +1889,7 @@
 
   bool FieldPacked = Packed || D->hasAttr();
 
-  bool AlignIsRequired = false;
+  AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
   CharUnits FieldAlign;
   // The amount of this class's dsize occupied by the field.
@@ -1904,7 +1904,7 @@
 // aligned appropriately for their element type.
 EffectiveFieldSize = FieldSize =
 IsIncompleteArrayType ? CharUnits::Zero() : TI.Width;
-AlignIsRequired = TI.AlignIsRequired;
+AlignRequirement = TI.AlignRequirement;
   };
 
   if (D->getType()->isIncompleteArrayType()) {
@@ -1978,7 +1978,8 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
+  AlignRequirement == AlignRequirementKind::None &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1858,7 +1858,7 @@
 Width = llvm::alignTo(Width, Align);
   return 

[PATCH] D108858: TypeInfo records more information about align requirement

2021-08-28 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369240.
stevewan added a comment.

Fix enum usage


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108858/new/

https://reviews.llvm.org/D108858

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1839,7 +1839,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6992,7 +6992,7 @@
 TyAlignForABI = CharUnits::fromQuantity(4);
   }
 
-  TypeInfoChars TyInfo(TySize, TyAlignForABI, false);
+  TypeInfoChars TyInfo(TySize, TyAlignForABI, AlignRequirementKind::None);
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, TyInfo,
   SlotSize, /*AllowHigherAlign*/ true);
 }
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -847,7 +847,7 @@
 // arguments was not supported and resulted in a compiler error. In 19.14
 // and later versions, such arguments are now passed indirectly.
 TypeInfo Info = getContext().getTypeInfo(RD->getTypeForDecl());
-if (Info.AlignIsRequired && Info.Align > 4)
+if (Info.isAlignRequired() && Info.Align > 4)
   return RAA_Indirect;
 
 // If C++ prohibits us from making a copy, construct the arguments directly
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,7 +52,7 @@
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext ) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.AlignIsRequired ? TI.Align : 0;
+  return TI.isAlignRequired() ? TI.Align : 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext ) {
@@ -4676,7 +4676,7 @@
 llvm::DIType *fieldType;
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
-  auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
+  auto Align = PtrInfo.isAlignRequired() ? PtrInfo.Align : 0;
   // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
   fieldType =
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,7 +1538,7 @@
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
-  bool AlignIsRequired = FieldInfo.AlignIsRequired;
+  bool AlignIsRequired = FieldInfo.isAlignRequired();
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1889,7 +1889,7 @@
 
   bool FieldPacked = Packed || D->hasAttr();
 
-  bool AlignIsRequired = false;
+  AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
   CharUnits FieldAlign;
   // The amount of this class's dsize occupied by the field.
@@ -1904,7 +1904,7 @@
 // aligned appropriately for their element type.
 EffectiveFieldSize = FieldSize =
 IsIncompleteArrayType ? CharUnits::Zero() : TI.Width;
-AlignIsRequired = TI.AlignIsRequired;
+AlignRequirement = TI.AlignRequirement;
   };
 
   if (D->getType()->isIncompleteArrayType()) {
@@ -1978,7 +1978,8 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
+  AlignRequirement == AlignRequirementKind::None &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1858,7 +1858,7 @@
 Width = llvm::alignTo(Width, Align);
   return 

[PATCH] D108858: TypeInfo records more information about align requirement

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369235.
stevewan added a comment.

Oops missed one flag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108858/new/

https://reviews.llvm.org/D108858

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1839,7 +1839,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6992,7 +6992,7 @@
 TyAlignForABI = CharUnits::fromQuantity(4);
   }
 
-  TypeInfoChars TyInfo(TySize, TyAlignForABI, false);
+  TypeInfoChars TyInfo(TySize, TyAlignForABI, AlignRequirementKind::None);
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, TyInfo,
   SlotSize, /*AllowHigherAlign*/ true);
 }
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -847,7 +847,7 @@
 // arguments was not supported and resulted in a compiler error. In 19.14
 // and later versions, such arguments are now passed indirectly.
 TypeInfo Info = getContext().getTypeInfo(RD->getTypeForDecl());
-if (Info.AlignIsRequired && Info.Align > 4)
+if (Info.isAlignRequired() && Info.Align > 4)
   return RAA_Indirect;
 
 // If C++ prohibits us from making a copy, construct the arguments directly
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,7 +52,7 @@
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext ) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.AlignIsRequired ? TI.Align : 0;
+  return TI.isAlignRequired() ? TI.Align : 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext ) {
@@ -4676,7 +4676,7 @@
 llvm::DIType *fieldType;
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
-  auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
+  auto Align = PtrInfo.isAlignRequired() ? PtrInfo.Align : 0;
   // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
   fieldType =
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,7 +1538,7 @@
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
-  bool AlignIsRequired = FieldInfo.AlignIsRequired;
+  bool AlignIsRequired = FieldInfo.isAlignRequired();
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1889,7 +1889,7 @@
 
   bool FieldPacked = Packed || D->hasAttr();
 
-  bool AlignIsRequired = false;
+  AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
   CharUnits FieldAlign;
   // The amount of this class's dsize occupied by the field.
@@ -1904,7 +1904,7 @@
 // aligned appropriately for their element type.
 EffectiveFieldSize = FieldSize =
 IsIncompleteArrayType ? CharUnits::Zero() : TI.Width;
-AlignIsRequired = TI.AlignIsRequired;
+AlignRequirement = TI.AlignRequirement;
   };
 
   if (D->getType()->isIncompleteArrayType()) {
@@ -1978,7 +1978,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !isAlignRequired() &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1858,7 +1858,7 @@
 Width = llvm::alignTo(Width, Align);
   return TypeInfoChars(CharUnits::fromQuantity(Width),

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D107394#2970326 , @rjmccall wrote:

> Please add me to the review for the other patch and I'll approve it pretty 
> quickly, and then we can get back to this one.

Sorry for the delay. Posted https://reviews.llvm.org/D108858, once that's in 
I'll rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108858: TypeInfo records more information about align requirement

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Extend the information preserved in `TypeInfo` by replacing the
`AlignIsRequired` bool flag with a three-valued enum, the enum also
indicates where the alignment attribute come from, which could be
helpful in determining whether the attribute should overrule.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108858

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1839,7 +1839,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6992,7 +6992,7 @@
 TyAlignForABI = CharUnits::fromQuantity(4);
   }
 
-  TypeInfoChars TyInfo(TySize, TyAlignForABI, false);
+  TypeInfoChars TyInfo(TySize, TyAlignForABI, AlignRequirementKind::None);
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, TyInfo,
   SlotSize, /*AllowHigherAlign*/ true);
 }
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -847,7 +847,7 @@
 // arguments was not supported and resulted in a compiler error. In 19.14
 // and later versions, such arguments are now passed indirectly.
 TypeInfo Info = getContext().getTypeInfo(RD->getTypeForDecl());
-if (Info.AlignIsRequired && Info.Align > 4)
+if (Info.isAlignRequired() && Info.Align > 4)
   return RAA_Indirect;
 
 // If C++ prohibits us from making a copy, construct the arguments directly
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,7 +52,7 @@
 
 static uint32_t getTypeAlignIfRequired(const Type *Ty, const ASTContext ) {
   auto TI = Ctx.getTypeInfo(Ty);
-  return TI.AlignIsRequired ? TI.Align : 0;
+  return TI.isAlignRequired() ? TI.Align : 0;
 }
 
 static uint32_t getTypeAlignIfRequired(QualType Ty, const ASTContext ) {
@@ -4676,7 +4676,7 @@
 llvm::DIType *fieldType;
 if (capture->isByRef()) {
   TypeInfo PtrInfo = C.getTypeInfo(C.VoidPtrTy);
-  auto Align = PtrInfo.AlignIsRequired ? PtrInfo.Align : 0;
+  auto Align = PtrInfo.isAlignRequired() ? PtrInfo.Align : 0;
   // FIXME: This recomputes the layout of the BlockByRefWrapper.
   uint64_t xoffset;
   fieldType =
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,7 +1538,7 @@
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
-  bool AlignIsRequired = FieldInfo.AlignIsRequired;
+  bool AlignIsRequired = FieldInfo.isAlignRequired();
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1889,7 +1889,7 @@
 
   bool FieldPacked = Packed || D->hasAttr();
 
-  bool AlignIsRequired = false;
+  AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
   CharUnits FieldAlign;
   // The amount of this class's dsize occupied by the field.
@@ -1904,7 +1904,7 @@
 // aligned appropriately for their element type.
 EffectiveFieldSize = FieldSize =
 IsIncompleteArrayType ? CharUnits::Zero() : TI.Width;
-AlignIsRequired = TI.AlignIsRequired;
+AlignRequirement = TI.AlignRequirement;
   };
 
   if (D->getType()->isIncompleteArrayType()) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1858,7 +1858,7 @@
 Width = llvm::alignTo(Width, Align);
   return TypeInfoChars(CharUnits::fromQuantity(Width),
CharUnits::fromQuantity(Align),
-   EltInfo.AlignIsRequired);
+   EltInfo.AlignRequirement);
 }
 
 TypeInfoChars ASTContext::getTypeInfoInChars(const Type *T) const {
@@ -1866,8 +1866,7 @@
 return getConstantArrayInfoInChars(*this, CAT);
   TypeInfo 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369177.
stevewan added a comment.

Fix missing "&&"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1831,7 +1831,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6984,7 +6984,7 @@
 TyAlignForABI = 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369164.
stevewan added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1831,7 +1831,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ -6984,7 +6984,7 @@
 TyAlignForABI = 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369163.
stevewan marked an inline comment as done.
stevewan added a comment.

Cleanup the condition check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1831,7 +1831,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked an inline comment as done.
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1984
+auto checkTypeIsTypedef = [](auto &,
+ const auto Ty) -> bool {
+  bool isTypedef = false;

rjmccall wrote:
> Hah.  The knot-tying here is really cute, but I think either just make it a 
> static function somewhere in the file, or make it iterative instead of 
> recursive.
> 
> ...actually, I think it would be better to just make the computation in 
> `getTypeInfo` preserve more information.  Make `TypeInfo` carry a 
> three-valued enum instead of an `AlignIsRequired` flag:
> 
> ```
> enum class AlignRequirement {
>   /// The alignment was not explicit in code.
>   None,
> 
>   /// The alignment comes from an alignment attribute on a typedef.
>   RequiredByTypedef,
> 
>   /// The alignment comes from an alignment attribute on a record type.
>   RequiredByRecord,
> };
> ```
> 
> You can add a method on `TypeInfo` to ask if the alignment is required for 
> any reason and make all the existing clients use that instead.
Good idea. I had thought about a similar approach but was afraid that the 
change may get too pervasive. I think it turned out fine. I'm now debating 
whether I should split this whole bool-to-enum change into a separate patch, 
any preference?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-27 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 369157.
stevewan added a comment.

Make TypeInfo carry more information about "aligned" attribute


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1831,7 +1831,7 @@
 
 // Pass over-aligned aggregates on Windows indirectly. This behavior was
 // added in MSVC 2015.
-if (IsWin32StructABI && TI.AlignIsRequired && TI.Align > 32)
+if (IsWin32StructABI && TI.isAlignRequired() && TI.Align > 32)
   return getIndirectResult(Ty, /*ByVal=*/false, State);
 
 // Expand small (<= 128-bit) record types when we know that the stack layout
@@ 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 368716.
stevewan marked an inline comment as done.
stevewan added a comment.

Avoid unannotated fall-through between cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,8 +1978,144 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
+auto checkTypeIsTypedef = [](auto &,
+ const auto Ty) -> bool {
+  bool isTypedef = false;
+  switch 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked 2 inline comments as done.
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1975
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && (Ty->getAs() != nullptr || FieldPacked);
+

rjmccall wrote:
> stevewan wrote:
> > rjmccall wrote:
> > > Okay, so first off, the comment and variable names here make this sound 
> > > very general when in fact this computation is only relevant to the AIX 
> > > alignment upgrade logic.  Also, please do not introduce new variables 
> > > with broad scope named things like `Ty` that are actually referring to a 
> > > very specific type and not, say, the unadulterated type of the field.
> > > 
> > > It seems to me that the right way to think about this is that, while the 
> > > AIX power alignment upgrade considers whether field type alignment is 
> > > "required", it uses a different condition than the standard rule when 
> > > making that decision.  It's important to understand what that rule is 
> > > exactly, and we can't see that from the current test cases.  In 
> > > particular, attributes on fields that define structs inline actually end 
> > > up applying to both the field and the struct, which confounds unrelated 
> > > issues.  Consider:
> > > 
> > > ```
> > > struct __attribute__((packed, aligned(2))) SS {
> > >   double d;
> > > };
> > > 
> > > struct S {
> > >   // Neither the field nor the struct are packed, but the field type is.
> > >   // Do we apply the alignment upgrade to S or not?
> > >   struct SS s;
> > > };
> > > ```
> > > 
> > > Regardless, I don't think this check for a typedef works; it's bypassing 
> > > quite a bit of recursive logic for computing whether type alignment is 
> > > required.  For example, you could have an explicitly aligned typedef of 
> > > an array type, and you'll lose that typedef here.
> > Thanks for the review. 
> > 
> > > the comment and variable names here make this sound very general when in 
> > > fact this computation is only relevant to the AIX alignment upgrade logic.
> > Moved the variable declarations back to the AIX alignment upgrade logic. 
> > >  It's important to understand what that rule is exactly, and we can't see 
> > > that from the current test cases.
> > Updated the test cases accordingly.
> > > For example, you could have an explicitly aligned typedef of an array 
> > > type, and you'll lose that typedef here.
> > Updated the check to examine the immediate type rather than the base 
> > element type, this should take care of the array-type considerations. 
> > 
> No, I'm not sure that's quite correct, either, because you might have an 
> array of an explicitly aligned typedef.  You might need to do a recursive 
> examination of the type the same way that getTypeInfo would, except I guess 
> not recursing into records.
> 
> I assume you verified that the behavior in your new test cases matches the 
> behavior of some existing AIX compiler?  For our general edification, what 
> compiler(s) are you testing against?
> 
> I've found that extracting very complex conditions into a function (perhaps a 
> lambda if it's inconvenient to have it separately-declared) can be useful.
Added a lambda function that mimics getTypeInfo to do the recursive check. If 
this looks about right in direction, I'm also going to memorize known types' 
typedef-ness in a map for faster lookup.

Yes, the behaviour was verified, and matches the behaviour of XL 16.1 on AIX.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 368702.
stevewan added a comment.
Herald added a subscriber: jfb.

Add recursive check for typedef


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-power-alignment-typedef.cpp
===
--- clang/test/Layout/aix-power-alignment-typedef.cpp
+++ clang/test/Layout/aix-power-alignment-typedef.cpp
@@ -37,3 +37,39 @@
 // CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
 
 } // namespace test2
+
+namespace test3 {
+typedef double DblArr[] __attribute__((__aligned__(2)));
+
+union U {
+  DblArr da;
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test3::U
+// CHECK-NEXT: 0 |   test3::DblArr da
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test3
+
+namespace test4 {
+typedef double Dbl __attribute__((__aligned__(2)));
+
+union U {
+  Dbl DblArr[];
+  char x;
+};
+
+int x = sizeof(U);
+
+// CHECK:  0 | union test4::U
+// CHECK-NEXT: 0 |   test4::Dbl [] DblArr
+// CHECK-NEXT: 0 |   char x
+// CHECK-NEXT:   | [sizeof=2, dsize=2, align=2, preferredalign=2,
+// CHECK-NEXT:   |  nvsize=2, nvalign=2, preferrednvalign=2]
+
+} // namespace test4
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,8 +1978,144 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
+auto checkTypeIsTypedef = [](auto &,
+ const auto Ty) -> bool {
+  bool isTypedef = false;
+  switch (Ty->getTypeClass()) {
+  case 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-20 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 367942.
stevewan added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,7 +1978,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,16 +1989,25 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
-if (const ComplexType *CTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
-} else if (const BuiltinType *BTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(BTy);
-} else if (const RecordType *RT = Ty->getAs()) {
-  const RecordDecl *RD = RT->getDecl();
-  assert(RD && "Expected non-null RecordDecl.");
-  const ASTRecordLayout  = Context.getASTRecordLayout(RD);
-  PreferredAlign = FieldRecord.getPreferredAlignment();
+const Type *Ty = D->getType().getTypePtr();
+const Type *BaseTy = Ty->getBaseElementTypeUnsafe();
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment. In that case,
+// it overrides any computed alignment we have, and there is no need to
+// upgrade the alignment.
+if (!(AlignIsRequired &&
+  (Ty->getTypeClass() == Type::Typedef || FieldPacked))) {
+  if (const ComplexType *CTy = BaseTy->getAs()) {
+performBuiltinTypeAlignmentUpgrade(
+CTy->getElementType()->castAs());
+  } else if (const BuiltinType *BTy = BaseTy->getAs()) {
+performBuiltinTypeAlignmentUpgrade(BTy);
+  

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-20 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 367875.
stevewan added a comment.

De-Morgan-ize if condition for readability


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,7 +1978,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,16 +1989,25 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
-if (const ComplexType *CTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
-} else if (const BuiltinType *BTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(BTy);
-} else if (const RecordType *RT = Ty->getAs()) {
-  const RecordDecl *RD = RT->getDecl();
-  assert(RD && "Expected non-null RecordDecl.");
-  const ASTRecordLayout  = Context.getASTRecordLayout(RD);
-  PreferredAlign = FieldRecord.getPreferredAlignment();
+const Type *Ty = D->getType().getTypePtr();
+const Type *BaseTy = Ty->getBaseElementTypeUnsafe();
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment. In that case,
+// it overrides any computed alignment we have, and there is no need to
+// upgrade the alignment.
+if (!(AlignIsRequired &&
+  !(Ty->getTypeClass() == Type::Typedef || FieldPacked))) {
+  if (const ComplexType *CTy = BaseTy->getAs()) {
+performBuiltinTypeAlignmentUpgrade(
+CTy->getElementType()->castAs());
+  } else if (const BuiltinType *BTy = BaseTy->getAs()) {
+

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-20 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1975
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && (Ty->getAs() != nullptr || FieldPacked);
+

rjmccall wrote:
> Okay, so first off, the comment and variable names here make this sound very 
> general when in fact this computation is only relevant to the AIX alignment 
> upgrade logic.  Also, please do not introduce new variables with broad scope 
> named things like `Ty` that are actually referring to a very specific type 
> and not, say, the unadulterated type of the field.
> 
> It seems to me that the right way to think about this is that, while the AIX 
> power alignment upgrade considers whether field type alignment is "required", 
> it uses a different condition than the standard rule when making that 
> decision.  It's important to understand what that rule is exactly, and we 
> can't see that from the current test cases.  In particular, attributes on 
> fields that define structs inline actually end up applying to both the field 
> and the struct, which confounds unrelated issues.  Consider:
> 
> ```
> struct __attribute__((packed, aligned(2))) SS {
>   double d;
> };
> 
> struct S {
>   // Neither the field nor the struct are packed, but the field type is.
>   // Do we apply the alignment upgrade to S or not?
>   struct SS s;
> };
> ```
> 
> Regardless, I don't think this check for a typedef works; it's bypassing 
> quite a bit of recursive logic for computing whether type alignment is 
> required.  For example, you could have an explicitly aligned typedef of an 
> array type, and you'll lose that typedef here.
Thanks for the review. 

> the comment and variable names here make this sound very general when in fact 
> this computation is only relevant to the AIX alignment upgrade logic.
Moved the variable declarations back to the AIX alignment upgrade logic. 
>  It's important to understand what that rule is exactly, and we can't see 
> that from the current test cases.
Updated the test cases accordingly.
> For example, you could have an explicitly aligned typedef of an array type, 
> and you'll lose that typedef here.
Updated the check to examine the immediate type rather than the base element 
type, this should take care of the array-type considerations. 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-20 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 367833.
stevewan added a comment.

Address comments about the check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-type-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-type-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-type-align-and-pack-attr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test1{{.*}}s{{.*}} = global %"struct.test1::S" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test2{{.*}}s{{.*}} = global %"struct.test2::S" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) S {
+  double d;
+};
+
+S s;
+
+// CHECK: @{{.*}}test3{{.*}}s{{.*}} = global %"struct.test3::S" zeroinitializer, align 16
+} // namespace test3
+
+namespace test4 {
+struct __attribute__((aligned(2))) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test4{{.*}}s{{.*}} = global %"struct.test4::S" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct __attribute__((aligned(2), packed)) SS {
+  double d;
+};
+
+struct S {
+  struct SS ss;
+} s;
+
+// CHECK: @{{.*}}test5{{.*}}s{{.*}} = global %"struct.test5::S" zeroinitializer, align 2
+} // namespace test5
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
-// RUN:   FileCheck %s
-
-namespace test1 {
-struct __attribute__((__aligned__(2))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
-} // namespace test1
-
-namespace test2 {
-struct __attribute__((__aligned__(2), packed)) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
-} // namespace test2
-
-namespace test3 {
-struct __attribute__((__aligned__(16))) C {
-  double x;
-} c;
-
-// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
-} // namespace test3
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1978,7 +1978,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,16 +1989,25 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
-if (const ComplexType *CTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
-} else if (const BuiltinType *BTy = Ty->getAs()) {
-  performBuiltinTypeAlignmentUpgrade(BTy);
-} else if (const RecordType *RT = Ty->getAs()) {
-  const RecordDecl *RD = RT->getDecl();
-  assert(RD && "Expected non-null RecordDecl.");
-  const ASTRecordLayout  = Context.getASTRecordLayout(RD);
-  PreferredAlign = FieldRecord.getPreferredAlignment();
+const Type *Ty = D->getType().getTypePtr();
+const Type *BaseTy = Ty->getBaseElementTypeUnsafe();
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment. In that case,
+// it overrides any computed alignment we have, and there is no need to
+// upgrade the alignment.
+if (!AlignIsRequired ||
+Ty->getTypeClass() != Type::Typedef && !FieldPacked) {
+  if (const ComplexType *CTy = BaseTy->getAs()) {
+performBuiltinTypeAlignmentUpgrade(
+CTy->getElementType()->castAs());
+  } else if (const BuiltinType *BTy = BaseTy->getAs()) {
+

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-18 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 367312.
stevewan added a comment.

Fields marked attribute "aligned" and "packed" don't need to go through 
alignment upgrade


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -27,3 +27,23 @@
 
 // CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" 
zeroinitializer, align 16
 } // namespace test3
+
+namespace test4 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2))) cc;
+} c;
+
+// CHECK: @{{.*}}test4{{.*}}c{{.*}} = global %"struct.test4::C" 
zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2), packed)) cc;
+} c;
+
+// CHECK: @{{.*}}test5{{.*}}c{{.*}} = global %"struct.test5::C" 
zeroinitializer, align 2
+} // namespace test5
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, or together with a 'packed' attribute,
+  // the 'aligned' attribute can be used to decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && (Ty->getAs() != nullptr || FieldPacked);
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1978,7 +1984,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,7 +1995,6 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
 if (const ComplexType *CTy = Ty->getAs()) {
   
performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
 } else if (const BuiltinType *BTy = Ty->getAs()) {


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -27,3 +27,23 @@
 
 // CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
 } // namespace test3
+
+namespace test4 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2))) cc;
+} c;
+
+// CHECK: @{{.*}}test4{{.*}}c{{.*}} = global %"struct.test4::C" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2), packed)) cc;
+} c;
+
+// CHECK: @{{.*}}test5{{.*}}c{{.*}} = global %"struct.test5::C" zeroinitializer, align 2
+} // namespace test5
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, or together with a 'packed' attribute,
+  // the 'aligned' attribute can be used to decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && (Ty->getAs() != nullptr || FieldPacked);
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1978,7 +1984,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-12 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 366051.
stevewan added a comment.

Rebase to latest main


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -27,3 +27,23 @@
 
 // CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" 
zeroinitializer, align 16
 } // namespace test3
+
+namespace test4 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2))) cc;
+} c;
+
+// CHECK: @{{.*}}test4{{.*}}c{{.*}} = global %"struct.test4::C" 
zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2), packed)) cc;
+} c;
+
+// CHECK: @{{.*}}test5{{.*}}c{{.*}} = global %"struct.test5::C" 
zeroinitializer, align 2
+} // namespace test5
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, the 'aligned' attribute can be used to
+  // decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && Ty->getAs() != nullptr;
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1978,7 +1984,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,7 +1995,6 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
 if (const ComplexType *CTy = Ty->getAs()) {
   
performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
 } else if (const BuiltinType *BTy = Ty->getAs()) {


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -27,3 +27,23 @@
 
 // CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
 } // namespace test3
+
+namespace test4 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2))) cc;
+} c;
+
+// CHECK: @{{.*}}test4{{.*}}c{{.*}} = global %"struct.test4::C" zeroinitializer, align 8
+} // namespace test4
+
+namespace test5 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2), packed)) cc;
+} c;
+
+// CHECK: @{{.*}}test5{{.*}}c{{.*}} = global %"struct.test5::C" zeroinitializer, align 2
+} // namespace test5
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1968,6 +1968,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, the 'aligned' attribute can be used to
+  // decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && Ty->getAs() != nullptr;
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1978,7 +1984,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1989,7 +1995,6 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
 if (const ComplexType 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-06 Thread Steven Wan via Phabricator via cfe-commits
stevewan planned changes to this revision.
stevewan added a comment.

The query portion has been split out as https://reviews.llvm.org/D107598, which 
needs to be cleaned out from this patch. The record layout part also needs 
update as we uncover more problems with the current implementation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107598: [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__

2021-08-05 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa91916500d67: [AIX] aligned attribute should not 
decrease type alignment returned by… (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107598/new/

https://reviews.llvm.org/D107598

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" 
zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" 
zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" 
zeroinitializer, align 16
+} // namespace test3
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
+} // namespace test3
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107598: [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__

2021-08-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 364630.
stevewan added a comment.

Add third test case as suggested.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107598/new/

https://reviews.llvm.org/D107598

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" 
zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" 
zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" 
zeroinitializer, align 16
+} // namespace test3
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct __attribute__((__aligned__(16))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 16
+} // namespace test3
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107598: [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__

2021-08-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

This is a split of the query portion from https://reviews.llvm.org/D107394.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107598/new/

https://reviews.llvm.org/D107598

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107598: [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__

2021-08-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The "__alignof__()" operator, when used on a type, always returns the 
`ABIAlign` if the type is marked `__attribute__((aligned()))`. However, the 
"aligned" attribute should only increase the alignment of a struct, or struct 
member, unless it's used together with the "packed" attribute, or used as a 
part of a typedef, in which case, the "aligned" attribute can both increase and 
decrease alignment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107598

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" 
zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" 
zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 364359.
stevewan added a comment.

Add test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp

Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
+
+namespace test3 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2))) cc;
+} c;
+
+// CHECK: @{{.*}}test3{{.*}}c{{.*}} = global %"struct.test3::C" zeroinitializer, align 8
+} // namespace test3
+
+namespace test4 {
+struct C {
+  struct CC {
+long double ld;
+  } __attribute__((aligned(2), packed)) cc;
+} c;
+
+// CHECK: @{{.*}}test4{{.*}}c{{.*}} = global %"struct.test4::C" zeroinitializer, align 2
+} // namespace test4
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1961,6 +1961,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, the 'aligned' attribute can be used to
+  // decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && Ty->getAs() != nullptr;
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1971,7 +1977,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1982,7 +1988,6 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
 if (const ComplexType *CTy = Ty->getAs()) {
   performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
 } else if (const BuiltinType *BTy = Ty->getAs()) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 364350.
stevewan marked an inline comment as done.
stevewan added a comment.

Fix the same problem in field layout.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" 
zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" 
zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1961,6 +1961,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, the 'aligned' attribute can be used to
+  // decrease alignment.
+  bool AlignAttrCanDecreaseAlignment =
+  AlignIsRequired && Ty->getAs() != nullptr;
+
   // The AIX `power` alignment rules apply the natural alignment of the
   // "first member" if it is of a floating-point data type (or is an aggregate
   // whose recursively "first" member or element is such a type). The alignment
@@ -1971,7 +1977,7 @@
   // and zero-width bit-fields count as prior members; members of empty class
   // types marked `no_unique_address` are not considered to be prior members.
   CharUnits PreferredAlign = FieldAlign;
-  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  if (DefaultsToAIXPowerAlignment && !AlignAttrCanDecreaseAlignment &&
   (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) {
 auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) {
   if (BTy->getKind() == BuiltinType::Double ||
@@ -1982,7 +1988,6 @@
   }
 };
 
-const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
 if (const ComplexType *CTy = Ty->getAs()) {
   
performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs());
 } else if (const BuiltinType *BTy = Ty->getAs()) {
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1961,6 +1961,12 @@
 }
   }
 
+  const Type *Ty = D->getType()->getBaseElementTypeUnsafe();
+  // When used as part of a typedef, the 'aligned' attribute can be used to
+  // 

[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked an inline comment as done.
stevewan added inline comments.



Comment at: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp:11
+
+// CHECK: @c = global %struct.C zeroinitializer, align 2

sfertile wrote:
> Minor nit: I think the other test can live in this file, highlighting the 
> difference between the 2 cases is nice. Also I think we should add a typedef 
> test in here as well.
Merged the tests as suggested. We have the typedef coverage in 
`aix-power-alignment-typedef.cpp` and `aix-power-alignment-typedef2.cpp`, not 
sure if want to merge those as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 364186.
stevewan added a comment.

Merge tests into one file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" 
zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" 
zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+namespace test1 {
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test1{{.*}}c{{.*}} = global %"struct.test1::C" zeroinitializer, align 8
+} // namespace test1
+
+namespace test2 {
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @{{.*}}test2{{.*}}c{{.*}} = global %"struct.test2::C" zeroinitializer, align 2
+} // namespace test2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-08-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106900/new/

https://reviews.llvm.org/D106900

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 363870.
stevewan added a comment.

Fix incomplete diff, please discard last update.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-alignof-align-attr.cpp


Index: clang/test/Layout/aix-alignof-align-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 8
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 8
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,16 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 363860.
stevewan added a comment.

Attr 'packed' is already taken into account in ABIAlign/PreferredAlign


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107394/new/

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2480,13 +2480,10 @@
   if (const auto *RT = T->getAs()) {
 const RecordDecl *RD = RT->getDecl();
 
-if (RD->isInvalidDecl())
-  return ABIAlign;
-
 // When used as part of a typedef, or together with a 'packed' attribute,
 // the 'aligned' attribute can be used to decrease alignment.
-if (TI.AlignIsRequired &&
-(T->getAs() != nullptr || RD->hasAttr()))
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2480,13 +2480,10 @@
   if (const auto *RT = T->getAs()) {
 const RecordDecl *RD = RT->getDecl();
 
-if (RD->isInvalidDecl())
-  return ABIAlign;
-
 // When used as part of a typedef, or together with a 'packed' attribute,
 // the 'aligned' attribute can be used to decrease alignment.
-if (TI.AlignIsRequired &&
-(T->getAs() != nullptr || RD->hasAttr()))
+if ((TI.AlignIsRequired && T->getAs() != nullptr) ||
+RD->isInvalidDecl())
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107394: [AIX] "aligned" attribute does not decrease alignment

2021-08-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The "aligned" attribute can only increase the alignment of a struct, or
struct member, unless it's used together with the "packed" attribute, or
used as a part of a typedef, in which case, the "aligned" attribute can
both increase and decrease alignment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107394

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
  clang/test/Layout/aix-alignof-align-attr.cpp


Index: clang/test/Layout/aix-alignof-align-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 8
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | 
\
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,19 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+if (RD->isInvalidDecl())
+  return ABIAlign;
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if (TI.AlignIsRequired &&
+(T->getAs() != nullptr || RD->hasAttr()))
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;


Index: clang/test/Layout/aix-alignof-align-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2))) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 8
Index: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-alignof-align-and-pack-attr.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s | \
+// RUN:   FileCheck %s
+
+struct __attribute__((__aligned__(2), packed)) C {
+  double x;
+} c;
+
+// CHECK: @c = global %struct.C zeroinitializer, align 2
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2478,11 +2478,19 @@
 return ABIAlign;
 
   if (const auto *RT = T->getAs()) {
-if (TI.AlignIsRequired || RT->getDecl()->isInvalidDecl())
+const RecordDecl *RD = RT->getDecl();
+
+if (RD->isInvalidDecl())
+  return ABIAlign;
+
+// When used as part of a typedef, or together with a 'packed' attribute,
+// the 'aligned' attribute can be used to decrease alignment.
+if (TI.AlignIsRequired &&
+(T->getAs() != nullptr || RD->hasAttr()))
   return ABIAlign;
 
 unsigned PreferredAlign = static_cast(
-toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
+toBits(getASTRecordLayout(RD).PreferredAlignment));
 assert(PreferredAlign >= ABIAlign &&
"PreferredAlign should be at least as large as ABIAlign.");
 return PreferredAlign;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1783
+if (FieldPacked) {
+  FieldAlign = UnpackedFieldAlign = 1;
+} else if (!MaxFieldAlignment.isZero()) {

`UnpackedFieldAlign` is used to check if the packed attribute is unnecessary 
(-Wpacked). here the attribute is making a difference, we probably shouldn't 
set `FieldAlign = UnpackedFieldAlign`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106900/new/

https://reviews.llvm.org/D106900

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1781
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);

sfertile wrote:
> stevewan wrote:
> > Just noting that the comment says `MaxFieldAlignment - The maximum allowed 
> > field alignment. This is set by #pragma pack`, but `__attribute__(packed)` 
> > also seems to set it to some large value that is at least as large as the 
> > FieldAlign. Maybe edit the comment accordingly for now, and a future 
> > follow-on patch if necessary.
> Sorry Steven, not sure what you are asking for. 
> 
> attribute packed will set 'FieldPacked` to true, in which case we ignore the 
> max field alignment  (and why the new comment says, or 1 if packed). IIUC the 
> MaXFieldAlign is set by only by pragma pack and pragma align in the Itanium 
> recored layout builder, and the place where it is set based on attribute 
> packed is int he Microsoft record layout builder and doesn't affect us here.
Sorry Sean, my previous comment was indeed confusing. The old buggy behaviour 
confused me, and for some reason I thought the code must had went down this if 
statement when attribute packed is set, hence the previous comment. Now that I 
take a second look, I realize the problem was actually that we never went into 
the `if` to fix the FieldAlign. Sorry for the churn.

 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106900/new/

https://reviews.llvm.org/D106900

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-29 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.
This revision is now accepted and ready to land.

LGTM with some nits.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1781
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);

Just noting that the comment says `MaxFieldAlignment - The maximum allowed 
field alignment. This is set by #pragma pack`, but `__attribute__(packed)` also 
seems to set it to some large value that is at least as large as the 
FieldAlign. Maybe edit the comment accordingly for now, and a future follow-on 
patch if necessary.



Comment at: clang/test/Layout/aix-packed-bitfields.c:95
+
+#pragma pack(2)
+struct __attribute__((packed)) PackedAttrAndPragma {

nit: might be helpful to use a different type for the zero-width bitfield here. 
(e.g., `long long : 0`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106900/new/

https://reviews.llvm.org/D106900

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105635: [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign.

2021-07-12 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG798fe3c774a1: [PowerPC][AIX] Fix Zero-width bit fields wrt 
MaxFieldAlign. (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105635/new/

https://reviews.llvm.org/D105635

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-bitfield-alignment.c
  clang/test/Layout/aix-packed-bitfields.c

Index: clang/test/Layout/aix-packed-bitfields.c
===
--- /dev/null
+++ clang/test/Layout/aix-packed-bitfields.c
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | FileCheck  %s
+//
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | FileCheck %s
+
+struct A {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+
+int a = sizeof(struct A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 4:0-29 |   int a2
+// CHECK-NEXT:  8:0-3 |   int a3
+// CHECK-NEXT:  sizeof=12, {{(dsize=12, )?}}align=4, preferredalign=4
+
+#pragma align(packed)
+struct AlignPacked {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma align(reset)
+
+int b = sizeof(struct AlignPacked);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct AlignPacked
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(1)
+struct Pack1 {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma pack(pop)
+
+int c = sizeof(struct Pack1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct Pack1
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct Pack2 {
+  int a1 : 30;
+  int a2 : 30;
+  int a3 : 4;
+};
+#pragma pack(pop)
+
+int d = sizeof(struct Pack2);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct Pack2
+// CHECK-NEXT: 0:0-29 |   int a1
+// CHECK-NEXT: 3:6-35 |   int a2
+// CHECK-NEXT:  7:4-7 |   int a3
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
Index: clang/test/Layout/aix-bitfield-alignment.c
===
--- clang/test/Layout/aix-bitfield-alignment.c
+++ clang/test/Layout/aix-bitfield-alignment.c
@@ -232,3 +232,37 @@
 // CHECK-NEXT:  0 | struct G
 // CHECK-NEXT: 0:0-44 |   long long ll
 // CHECK-NEXT:   sizeof=8, {{(dsize=8, )?}}align=8, preferredalign=8
+
+#pragma align(packed)
+struct H {
+   char c;
+   int : 0;
+   int i;
+} H;
+#pragma align(reset)
+
+int h = sizeof(H);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct H
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct I {
+   char c;
+   int : 0;
+   int i;
+} I;
+#pragma pack(pop)
+
+int i = sizeof(I);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct I
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4 |   int i
+// CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1775,6 +1775,12 @@
   !D->getIdentifier())
 FieldAlign = UnpackedFieldAlign = 1;
 
+  // On AIX, zero-width bitfields pad out to the alignment boundary, but then
+  // do not affect overall record alignment if there is a pragma pack or
+  // pragma align(packed).
+  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
+FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+
   // Diagnose differences in layout due to padding or packing.
   if (!UseExternalLayout)
 CheckFieldPadding(FieldOffset, UnpaddedFieldOffset, UnpackedFieldOffset,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103587: [AIX] Define __TOS_AIX__ predefined macro

2021-07-06 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG045872f42203: [AIX] Define __TOS_AIX__ predefined macro 
(authored by Jake-Egan, committed by stevewan).

Changed prior to commit:
  https://reviews.llvm.org/D103587?vs=349913=356783#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103587/new/

https://reviews.llvm.org/D103587

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -541,6 +541,7 @@
 // PPC-AIX:#define __SIZE_MAX__ 4294967295UL
 // PPC-AIX:#define __SIZE_TYPE__ long unsigned int
 // PPC-AIX:#define __SIZE_WIDTH__ 32
+// PPC-AIX:#define __TOS_AIX__ 1
 // PPC-AIX:#define __UINT16_C_SUFFIX__
 // PPC-AIX:#define __UINT16_MAX__ 65535
 // PPC-AIX:#define __UINT16_TYPE__ unsigned short
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -675,6 +675,7 @@
 Builder.defineMacro("_POWER");
 
 Builder.defineMacro("_AIX");
+Builder.defineMacro("__TOS_AIX__");
 
 if (Opts.C11) {
   Builder.defineMacro("__STDC_NO_ATOMICS__");


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -541,6 +541,7 @@
 // PPC-AIX:#define __SIZE_MAX__ 4294967295UL
 // PPC-AIX:#define __SIZE_TYPE__ long unsigned int
 // PPC-AIX:#define __SIZE_WIDTH__ 32
+// PPC-AIX:#define __TOS_AIX__ 1
 // PPC-AIX:#define __UINT16_C_SUFFIX__
 // PPC-AIX:#define __UINT16_MAX__ 65535
 // PPC-AIX:#define __UINT16_TYPE__ unsigned short
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -675,6 +675,7 @@
 Builder.defineMacro("_POWER");
 
 Builder.defineMacro("_AIX");
+Builder.defineMacro("__TOS_AIX__");
 
 if (Opts.C11) {
   Builder.defineMacro("__STDC_NO_ATOMICS__");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-07-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D105112#2858702 , @thakis wrote:

> Hi, you have to bump clang/include/clang/Serialization/ASTBitCodes.h's 
> VERSION_MAJOR after adding a LangOption, else builds with 
> LLVM_APPEND_VC_REV=NO won't invalidate their module cache correctly. See e.g. 
> https://reviews.llvm.org/rGb8b7a9dcdcbc Without that, tests are broken on 
> bots with  LLVM_APPEND_VC_REV=NO , eg 
> http://45.33.8.238/linux/50460/step_7.txt

Posted fix rGe2904c8e0fa901adeefe579297cb2ece2757fb18 
. Sorry 
for the churn.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105112/new/

https://reviews.llvm.org/D105112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-07-05 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9964b0ef828b: [clang] Add -fdump-record-layouts-canonical 
option (authored by daltenty, committed by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105112/new/

https://reviews.llvm.org/D105112

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/dump-canonical.cpp


Index: clang/test/Layout/dump-canonical.cpp
===
--- /dev/null
+++ clang/test/Layout/dump-canonical.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts-canonical %s | 
FileCheck %s -check-prefix CANONICAL
+
+typedef long foo_t;
+
+
+struct a {
+  foo_t x;
+} b;
+
+struct c {
+  typedef foo_t bar_t;
+  bar_t x;
+} d;
+
+// CHECK:  0 | foo_t
+// CHECK:  0 | c::bar_t
+// CANONICAL-NOT:  0 | foo_t
+// CANONICAL-NOT:  0 | c::bar_t
+// CANONICAL:  0 | long
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3577,7 +3577,10 @@
 } else {
   PrintOffset(OS, FieldOffset, IndentLevel);
 }
-OS << Field.getType().getAsString() << ' ' << Field << '\n';
+const QualType  = C.getLangOpts().DumpRecordLayoutsCanonical
+? Field.getType().getCanonicalType()
+: Field.getType();
+OS << FieldType.getAsString() << ' ' << Field << '\n';
   }
 
   // Dump virtual bases.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5405,13 +5405,16 @@
 def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
   HelpText<"Dump record layout information in a simple form used for testing">,
   MarshallingInfoFlag>;
+def fdump_record_layouts_canonical : Flag<["-"], 
"fdump-record-layouts-canonical">,
+  HelpText<"Dump record layout information with canonical field types">,
+  MarshallingInfoFlag>;
 def fdump_record_layouts_complete : Flag<["-"], 
"fdump-record-layouts-complete">,
   HelpText<"Dump record layout information for all complete types">,
   MarshallingInfoFlag>;
 def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
   HelpText<"Dump record layout information">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath, 
fdump_record_layouts_complete.KeyPath]>;
+  ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath, 
fdump_record_layouts_complete.KeyPath, fdump_record_layouts_canonical.KeyPath]>;
 def fix_what_you_can : Flag<["-"], "fix-what-you-can">,
   HelpText<"Apply fix-it advice even in the presence of unfixable errors">,
   MarshallingInfoFlag>;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -269,6 +269,7 @@
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd 
records")
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")
+BENIGN_LANGOPT(DumpRecordLayoutsCanonical , 1, 0, "dumping the AST layout of 
records using canonical field types")
 BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping the AST layout of 
all complete records")
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")


Index: clang/test/Layout/dump-canonical.cpp
===
--- /dev/null
+++ clang/test/Layout/dump-canonical.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -fdump-record-layouts-canonical %s | FileCheck %s -check-prefix CANONICAL
+
+typedef long foo_t;
+
+
+struct a {
+  foo_t x;
+} b;
+
+struct c {
+  typedef foo_t bar_t;
+  bar_t x;
+} d;
+
+// CHECK:  0 | foo_t
+// CHECK:  0 | c::bar_t
+// CANONICAL-NOT:  0 | foo_t
+// CANONICAL-NOT:  0 | c::bar_t
+// CANONICAL:  0 | long
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3577,7 +3577,10 @@
 } else {
   PrintOffset(OS, FieldOffset, IndentLevel);
 }
-OS << 

[PATCH] D105185: [AIX] Add _AIX73 version macro

2021-07-05 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52f34673ead3: [AIX] Add _AIX73 version macro (authored by 
Jake-Egan, committed by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105185/new/

https://reviews.llvm.org/D105185

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-ppc.c

Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -585,6 +585,20 @@
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX73 %s
+//
+// PPC-AIX73:#define _AIX32 1
+// PPC-AIX73:#define _AIX41 1
+// PPC-AIX73:#define _AIX43 1
+// PPC-AIX73:#define _AIX50 1
+// PPC-AIX73:#define _AIX51 1
+// PPC-AIX73:#define _AIX52 1
+// PPC-AIX73:#define _AIX53 1
+// PPC-AIX73:#define _AIX61 1
+// PPC-AIX73:#define _AIX71 1
+// PPC-AIX73:#define _AIX72 1
+// PPC-AIX73:#define _AIX73 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX72 %s
 //
 // PPC-AIX72:#define _AIX32 1
@@ -597,6 +611,7 @@
 // PPC-AIX72:#define _AIX61 1
 // PPC-AIX72:#define _AIX71 1
 // PPC-AIX72:#define _AIX72 1
+// PPC-AIX72-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX71 %s
 //
@@ -610,6 +625,7 @@
 // PPC-AIX71:#define _AIX61 1
 // PPC-AIX71:#define _AIX71 1
 // PPC-AIX71-NOT:#define _AIX72 1
+// PPC-AIX71-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix6.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX61 %s
 //
@@ -623,6 +639,7 @@
 // PPC-AIX61:#define _AIX61 1
 // PPC-AIX61-NOT:#define _AIX71 1
 // PPC-AIX61-NOT:#define _AIX72 1
+// PPC-AIX61-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX53 %s
 // PPC-AIX53:#define _AIX32 1
@@ -635,6 +652,7 @@
 // PPC-AIX53-NOT:#define _AIX61 1
 // PPC-AIX53-NOT:#define _AIX71 1
 // PPC-AIX53-NOT:#define _AIX72 1
+// PPC-AIX53-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX52 %s
 // PPC-AIX52:#define _AIX32 1
@@ -647,6 +665,7 @@
 // PPC-AIX52-NOT:#define _AIX61 1
 // PPC-AIX52-NOT:#define _AIX71 1
 // PPC-AIX52-NOT:#define _AIX72 1
+// PPC-AIX52-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX51 %s
 // PPC-AIX51:#define _AIX32 1
@@ -659,6 +678,7 @@
 // PPC-AIX51-NOT:#define _AIX61 1
 // PPC-AIX51-NOT:#define _AIX71 1
 // PPC-AIX51-NOT:#define _AIX72 1
+// PPC-AIX51-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.0.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX50 %s
 // PPC-AIX50:#define _AIX32 1
@@ -671,6 +691,7 @@
 // PPC-AIX50-NOT:#define _AIX61 1
 // PPC-AIX50-NOT:#define _AIX71 1
 // PPC-AIX50-NOT:#define _AIX72 1
+// PPC-AIX50-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.3.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX43 %s
 // PPC-AIX43:#define _AIX32 1
@@ -683,6 +704,7 @@
 // PPC-AIX43-NOT:#define _AIX61 1
 // PPC-AIX43-NOT:#define _AIX71 1
 // PPC-AIX43-NOT:#define _AIX72 1
+// PPC-AIX43-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix4.1.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX41 %s
 // PPC-AIX41:#define _AIX32 1
@@ -695,6 +717,7 @@
 // PPC-AIX41-NOT:#define _AIX61 1
 // PPC-AIX41-NOT:#define _AIX71 1
 // PPC-AIX41-NOT:#define _AIX72 1
+// PPC-AIX41-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix3.2.0.0 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX32 %s
 // PPC-AIX32:#define _AIX32 1
@@ -707,6 +730,7 @@
 // PPC-AIX32-NOT:#define _AIX61 1
 // PPC-AIX32-NOT:#define _AIX71 1
 // PPC-AIX32-NOT:#define _AIX72 1
+// PPC-AIX32-NOT:#define _AIX73 1
 
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-CXX %s
 //
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -700,6 +700,7 @@
 if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61");
 if (OsVersion >= 

[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-07-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105112/new/

https://reviews.llvm.org/D105112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105112: [clang] Add -fdump-record-layouts-canonical option

2021-06-30 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

I'm not familiar with `getCanonicalType()`, can you confirm whether it sees 
through nested typedef's?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105112/new/

https://reviews.llvm.org/D105112

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-25 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bc644aeca8f: Revert [AIX] Avoid structor alias; die 
before bad alias codegen (authored by Jake-Egan, committed by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102724/new/

https://reviews.llvm.org/D102724

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-constructor-alias.c


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5028,10 +5028,8 @@
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
   // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5028,10 +5028,8 @@
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
   // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Might be a dumb question, but I see this is a revert to rGb116ded 
, do we 
also want to revert the changes added to 
`llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp`?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4964
   if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  !RawTriple.isAMDGPU())
 CmdArgs.push_back("-mconstructor-aliases");

jasonliu wrote:
> Format as clang-format suggest. You could run clang-format or 
> git-clang-format just for your commits by the way. 
FWIW, if `clang-format` is installed on your host (you can do this via homebrew 
on mac IIRC), arc would use it as the linter when you do `arc lint` or `arc 
diff`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102724/new/

https://reviews.llvm.org/D102724

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97823: [AIX] Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b274ed49960: [AIX] Update default arch on AIX (authored by 
stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else 

[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327825.
stevewan added a comment.

Reflect varible is unused in its name.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, unused_micro;
+  T.getOSVersion(major, minor, unused_micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";

[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:403
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);

jsji wrote:
> `micro` unsed.
Sorry I missed this comment. I agree that the unused `micro` is a bit ugly, do 
you have a preference on how you'd like it to be improved? We don't have an 
existing query for only `major` and `minor`, and creating one seems unnecessary 
IMHO. If you think renaming the variable to `unused_micro` mitigates the 
problem, I can do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327803.
stevewan added a comment.

Improve handling different AIX versions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,14 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName =
+  (major < 7 || (major == 7 && minor < 2)) ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
___
cfe-commits 

[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 327798.
stevewan added a comment.

Address comments with regard to handling older AIX versions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,13 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName = major < 7 || minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,13 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  // The minimal arch level moved from pwr4 for AIX7.1 to
+  // pwr7 for AIX7.2.
+  TargetCPUName = major < 7 || minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D97823: Update default arch on AIX

2021-03-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:405
+  T.getOSVersion(major, minor, micro);
+  TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)

jsji wrote:
> jsji wrote:
> > Please add comments here about AIX 7.2's minimal arch is P7.
> `major == 7 ` should this be `major <= 7 `? Or else, we may get `pwr7` for 
> AIX 5.1.
That's a great idea. Although I think we'd need to change `major == 7 && minor 
< 2` to `major < 7 || minor < 2` to also handle 4.3 and 5.3 properly. Let me 
know if you have further comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97823/new/

https://reviews.llvm.org/D97823

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97823: Update default arch on AIX

2021-03-02 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On AIX, the default arch level should match the minimum supported arch level of 
the OS version


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97823

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-mcpu-default.c


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,11 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";


Index: clang/test/Driver/aix-mcpu-default.c
===
--- clang/test/Driver/aix-mcpu-default.c
+++ clang/test/Driver/aix-mcpu-default.c
@@ -1,10 +1,18 @@
-// Check that the target cpu defaults to power4 on AIX.
+// Check that the target cpu defaults to power7 on AIX7.2 and up.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
-// RUN:-target powerpc-ibm-aix \
-// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT %s
-// CHECK-MCPU-DEFAULT-NOT: warning:
-// CHECK-MCPU-DEFAULT: {{.*}}clang{{.*}}" "-cc1"
-// CHECK-MCPU-DEFAULT: "-target-cpu" "pwr4"
+// RUN:-target powerpc-ibm-aix7.2 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX72 %s
+// CHECK-MCPU-DEFAULT-AIX72-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX72: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX72: "-target-cpu" "pwr7"
+
+// Check that the target cpu defaults to power4 on AIX7.1 and below.
+// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MCPU-DEFAULT-AIX71 %s
+// CHECK-MCPU-DEFAULT-AIX71-NOT: warning:
+// CHECK-MCPU-DEFAULT-AIX71: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-MCPU-DEFAULT-AIX71: "-target-cpu" "pwr4"
 
 // Check that the user is able to overwrite the default with '-mcpu'.
 // RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -399,9 +399,11 @@
 if (!TargetCPUName.empty())
   return TargetCPUName;
 
-if (T.isOSAIX())
-  TargetCPUName = "pwr4";
-else if (T.getArch() == llvm::Triple::ppc64le)
+if (T.isOSAIX()) {
+  unsigned major, minor, micro;
+  T.getOSVersion(major, minor, micro);
+  TargetCPUName = major == 7 && minor < 2 ? "pwr4" : "pwr7";
+} else if (T.getArch() == llvm::Triple::ppc64le)
   TargetCPUName = "ppc64le";
 else if (T.getArch() == llvm::Triple::ppc64)
   TargetCPUName = "ppc64";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-13 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.
This revision is now accepted and ready to land.

This LGTM, but since I'm not most familiar with the type 1 failure in 
description, let's see if other reviewers have further comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-10 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:117
+/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple
+// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \
+// RUN:   mv %t/$DEFAULT_TRIPLE-gcc  %t/prefix || true

DavidSpickett wrote:
> stevewan wrote:
> > Maybe I'm not seeing something obvious here, but I'm not aware of the `file 
> > -E` usage, and on Linux I got `file: invalid option -- 'E'`.
> I was looking for a way to mimic [! -f ], which worked on the command 
> line but not in a test. From my system's file:
> -E  On filesystem errors (file not found etc), instead of handling 
> the error as regu‐
>  lar output as POSIX mandates and keep going, issue an error 
> message and exit.
> 
> I didn't realise it was non-standard, so I've switched to mv || true with the 
> error redirected so it won't confuse the verbose output.
I believe having just `mv || true` works, but I did like the idea of 
pre-checking for the existence of the file, and the test is more robust with 
the check. Is there a reason we wouldn't use `test -f` here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-09 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:117
+/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple
+// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \
+// RUN:   mv %t/$DEFAULT_TRIPLE-gcc  %t/prefix || true

Maybe I'm not seeing something obvious here, but I'm not aware of the `file -E` 
usage, and on Linux I got `file: invalid option -- 'E'`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-08 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D79842#2138857 , @DavidSpickett 
wrote:

> Right, I see the issue.
>
> The code that gets the default triple name 
> (https://reviews.llvm.org/D13340?id=36227#inline-108606) looks up the one you 
> have in cmake, not the actual default which you get in --version. We could 
> "fix" this by doing so when we make the tool name as well, but this breaks 
> whatever mips toolchain was using that. (their tools won't be 
> mips-unknown-elf-)
>
> So yes it looks up powerpc64le-linux-gnu but shows 
> powerpc64le-unknown-linux-gnu. Can't go back to using cmake's value because 
> on Mac OS, cmake has x86_64-darwin, clang has x86_64-darwin. Writing 
> to both is a short term option so I will try that and fold it into 
> https://reviews.llvm.org/D83055. (will add you on review once I update it)
>
> (this whole default triple lookup should probably go but I'd really like to 
> do that in its own commit)


Thanks. @DavidSpickett


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Yes, this issue was hit with the reland applied. When given a 
`--` format LLVM_DEFAULT_TARGET_TRIPLE, Clang would expand the 
target triple to `---`, and therefore causes the name 
mismatch between what the driver searches for and what the test case creates as 
the dummy tool.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-06 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

The test was failing on Linux if I set LLVM_DEFAULT_TARGET_TRIPLE. For example 
if I set it to`powerpc64le-linux-gnu` clang actually uses 
"powerpc64le-unknown-linux-gnu".

Would you be able to provide a fix to this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.

LGTM with minor nit.

I took a look at the failed tests in premerge checks, they didn't seem to be 
related, but please double check before you commit.




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:195
+  // Return if -nostdlibinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;

Can we rewrite this block of code so that it's in consistent with the previous 
one?
```
  if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
// Add /usr/include.
SmallString<128> UP(Sysroot);
path::append(UP, "/usr/include");
addSystemInclude(DriverArgs, CC1Args, UP.str());
  }
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82677/new/

https://reviews.llvm.org/D82677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-06-26 Thread Steven Wan via Phabricator via cfe-commits
stevewan marked an inline comment as done.
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:167
 
+void AIX::AddClangSystemIncludeArgs(const ArgList ,
+ArgStringList ) const {

stevewan wrote:
> I don't think this is the revision you intended to post.
This is a stale comment, please ignore.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82677/new/

https://reviews.llvm.org/D82677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-06-26 Thread Steven Wan via Phabricator via cfe-commits
stevewan added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:167
 
+void AIX::AddClangSystemIncludeArgs(const ArgList ,
+ArgStringList ) const {

I don't think this is the revision you intended to post.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82677/new/

https://reviews.llvm.org/D82677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81115: [PowerPC] Do not special case Darwin on PowerPC in target cpu handling

2020-06-05 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61cd264068ee: [PowerPC] Do not special case Darwin on 
PowerPC in target cpu handling (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81115/new/

https://reviews.llvm.org/D81115

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,19 +294,19 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
-if (TargetCPUName.empty()) {
-  if (T.isOSAIX())
-TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
-}
+// each architecture. (except on AIX)
+if (!TargetCPUName.empty())
+  return TargetCPUName;
+
+if (T.isOSAIX())
+  TargetCPUName = "pwr4";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else
+  TargetCPUName = "ppc";
+
 return TargetCPUName;
   }
 


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,19 +294,19 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
-if (TargetCPUName.empty()) {
-  if (T.isOSAIX())
-TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
-}
+// each architecture. (except on AIX)
+if (!TargetCPUName.empty())
+  return TargetCPUName;
+
+if (T.isOSAIX())
+  TargetCPUName = "pwr4";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else
+  TargetCPUName = "ppc";
+
 return TargetCPUName;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81115: [PowerPC] Do not special case Darwin on PowerPC in target cpu handling

2020-06-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

The unit test failure (`instrprof-gcov-multithread_fork.test`) in pre merge 
checks is caused by another commit. See 
http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/2205.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81115/new/

https://reviews.llvm.org/D81115



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80966: [codeview] Put !heapallocsite on calls to operator new

2020-06-05 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Looks like this has broken the build bot? (see 
http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/2205)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80966/new/

https://reviews.llvm.org/D80966



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >