[clang] 5bf2409 - [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions
Author: stevewan Date: 2020-05-25T13:44:15-04:00 New Revision: 5bf2409a4e4d23018ecffe4eff39988a957e76f7 URL: https://github.com/llvm/llvm-project/commit/5bf2409a4e4d23018ecffe4eff39988a957e76f7 DIFF: https://github.com/llvm/llvm-project/commit/5bf2409a4e4d23018ecffe4eff39988a957e76f7.diff LOG: [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions Summary: On AIX, add '-bcdtors:all:0:s' to the linker implicitly through the driver so that we can collect all static constructor and destructor functions. Reviewers: hubert.reinterpretcast, Xiangling_L, ZarkoCA, daltenty Reviewed By: hubert.reinterpretcast Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80415 Added: Modified: clang/lib/Driver/ToolChains/AIX.cpp clang/test/Driver/aix-ld.c Removed: diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index 6fbff61f7656..df2e30da32a8 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -81,6 +81,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { const AIX &ToolChain = static_cast(getToolChain()); + const Driver &D = ToolChain.getDriver(); ArgStringList CmdArgs; const bool IsArch32Bit = ToolChain.getTriple().isArch32Bit(); @@ -129,6 +130,12 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(; } + // Collect all static constructor and destructor functions in CXX mode. This + // has to come before AddLinkerInputs as the implied option needs to precede + // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward. + if (D.CCCIsCXX()) +CmdArgs.push_back("-bcdtors:all:0:s"); + // Specify linker input file(s). AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c index 95495718546c..218fbd2bb380 100644 --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -175,3 +175,21 @@ // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads" // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc" + +// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order. +// RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \ +// RUN: -Wl,-bnocdtors \ +// RUN: -target powerpc-ibm-aix7.1.0.0 \ +// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s + +// CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso" +// CHECK-LD32-CXX-ARG-ORDER: "-b32" +// CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x1000" "-bpD:0x2000" +// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" +// CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s" +// CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors" +// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a924dac - [NFC] Fix formatting for the 'aix-ld.c' test case.
Author: stevewan Date: 2020-05-26T18:11:49-04:00 New Revision: a924dac44f31ffa19508165fc61a9f10cd1d4836 URL: https://github.com/llvm/llvm-project/commit/a924dac44f31ffa19508165fc61a9f10cd1d4836 DIFF: https://github.com/llvm/llvm-project/commit/a924dac44f31ffa19508165fc61a9f10cd1d4836.diff LOG: [NFC] Fix formatting for the 'aix-ld.c' test case. Summary: Based on comments received in D80415 pertinent to test case format, the following fixes are provided to other tests in 'aix-ld.c' for the sake of consistency and readability, - Align flags in RUN directives vertically. - Align patterns in CHECK directives vertically. - Remove the ‘-o %t.o’ as it’s unnecessary for tests with ‘-###’. - Fix typos in comments. Reviewers: ZarkoCA, hubert.reinterpretcast, daltenty Reviewed By: hubert.reinterpretcast Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80532 Added: Modified: clang/test/Driver/aix-ld.c Removed: diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c index 218fbd2bb380..59e35248af30 100644 --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -2,177 +2,177 @@ // sysroot to make these tests independent of the host system. // Check powerpc-ibm-aix7.1.0.0, 32-bit. -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target powerpc-ibm-aix7.1.0.0 \ -// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ +// RUN:-target powerpc-ibm-aix7.1.0.0 \ +// RUN:--sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32 %s // CHECK-LD32-NOT: warning: -// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" -// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-NOT: "-bnso" -// CHECK-LD32: "-b32" -// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" -// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" -// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" -// CHECK-LD32: "-lc" +// CHECK-LD32: "-b32" +// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" +// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" +// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" +// CHECK-LD32: "-lc" // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target powerpc64-ibm-aix7.1.0.0 \ -// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ +// RUN:-target powerpc64-ibm-aix7.1.0.0 \ +// RUN:--sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD64 %s // CHECK-LD64-NOT: warning: -// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" -// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" // CHECK-LD64-NOT: "-bnso" -// CHECK-LD64: "-b64" -// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" -// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o" -// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" -// CHECK-LD64: "-lc" +// CHECK-LD64: "-b64" +// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" +// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o" +// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" +// CHECK-LD64: "-lc" // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support. -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -pthread \ -// RUN: -target powerpc-ibm-aix7.1.0.0 \ -// RUN: --sysroot %S/Inputs/aix_ppc_tree \ +// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \ +// RUN:-pthread \ +// RUN:-target powerpc-ibm-aix7.1.0.0 \ +// RUN:--sysroot %S/Inputs/aix_ppc_tree \ // RUN: | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s // CHECK-LD32-PTHREAD-NOT: warning: -// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" -// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" +// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" // CHECK-LD32-PTHREAD-NOT: "-bnso" -// CHECK-LD32-PTHREAD: "-b32" -// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" -// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" -// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib" -// CHECK-L
[clang] ba4afe6 - [AIX] Change the default target CPU to power4 for AIX on Power
Author: Steven Wan Date: 2020-06-03T13:50:26-04:00 New Revision: ba4afe6f7a8453b24ee0b664e40d157d15a54034 URL: https://github.com/llvm/llvm-project/commit/ba4afe6f7a8453b24ee0b664e40d157d15a54034 DIFF: https://github.com/llvm/llvm-project/commit/ba4afe6f7a8453b24ee0b664e40d157d15a54034.diff LOG: [AIX] Change the default target CPU to power4 for AIX on Power Summary: This patch changes the AIX default target CPU to power4 since this is the the lowest arch for the lowest OS level supported. Reviewers: hubert.reinterpretcast, cebowleratibm, daltenty Reviewed By: hubert.reinterpretcast Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80835 Added: clang/test/Driver/aix-mcpu-default.c Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b2c984912154..0ddbfac81b33 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -294,14 +294,18 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T, 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 Darwin) -if (TargetCPUName.empty() && !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 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"; + } } return TargetCPUName; } diff --git a/clang/test/Driver/aix-mcpu-default.c b/clang/test/Driver/aix-mcpu-default.c new file mode 100644 index ..10636abad304 --- /dev/null +++ b/clang/test/Driver/aix-mcpu-default.c @@ -0,0 +1,16 @@ +// Check that the target cpu defaults to power4 on AIX. +// 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" + +// Check that the user is able to overwrite the default with '-mcpu'. +// RUN: %clang -no-canonical-prefixes %s -### -c 2>&1 \ +// RUN:-mcpu=pwr6 \ +// RUN:-target powerpc-ibm-aix \ +// RUN: | FileCheck --check-prefix=CHECK-MCPU-USER %s +// CHECK-MCPU-USER-NOT: warning: +// CHECK-MCPU-USER: {{.*}}clang{{.*}}" "-cc1" +// CHECK-MCPU-USER: "-target-cpu" "pwr6" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 61cd264 - [PowerPC] Do not special case Darwin on PowerPC in target cpu handling
Author: stevewan Date: 2020-06-05T19:55:28-04:00 New Revision: 61cd264068ee77ae4e7a503ecd93f0d9fc6120c8 URL: https://github.com/llvm/llvm-project/commit/61cd264068ee77ae4e7a503ecd93f0d9fc6120c8 DIFF: https://github.com/llvm/llvm-project/commit/61cd264068ee77ae4e7a503ecd93f0d9fc6120c8.diff LOG: [PowerPC] Do not special case Darwin on PowerPC in target cpu handling Summary: This patch removes the special handling for Darwin on PowerPC in the default target cpu handling, because Darwin is no longer supported on the PowerPC platform. Reviewers: hubert.reinterpretcast, daltenty Reviewed By: hubert.reinterpretcast Subscribers: wuzish, nemanjai, shchenz, steven.zhang, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81115 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0ddbfac81b33..7fdb3fdf0009 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -294,19 +294,19 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T, 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
[clang] 5bc644a - Revert "[AIX] Avoid structor alias; die before bad alias codegen"
Author: Jake Egan Date: 2021-05-25T15:07:40-04:00 New Revision: 5bc644aeca8fc6a734308d81781935de26ea4cde URL: https://github.com/llvm/llvm-project/commit/5bc644aeca8fc6a734308d81781935de26ea4cde DIFF: https://github.com/llvm/llvm-project/commit/5bc644aeca8fc6a734308d81781935de26ea4cde.diff LOG: Revert "[AIX] Avoid structor alias; die before bad alias codegen" Avoiding structor alias is no longer needed because AIX now has an alias implementation here: https://reviews.llvm.org/D83252. This reverts commit b116ded57da3530e661f871f4191c59cd9e091cd. Reviewed By: jasonliu Differential Revision: https://reviews.llvm.org/D102724 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/aix-constructor-alias.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 677e2b635354..6ded23b316c8 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5028,10 +5028,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // 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 diff --git a/clang/test/Driver/aix-constructor-alias.c b/clang/test/Driver/aix-constructor-alias.c index 18c5f5b5b877..0f53dee2be67 100644 --- a/clang/test/Driver/aix-constructor-alias.c +++ b/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" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a919165 - [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__
Author: Steven Wan Date: 2021-08-05T18:18:58-04:00 New Revision: a91916500d67155ca17bfdf3294541f871f90a45 URL: https://github.com/llvm/llvm-project/commit/a91916500d67155ca17bfdf3294541f871f90a45 DIFF: https://github.com/llvm/llvm-project/commit/a91916500d67155ca17bfdf3294541f871f90a45.diff LOG: [AIX] "aligned" attribute should not decrease type alignment returned by __alignof__ `__alignof__(x)` always returns `ABIAlign` if the "x" 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. Reviewed By: sfertile Differential Revision: https://reviews.llvm.org/D107598 Added: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp Modified: clang/lib/AST/ASTContext.cpp Removed: diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4ff2aa5307bbe..4c9dc42c5b5dd 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2478,11 +2478,16 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const { 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; diff --git a/clang/test/Layout/aix-alignof-align-and-pack-attr.cpp b/clang/test/Layout/aix-alignof-align-and-pack-attr.cpp new file mode 100644 index 0..51f3c5a2adc11 --- /dev/null +++ b/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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 52f3467 - [AIX] Add _AIX73 version macro
Author: Jake Egan Date: 2021-07-05T16:28:48-04:00 New Revision: 52f34673ead32e6818d337207661597de52b9808 URL: https://github.com/llvm/llvm-project/commit/52f34673ead32e6818d337207661597de52b9808 DIFF: https://github.com/llvm/llvm-project/commit/52f34673ead32e6818d337207661597de52b9808.diff LOG: [AIX] Add _AIX73 version macro This patch defines _AIX73 version macro for AIX 7.3. It extends the following patch https://reviews.llvm.org/D61530. Reviewed By: xgupta Differential Revision: https://reviews.llvm.org/D105185 Added: Modified: clang/lib/Basic/Targets/OSTargets.h clang/test/Preprocessor/init-ppc.c Removed: diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 335ca5635642c..fd1b15c512a2f 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -700,6 +700,7 @@ class AIXTargetInfo : public OSTargetInfo { if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61"); if (OsVersion >= std::make_pair(7, 1)) Builder.defineMacro("_AIX71"); if (OsVersion >= std::make_pair(7, 2)) Builder.defineMacro("_AIX72"); +if (OsVersion >= std::make_pair(7, 3)) Builder.defineMacro("_AIX73"); // FIXME: Do not define _LONG_LONG when -fno-long-long is specified. Builder.defineMacro("_LONG_LONG"); diff --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c index 5301c7e3f59df..f59edd119ab0b 100644 --- a/clang/test/Preprocessor/init-ppc.c +++ b/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 _AI
[clang] 9964b0e - [clang] Add -fdump-record-layouts-canonical option
Author: David Tenty Date: 2021-07-05T17:35:37-04:00 New Revision: 9964b0ef828b685dc575a50f75bb1780b84b95c8 URL: https://github.com/llvm/llvm-project/commit/9964b0ef828b685dc575a50f75bb1780b84b95c8 DIFF: https://github.com/llvm/llvm-project/commit/9964b0ef828b685dc575a50f75bb1780b84b95c8.diff LOG: [clang] Add -fdump-record-layouts-canonical option This option implies -fdump-record-layouts but dumps record layout information with canonical field types, which can be more useful in certain cases when comparing structure layouts. Reviewed By: stevewan Differential Revision: https://reviews.llvm.org/D105112 Added: clang/test/Layout/dump-canonical.cpp Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/lib/AST/RecordLayoutBuilder.cpp Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index b18e957a58f4c..8420a97376c38 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -269,6 +269,7 @@ BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info") 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") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 41b7299b02745..c2b21d9851241 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5405,13 +5405,16 @@ def stats_file : Joined<["-"], "stats-file=">, 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>; diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index beb111e2e9718..6ee4178248b92 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -3577,7 +3577,10 @@ static void DumpRecordLayout(raw_ostream &OS, const RecordDecl *RD, } else { PrintOffset(OS, FieldOffset, IndentLevel); } -OS << Field.getType().getAsString() << ' ' << Field << '\n'; +const QualType &FieldType = C.getLangOpts().DumpRecordLayoutsCanonical +? Field.getType().getCanonicalType() +: Field.getType(); +OS << FieldType.getAsString() << ' ' << Field << '\n'; } // Dump virtual bases. diff --git a/clang/test/Layout/dump-canonical.cpp b/clang/test/Layout/dump-canonical.cpp new file mode 100644 index 0..c7216169efdd9 --- /dev/null +++ b/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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e2904c8 - [clang] unbreak Index/preamble-reparse-changed-module.m with LLVM_APPEND_VC_REV=NO after 9964b0e
Author: Steven Wan Date: 2021-07-05T19:51:00-04:00 New Revision: e2904c8e0fa901adeefe579297cb2ece2757fb18 URL: https://github.com/llvm/llvm-project/commit/e2904c8e0fa901adeefe579297cb2ece2757fb18 DIFF: https://github.com/llvm/llvm-project/commit/e2904c8e0fa901adeefe579297cb2ece2757fb18.diff LOG: [clang] unbreak Index/preamble-reparse-changed-module.m with LLVM_APPEND_VC_REV=NO after 9964b0e See revision b8b7a9d for prior art. Added: Modified: clang/include/clang/Serialization/ASTBitCodes.h Removed: diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 8edf43da84b90..ca8ffc746612d 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -41,7 +41,7 @@ namespace serialization { /// Version 4 of AST files also requires that the version control branch and /// revision match exactly, since there is no backward compatibility of /// AST files at this time. -const unsigned VERSION_MAJOR = 14; +const unsigned VERSION_MAJOR = 15; /// AST file minor version number supported by this version of /// Clang. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 045872f - [AIX] Define __TOS_AIX__ predefined macro
Author: Jake Egan Date: 2021-07-06T14:15:35-04:00 New Revision: 045872f42203223450c96a518b6478d255a5d586 URL: https://github.com/llvm/llvm-project/commit/045872f42203223450c96a518b6478d255a5d586 DIFF: https://github.com/llvm/llvm-project/commit/045872f42203223450c96a518b6478d255a5d586.diff LOG: [AIX] Define __TOS_AIX__ predefined macro %%% Transfer the predefined macro, __TOS_AIX__, from the AIX XL C/C++ compilers. __TOS_AIX__ indicates that the target operating system is AIX. %%% Reviewed By: cebowleratibm Differential Revision: https://reviews.llvm.org/D103587 Added: Modified: clang/lib/Basic/Targets/OSTargets.h clang/test/Preprocessor/init-ppc.c Removed: diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index fd1b15c512a2f..31f8b4bea30d9 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -675,6 +675,7 @@ class AIXTargetInfo : public OSTargetInfo { Builder.defineMacro("_POWER"); Builder.defineMacro("_AIX"); +Builder.defineMacro("__TOS_AIX__"); if (Opts.C11) { Builder.defineMacro("__STDC_NO_ATOMICS__"); diff --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c index f59edd119ab0b..4803a8511c7ed 100644 --- a/clang/test/Preprocessor/init-ppc.c +++ b/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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 798fe3c - [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign.
Author: Steven Wan Date: 2021-07-12T15:31:15-04:00 New Revision: 798fe3c774a1af75c8735933ded749fa62f39594 URL: https://github.com/llvm/llvm-project/commit/798fe3c774a1af75c8735933ded749fa62f39594 DIFF: https://github.com/llvm/llvm-project/commit/798fe3c774a1af75c8735933ded749fa62f39594.diff LOG: [PowerPC][AIX] Fix Zero-width bit fields wrt MaxFieldAlign. On AIX when there is a pragma pack, or pragma align in effect then zero-width bitfields should pad out to the end of the bitfield container but not increase the alignment requirements of the struct greater then the max field align. Reviewed By: ZarkoCA Differential Revision: https://reviews.llvm.org/D105635 Added: clang/test/Layout/aix-packed-bitfields.c Modified: clang/lib/AST/RecordLayoutBuilder.cpp clang/test/Layout/aix-bitfield-alignment.c Removed: diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 6ee4178248b92..972690becf9ec 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1775,6 +1775,12 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { !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 diff erences in layout due to padding or packing. if (!UseExternalLayout) CheckFieldPadding(FieldOffset, UnpaddedFieldOffset, UnpackedFieldOffset, diff --git a/clang/test/Layout/aix-bitfield-alignment.c b/clang/test/Layout/aix-bitfield-alignment.c index a736695cc6030..d47b3d7a0c7d8 100644 --- a/clang/test/Layout/aix-bitfield-alignment.c +++ b/clang/test/Layout/aix-bitfield-alignment.c @@ -232,3 +232,37 @@ int s = sizeof(G); // 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 diff --git a/clang/test/Layout/aix-packed-bitfields.c b/clang/test/Layout/aix-packed-bitfields.c new file mode 100644 index 0..9bc907af0f596 --- /dev/null +++ b/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:
[clang] 42102bc - [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF support.
Author: Steven Wan Date: 2021-11-11T14:10:42-05:00 New Revision: 42102bce98e527f994a7bc68b2255d9e0462f6eb URL: https://github.com/llvm/llvm-project/commit/42102bce98e527f994a7bc68b2255d9e0462f6eb DIFF: https://github.com/llvm/llvm-project/commit/42102bce98e527f994a7bc68b2255d9e0462f6eb.diff LOG: [AIX][NFC] Disable clang-repl tests failing due to lack of 64-bit XCOFF support. 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 for the time being. Reviewed By: Jake-Egan Differential Revision: https://reviews.llvm.org/D113614 Added: Modified: clang/unittests/Interpreter/InterpreterTest.cpp Removed: diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index 0f02935b533b4..742aa49763577 100644 --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -145,7 +145,11 @@ struct LLVMInitRAII { ~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 @@ static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) { 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
[clang] 0b274ed - [AIX] Update default arch on AIX
Author: Steven Wan Date: 2021-03-03T19:07:43-05:00 New Revision: 0b274ed499603d30694c0b995252ab014609acf9 URL: https://github.com/llvm/llvm-project/commit/0b274ed499603d30694c0b995252ab014609acf9 DIFF: https://github.com/llvm/llvm-project/commit/0b274ed499603d30694c0b995252ab014609acf9.diff LOG: [AIX] Update default arch on AIX On AIX, the default arch level should match the minimum supported arch level of the OS version. Differential Revision: https://reviews.llvm.org/D97823 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/aix-mcpu-default.c Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 9471639350af..46a0fc67ced0 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -399,9 +399,14 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T, 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"; diff --git a/clang/test/Driver/aix-mcpu-default.c b/clang/test/Driver/aix-mcpu-default.c index 10636abad304..7b55839a8066 100644 --- a/clang/test/Driver/aix-mcpu-default.c +++ b/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 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 06d4a76 - [NFC][AIX]Disable precompiled module file tests on AIX
Author: Steven Wan Date: 2021-11-24T13:22:09-05:00 New Revision: 06d4a76309cd97e25859770b3da29006ccac421a URL: https://github.com/llvm/llvm-project/commit/06d4a76309cd97e25859770b3da29006ccac421a DIFF: https://github.com/llvm/llvm-project/commit/06d4a76309cd97e25859770b3da29006ccac421a.diff LOG: [NFC][AIX]Disable precompiled module file tests on AIX 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. Reviewed By: daltenty Differential Revision: https://reviews.llvm.org/D114481 Added: Modified: 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 Removed: diff --git a/clang/test/ClangScanDeps/modules-pch-common-submodule.c b/clang/test/ClangScanDeps/modules-pch-common-submodule.c index 0189ab346ac01..c7f3e76cf0a15 100644 --- a/clang/test/ClangScanDeps/modules-pch-common-submodule.c +++ b/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 diff --git a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c index 3d35ede3b67c9..e63e310b22d09 100644 --- a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c +++ b/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. diff --git a/clang/test/ClangScanDeps/modules-pch.c b/clang/test/ClangScanDeps/modules-pch.c index 755ddeea67c56..2be17743a64b9 100644 --- a/clang/test/ClangScanDeps/modules-pch.c +++ b/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 diff --git a/clang/test/PCH/debug-info-pch-path.c b/clang/test/PCH/debug-info-pch-path.c index 272d9ac1ab7cf..192d5c79d4819 100644 --- a/clang/test/PCH/debug-info-pch-path.c +++ b/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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 23dc886 - [NFC][AIX]Disable unsupported hip test on AIX
Author: Steven Wan Date: 2021-11-29T13:26:26-05:00 New Revision: 23dc886226306d961c31987db9aad137a69ad539 URL: https://github.com/llvm/llvm-project/commit/23dc886226306d961c31987db9aad137a69ad539 DIFF: https://github.com/llvm/llvm-project/commit/23dc886226306d961c31987db9aad137a69ad539.diff LOG: [NFC][AIX]Disable unsupported hip test on AIX AIX doesn't support GPU. There is no point testing HIP on it. Reviewed By: Jake-Egan Differential Revision: https://reviews.llvm.org/D114484 Added: Modified: clang/test/Driver/hip-version.hip Removed: diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip index 83b8dbddf228c..af98e025a 100644 --- a/clang/test/Driver/hip-version.hip +++ b/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
[clang] 3c32c56 - [NFC][clang]Increase the number of driver diagnostics
Author: Steven Wan Date: 2021-11-29T14:12:03-05:00 New Revision: 3c32c568844c745e3fe7fa72ce3aa65340e545bc URL: https://github.com/llvm/llvm-project/commit/3c32c568844c745e3fe7fa72ce3aa65340e545bc DIFF: https://github.com/llvm/llvm-project/commit/3c32c568844c745e3fe7fa72ce3aa65340e545bc.diff LOG: [NFC][clang]Increase the number of driver diagnostics We're close to hitting the limited number of driver diagnostics, increase `DIAG_SIZE_DRIVER` to accommodate more. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D114615 Added: Modified: clang/include/clang/Basic/DiagnosticIDs.h Removed: diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h index aef86516707c..375930c14848 100644 --- a/clang/include/clang/Basic/DiagnosticIDs.h +++ b/clang/include/clang/Basic/DiagnosticIDs.h @@ -30,7 +30,7 @@ namespace clang { // 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
[clang] 5e37fb1 - [NFC] Delete extra white space in a test case.
Author: Steven Wan Date: 2020-02-11T16:00:59-05:00 New Revision: 5e37fb1776de2698c10db697e3c479d0e94234e0 URL: https://github.com/llvm/llvm-project/commit/5e37fb1776de2698c10db697e3c479d0e94234e0 DIFF: https://github.com/llvm/llvm-project/commit/5e37fb1776de2698c10db697e3c479d0e94234e0.diff LOG: [NFC] Delete extra white space in a test case. Remove an extra empty line in one of the AIX driver test cases. Added: Modified: clang/test/Driver/aix-as.c Removed: diff --git a/clang/test/Driver/aix-as.c b/clang/test/Driver/aix-as.c index 4f67d1ba90b7..cb3053f5acd3 100644 --- a/clang/test/Driver/aix-as.c +++ b/clang/test/Driver/aix-as.c @@ -23,7 +23,6 @@ // CHECK-AS64: "-u" // CHECK-AS64: "-many" - // Check powerpc-ibm-aix7.1.0.0, 32-bit. -Xassembler option. // RUN: %clang -no-canonical-prefixes %s -### -c -o %t.o 2>&1 \ // RUN: -Xassembler -w \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 760e692 - [NFC][AIX]Disable new pcm tests on AIX
Author: Steven Wan Date: 2022-01-28T12:39:09-05:00 New Revision: 760e69223d83860ed4758f86a0de4686a8d51fd7 URL: https://github.com/llvm/llvm-project/commit/760e69223d83860ed4758f86a0de4686a8d51fd7 DIFF: https://github.com/llvm/llvm-project/commit/760e69223d83860ed4758f86a0de4686a8d51fd7.diff LOG: [NFC][AIX]Disable new pcm tests on AIX 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. Reviewed By: Jake-Egan, daltenty, sfertile Differential Revision: https://reviews.llvm.org/D118477 Added: Modified: clang/test/ClangScanDeps/modules-symlink.c Removed: diff --git a/clang/test/ClangScanDeps/modules-symlink.c b/clang/test/ClangScanDeps/modules-symlink.c index 46831b0a3fc00..5b628175560d2 100644 --- a/clang/test/ClangScanDeps/modules-symlink.c +++ b/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
[clang] 245b8e5 - [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX
Author: Steven Wan Date: 2022-02-01T11:49:53-05:00 New Revision: 245b8e5691ed9e4483b3e0f807706fe1fb6eaa38 URL: https://github.com/llvm/llvm-project/commit/245b8e5691ed9e4483b3e0f807706fe1fb6eaa38 DIFF: https://github.com/llvm/llvm-project/commit/245b8e5691ed9e4483b3e0f807706fe1fb6eaa38.diff LOG: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX 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. Differential Revision: https://reviews.llvm.org/D118670 Added: Modified: clang/test/Analysis/padding_c.c clang/test/Analysis/padding_cpp.cpp clang/test/CXX/drs/dr6xx.cpp clang/test/SemaTemplate/instantiate-attr.cpp Removed: diff --git a/clang/test/Analysis/padding_c.c b/clang/test/Analysis/padding_c.c index 98d3ab1a3e1f1..e01bb7ef73c04 100644 --- a/clang/test/Analysis/padding_c.c +++ b/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 \ diff --git a/clang/test/Analysis/padding_cpp.cpp b/clang/test/Analysis/padding_cpp.cpp index f0e8beacda763..3d4055a3ae472 100644 --- a/clang/test/Analysis/padding_cpp.cpp +++ b/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" diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp index ad87c7295cfe8..a9c2ddbf47840 100644 --- a/clang/test/CXX/drs/dr6xx.cpp +++ b/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 {}; diff --git a/clang/test/SemaTemplate/instantiate-attr.cpp b/clang/test/SemaTemplate/instantiate-attr.cpp index 1e94614f371da..8cd0b335ffbdd 100644 --- a/clang/test/SemaTemplate/instantiate-attr.cpp +++ b/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 { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 73733ae - TypeInfo records more information about align requirement
Author: Steven Wan Date: 2021-08-28T19:47:48-04:00 New Revision: 73733ae526a5152e5427973ac12dc54f7dd243fb URL: https://github.com/llvm/llvm-project/commit/73733ae526a5152e5427973ac12dc54f7dd243fb DIFF: https://github.com/llvm/llvm-project/commit/73733ae526a5152e5427973ac12dc54f7dd243fb.diff LOG: TypeInfo records more information about align requirement 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. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D108858 Added: Modified: 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 Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index da372e854700b..5004cb6cb2671 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -164,24 +164,46 @@ namespace serialization { template class AbstractTypeReader; } // namespace serialization +enum class AlignRequirementKind { + /// 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, + + /// The alignment comes from an alignment attribute on a enum type. + RequiredByEnum, +}; + struct TypeInfo { uint64_t Width = 0; unsigned Align = 0; - bool AlignIsRequired : 1; + AlignRequirementKind AlignRequirement; - TypeInfo() : AlignIsRequired(false) {} - TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired) - : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} + TypeInfo() : AlignRequirement(AlignRequirementKind::None) {} + TypeInfo(uint64_t Width, unsigned Align, + AlignRequirementKind AlignRequirement) + : Width(Width), Align(Align), AlignRequirement(AlignRequirement) {} + bool isAlignRequired() { +return AlignRequirement != AlignRequirementKind::None; + } }; struct TypeInfoChars { CharUnits Width; CharUnits Align; - bool AlignIsRequired : 1; + AlignRequirementKind AlignRequirement; - TypeInfoChars() : AlignIsRequired(false) {} - TypeInfoChars(CharUnits Width, CharUnits Align, bool AlignIsRequired) - : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} + TypeInfoChars() : AlignRequirement(AlignRequirementKind::None) {} + TypeInfoChars(CharUnits Width, CharUnits Align, +AlignRequirementKind AlignRequirement) + : Width(Width), Align(Align), AlignRequirement(AlignRequirement) {} + bool isAlignRequired() { +return AlignRequirement != AlignRequirementKind::None; + } }; /// Holds long-lived AST nodes (such as types and decls) that can be diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 12b5d14f35c63..41dd9f7e3330b 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1858,7 +1858,7 @@ static getConstantArrayInfoInChars(const ASTContext &Context, 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 @@ TypeInfoChars ASTContext::getTypeInfoInChars(const Type *T) const { return getConstantArrayInfoInChars(*this, CAT); TypeInfo Info = getTypeInfo(T); return TypeInfoChars(toCharUnitsFromBits(Info.Width), - toCharUnitsFromBits(Info.Align), - Info.AlignIsRequired); + toCharUnitsFromBits(Info.Align), Info.AlignRequirement); } TypeInfoChars ASTContext::getTypeInfoInChars(QualType T) const { @@ -1875,7 +1874,7 @@ TypeInfoChars ASTContext::getTypeInfoInChars(QualType T) const { } bool ASTContext::isAlignmentRequired(const Type *T) const { - return getTypeInfo(T).AlignIsRequired; + return getTypeInfo(T).AlignRequirement != AlignRequirementKind::None; } bool ASTContext::isAlignmentRequired(QualType T) const { @@ -1927,7 +1926,7 @@ TypeInfo ASTContext::getTypeInfo(const Type *T) const { TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { uint64_t Width = 0; unsigned Align = 8; - bool AlignIsRequired = false; + AlignRequirementKind AlignRequirement = AlignRequirementKind::None; unsigned AS = 0; switch (T->getTypeClass()) { #define TYPE(Class, Base) @@ -1961,7 +1960,7 @@ TypeIn
[clang] 71b170c - [AIX] "aligned" attribute does not decrease alignment
Author: Steven Wan Date: 2021-08-29T21:33:05-04:00 New Revision: 71b170ccf36ee02e6a4c472bc1d3e89bbaf0e2b4 URL: https://github.com/llvm/llvm-project/commit/71b170ccf36ee02e6a4c472bc1d3e89bbaf0e2b4 DIFF: https://github.com/llvm/llvm-project/commit/71b170ccf36ee02e6a4c472bc1d3e89bbaf0e2b4.diff LOG: [AIX] "aligned" attribute does not decrease alignment 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. That said, we expect: 1. "aligned" attribute alone: does not interfere with the alignment upgrade instrumented by the AIX "power" alignment rule, 2. "aligned" attribute + typedef: overrides any computed alignment, 3. "aligned" attribute + "packed" attribute: overrides any computed alignment. The old implementation achieved 2 and 3, but didn't get 1 right, in that any field marked attribute "aligned" would not go through the alignment upgrade. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D107394 Added: clang/test/Layout/aix-type-align-and-pack-attr.cpp Modified: clang/lib/AST/RecordLayoutBuilder.cpp clang/test/Layout/aix-power-alignment-typedef.cpp Removed: clang/test/Layout/aix-alignof-align-and-pack-attr.cpp diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 30e88da9ac4f5..5c86b06da835e 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1968,6 +1968,19 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, } } + // 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 == AlignRequirementKind::RequiredByTypedef || + (AlignRequirement == AlignRequirementKind::RequiredByRecord && +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,8 +1991,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, // 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 && - AlignRequirement == AlignRequirementKind::None && + if (DefaultsToAIXPowerAlignment && !alignedAttrCanDecreaseAIXAlignment() && (FoundFirstNonOverlappingEmptyFieldForAIX || IsNaturalAlign)) { auto performBuiltinTypeAlignmentUpgrade = [&](const BuiltinType *BTy) { if (BTy->getKind() == BuiltinType::Double || @@ -1990,12 +2002,13 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, } }; -const Type *Ty = D->getType()->getBaseElementTypeUnsafe(); -if (const ComplexType *CTy = Ty->getAs()) { - performBuiltinTypeAlignmentUpgrade(CTy->getElementType()->castAs()); -} else if (const BuiltinType *BTy = Ty->getAs()) { +const Type *BaseTy = D->getType()->getBaseElementTypeUnsafe(); +if (const ComplexType *CTy = BaseTy->getAs()) { + performBuiltinTypeAlignmentUpgrade( + CTy->getElementType()->castAs()); +} else if (const BuiltinType *BTy = BaseTy->getAs()) { performBuiltinTypeAlignmentUpgrade(BTy); -} else if (const RecordType *RT = Ty->getAs()) { +} else if (const RecordType *RT = BaseTy->getAs()) { const RecordDecl *RD = RT->getDecl(); assert(RD && "Expected non-null RecordDecl."); const ASTRecordLayout &FieldRecord = Context.getASTRecordLayout(RD); diff --git a/clang/test/Layout/aix-alignof-align-and-pack-attr.cpp b/clang/test/Layout/aix-alignof-align-and-pack-attr.cpp deleted file mode 100644 index 51f3c5a2adc11..0 --- a/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.t
[clang] 806ff3c - [AIX] Check for typedef properly when getting preferred type align
Author: Steven Wan Date: 2021-09-08T16:21:52-04:00 New Revision: 806ff3c4a42c7393a0bbeab3dd1c0295f61ad457 URL: https://github.com/llvm/llvm-project/commit/806ff3c4a42c7393a0bbeab3dd1c0295f61ad457 DIFF: https://github.com/llvm/llvm-project/commit/806ff3c4a42c7393a0bbeab3dd1c0295f61ad457.diff LOG: [AIX] Check for typedef properly when getting preferred type align 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. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D109387 Added: Modified: clang/lib/AST/ASTContext.cpp clang/test/Layout/aix-power-alignment-typedef-2.cpp Removed: diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index dc19dd6959049..74af9f869d084 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2497,8 +2497,10 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const { 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; diff --git a/clang/test/Layout/aix-power-alignment-typedef-2.cpp b/clang/test/Layout/aix-power-alignment-typedef-2.cpp index 8e7e3db47c602..b814be9c06cff 100644 --- a/clang/test/Layout/aix-power-alignment-typedef-2.cpp +++ b/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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits