[clang] 69f3378 - [AIX]Generate debug info for static init related functions
Author: Xiangling Liao Date: 2020-07-16T10:43:10-04:00 New Revision: 69f3378ad65b41c979acc1bcb4968d2247e6adf7 URL: https://github.com/llvm/llvm-project/commit/69f3378ad65b41c979acc1bcb4968d2247e6adf7 DIFF: https://github.com/llvm/llvm-project/commit/69f3378ad65b41c979acc1bcb4968d2247e6adf7.diff LOG: [AIX]Generate debug info for static init related functions Set the debug location for static init related functions(__dtor and __finalize) so we can generate valid debug info on AIX by invoking -g with clang or -debug-info-kind=limited with clang_cc1. This also works for any other future targets who may use sinit and sterm functions for static initialization, where a direct call to dtor will be generated within finalize function body. This patch also aims at validating that the debug info generated is correct for AIX sinit related functions. Differential Revision: https://reviews.llvm.org/D83702 Added: clang/test/CodeGenCXX/aix-static-init-debug-info.cpp Modified: clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp Removed: diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 5a8500364295..4e941021daa3 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -246,7 +246,8 @@ llvm::Function *CodeGenFunction::createAtExitStub(const VarDecl &VD, CodeGenFunction CGF(CGM); CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit), -CGM.getContext().VoidTy, fn, FI, FunctionArgList()); +CGM.getContext().VoidTy, fn, FI, FunctionArgList(), +VD.getLocation(), VD.getInit()->getExprLoc()); llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr); diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 80de2a6e3950..12d00c7d59a3 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -4567,7 +4567,8 @@ void XLCXXABI::emitCXXStermFinalizer(const VarDecl &D, llvm::Function *dtorStub, CodeGenFunction CGF(CGM); CGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, StermFinalizer, FI, -FunctionArgList()); +FunctionArgList(), D.getLocation(), +D.getInit()->getExprLoc()); // The unatexit subroutine unregisters __dtor functions that were previously // registered by the atexit subroutine. If the referenced function is found, diff --git a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp new file mode 100644 index ..39de0cdd513a --- /dev/null +++ b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -x c++ \ +// RUN: -debug-info-kind=limited < %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s + +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm -x c++ \ +// RUN: -debug-info-kind=limited < %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s + +struct X { + X(); + ~X(); +}; + +X v; + +// CHECK: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]+]] !dbg ![[DBGVAR16:[0-9]+]] { +// CHECK: entry: +// CHECK: call void @_ZN1XC1Ev(%struct.X* @v), !dbg ![[DBGVAR19:[0-9]+]] +// CHECK: %0 = call i32 @atexit(void ()* @__dtor_v) [[ATTR:#[0-9]+]], !dbg ![[DBGVAR19]] +// CHECK: ret void, !dbg ![[DBGVAR19]] +// CHECK: } + +// CHECK: define internal void @__dtor_v() [[ATTR:#[0-9]+]] !dbg ![[DBGVAR20:[0-9]+]] { +// CHECK: entry: +// CHECK: call void @_ZN1XD1Ev(%struct.X* @v), !dbg ![[DBGVAR21:[0-9]+]] +// CHECK: ret void, !dbg ![[DBGVAR21]] +// CHECK: } + +// CHECK: define internal void @__finalize_v() [[ATTR:#[0-9]+]] !dbg ![[DBGVAR22:[0-9]+]] { +// CHECK: entry: +// CHECK: %0 = call i32 @unatexit(void ()* @__dtor_v) [[ATTR:#[0-9]+]], !dbg ![[DBGVAR24:[0-9]+]] +// CHECK: %needs_destruct = icmp eq i32 %0, 0, !dbg ![[DBGVAR24]] +// CHECK: br i1 %needs_destruct, label %destruct.call, label %destruct.end, !dbg ![[DBGVAR24]] + +// CHECK: destruct.call: +// CHECK: call void @__dtor_v(), !dbg ![[DBGVAR24]] +// CHECK: br label %destruct.end, !dbg ![[DBGVAR24]] + +// CHECK: destruct.end: +// CHECK: ret void, !dbg ![[DBGVAR24]] +// CHECK: } + +// CHECK: define void @__sinit8000_clang_c3236cbaa79f2bae3a15e6379a05f625() [[ATTR:#[0-9]+]] !dbg ![[DBGVAR25:[0-9]+]] { +// CHECK: entry: +// CHECK: call void @__cxx_global_var_init(), !dbg ![[DBGVAR26:[0-9]+]] +// CHECK: ret void +// CHECK: } + +// CHECK: define void @__sterm8000_clang_c3236cbaa79f2bae3a15e6379a05f625() [[ATTR:#[0-9]+]] !dbg ![[DBGVAR27:[0-9]+]] { +// CHECK: entry: +// CHECK: call void @__finalize_v(), !dbg ![[DBGVAR28:[0-9]+]] +// CHECK: ret void +// CHECK: } + +// CHECK: ![[DBGVAR16]] = distinct !DISubprogram(name: "__cxx_global_v
[clang] ec6ada6 - [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init
Author: Xiangling Liao Date: 2020-07-17T16:14:49-04:00 New Revision: ec6ada62643cf7cded8160e04cce163323112ade URL: https://github.com/llvm/llvm-project/commit/ec6ada62643cf7cded8160e04cce163323112ade DIFF: https://github.com/llvm/llvm-project/commit/ec6ada62643cf7cded8160e04cce163323112ade.diff LOG: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init On AIX, the semantic of global_dtors contains __sterm functions associated with C++ cleanup actions and user-declared __attribute__((destructor)) functions. We should never merely register __sterm with atexit(), so currently -fregister_global_dtors_with_atexit does not work well on AIX: It would cause finalization actions to not occur when unloading shared libraries. We need to figure out a way to handle that when we start supporting user-declared __attribute__((destructor)) functions. Currently we report_fatal_error on this option temporarily. Differential Revision: https://reviews.llvm.org/D83974 Added: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/test/Driver/cxa-atexit.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4ae8ce7e5ccf..4c792520b5f3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1209,6 +1209,9 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, /// when the module is unloaded. void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) { +if (getCXXABI().useSinitAndSterm()) + llvm::report_fatal_error( + "register global dtors with atexit() is not supported yet"); DtorsUsingAtExit[Priority].push_back(Dtor); return; } diff --git a/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp new file mode 100644 index ..4cec83d461ad --- /dev/null +++ b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp @@ -0,0 +1,14 @@ +// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \ +// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \ +// RUN: FileCheck %s + +// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \ +// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \ +// RUN: FileCheck %s + +struct T { + T(); + ~T(); +} t; + +// CHECK: error in backend: register global dtors with atexit() is not supported yet diff --git a/clang/test/Driver/cxa-atexit.cpp b/clang/test/Driver/cxa-atexit.cpp index e81af6cd5963..537a11a35f51 100644 --- a/clang/test/Driver/cxa-atexit.cpp +++ b/clang/test/Driver/cxa-atexit.cpp @@ -36,6 +36,7 @@ // RUN: FileCheck --check-prefix=WITHATEXIT %s // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s + // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s // RUN: %clang -target x86_64-pc-linux-gnu -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ @@ -43,5 +44,18 @@ // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s + // WITHATEXIT: -fregister-global-dtors-with-atexit // WITHOUTATEXIT-NOT: -fregister-global-dtors-with-atexit ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 05ad8e9 - [AIX] Implement AIX special alignment rule about double/long double
Author: Xiangling Liao Date: 2020-07-27T15:13:03-04:00 New Revision: 05ad8e942996f36cc694478542ccd84aa5bbb80f URL: https://github.com/llvm/llvm-project/commit/05ad8e942996f36cc694478542ccd84aa5bbb80f DIFF: https://github.com/llvm/llvm-project/commit/05ad8e942996f36cc694478542ccd84aa5bbb80f.diff LOG: [AIX] Implement AIX special alignment rule about double/long double Implement AIX default `power` alignment rule by adding `PreferredAlignment` and `PreferredNVAlignment` in ASTRecordLayout class. The patchh aims at returning correct value for `__alignof(x)` and `alignof(x)` under `power` alignment rules. Differential Revision: https://reviews.llvm.org/D79719 Added: clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp clang/test/Layout/aix-Wpacked-no-diagnostics.cpp clang/test/Layout/aix-double-struct-member.cpp clang/test/Layout/aix-no-unique-address-with-double.cpp clang/test/Layout/aix-pack-attr-on-base.cpp clang/test/Layout/aix-power-alignment-typedef-2.cpp clang/test/Layout/aix-power-alignment-typedef.cpp clang/test/Layout/aix-virtual-function-and-base-with-double.cpp Modified: clang/include/clang/AST/RecordLayout.h clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/RecordLayout.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/PPC.h Removed: diff --git a/clang/include/clang/AST/RecordLayout.h b/clang/include/clang/AST/RecordLayout.h index b259791af509..946fbd8f4ce2 100644 --- a/clang/include/clang/AST/RecordLayout.h +++ b/clang/include/clang/AST/RecordLayout.h @@ -70,6 +70,11 @@ class ASTRecordLayout { // Alignment - Alignment of record in characters. CharUnits Alignment; + // PreferredAlignment - Preferred alignment of record in characters. This + // can be diff erent than Alignment in cases where it is beneficial for + // performance or backwards compatibility preserving (e.g. AIX-ABI). + CharUnits PreferredAlignment; + // UnadjustedAlignment - Maximum of the alignments of the record members in // characters. CharUnits UnadjustedAlignment; @@ -91,6 +96,11 @@ class ASTRecordLayout { /// which is the alignment of the object without virtual bases. CharUnits NonVirtualAlignment; +/// PreferredNVAlignment - The preferred non-virtual alignment (in chars) of +/// an object, which is the preferred alignment of the object without +/// virtual bases. +CharUnits PreferredNVAlignment; + /// SizeOfLargestEmptySubobject - The size of the largest empty subobject /// (either a base or a member). Will be zero if the class doesn't contain /// any empty subobjects. @@ -139,30 +149,26 @@ class ASTRecordLayout { CXXRecordLayoutInfo *CXXInfo = nullptr; ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, - CharUnits unadjustedAlignment, + CharUnits preferredAlignment, CharUnits unadjustedAlignment, CharUnits requiredAlignment, CharUnits datasize, ArrayRef fieldoffsets); using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy; // Constructor for C++ records. - ASTRecordLayout(const ASTContext &Ctx, - CharUnits size, CharUnits alignment, - CharUnits unadjustedAlignment, - CharUnits requiredAlignment, - bool hasOwnVFPtr, bool hasExtendableVFPtr, - CharUnits vbptroffset, - CharUnits datasize, - ArrayRef fieldoffsets, + ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits preferredAlignment, CharUnits unadjustedAlignment, + CharUnits requiredAlignment, bool hasOwnVFPtr, + bool hasExtendableVFPtr, CharUnits vbptroffset, + CharUnits datasize, ArrayRef fieldoffsets, CharUnits nonvirtualsize, CharUnits nonvirtualalignment, + CharUnits preferrednvalignment, CharUnits SizeOfLargestEmptySubobject, - const CXXRecordDecl *PrimaryBase, - bool IsPrimaryBaseVirtual, + const CXXRecordDecl *PrimaryBase, bool IsPrimaryBaseVirtual, const CXXRecordDecl *BaseSharingVBPtr, - bool EndsWithZeroSizedObject, - bool LeadsWithZeroSizedBase, - const BaseOffsetsMapTy& BaseOffsets, - const VBaseOffsetsMapTy& VBaseOffsets); + bool EndsWithZeroSizedObject, bool LeadsWithZeroSizedBase, + const BaseOffsetsMapTy &BaseOffsets, + const VBaseOffsetsMapTy &VBaseOffsets); ~ASTRecordLayout() = default; @@ -175,6 +181,10 @@ class ASTRecordLayout { /// getAlignment - Get th
[clang] 4e6176f - [AIX] Temporarily disable IncrementalProcessingTest partially
Author: Xiangling Liao Date: 2020-07-30T10:41:52-04:00 New Revision: 4e6176fd912a68de0764fff43a129a73f5cab800 URL: https://github.com/llvm/llvm-project/commit/4e6176fd912a68de0764fff43a129a73f5cab800 DIFF: https://github.com/llvm/llvm-project/commit/4e6176fd912a68de0764fff43a129a73f5cab800.diff LOG: [AIX] Temporarily disable IncrementalProcessingTest partially Temporarily disable IncrementalProcessingTest partially until the static initialization implementation on AIX is recovered. Differential Revision: https://reviews.llvm.org/D84880 Added: Modified: clang/unittests/CodeGen/IncrementalProcessingTest.cpp Removed: diff --git a/clang/unittests/CodeGen/IncrementalProcessingTest.cpp b/clang/unittests/CodeGen/IncrementalProcessingTest.cpp index 045ed9bbc760..d1d921bb03c6 100644 --- a/clang/unittests/CodeGen/IncrementalProcessingTest.cpp +++ b/clang/unittests/CodeGen/IncrementalProcessingTest.cpp @@ -159,6 +159,11 @@ TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) { // First code should not end up in second module: ASSERT_FALSE(M[2]->getFunction("funcForProg1")); +// TODO: Remove this after the static initialization frontend implementation +// is recovered on AIX. +if (compiler.getTarget().getTriple().isOSAIX()) + return; + // Make sure global inits exist and are unique: const Function* GlobalInit1 = getGlobalInit(*M[1]); ASSERT_TRUE(GlobalInit1); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ed1b556 - [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()
Author: Xiangling Liao Date: 2020-06-18T18:49:23-04:00 New Revision: ed1b556954eb2b1bb50db973860b7cf20494ce15 URL: https://github.com/llvm/llvm-project/commit/ed1b556954eb2b1bb50db973860b7cf20494ce15 DIFF: https://github.com/llvm/llvm-project/commit/ed1b556954eb2b1bb50db973860b7cf20494ce15.diff LOG: [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc() Tidy up some code of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc() as the pre-work of D74166 patch. Differential Revision: https://reviews.llvm.org/D81972 Added: Modified: clang/lib/CodeGen/CGDeclCXX.cpp Removed: diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 2a01aff9f0f2..b4a8d551a5ae 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -533,6 +533,22 @@ void CodeGenModule::EmitCXXThreadLocalInitFunc() { CXXThreadLocals.clear(); } +static SmallString<128> getTransformedFileName(llvm::Module &M) { + SmallString<128> FileName = llvm::sys::path::filename(M.getName()); + + if (FileName.empty()) +FileName = ""; + + for (size_t i = 0; i < FileName.size(); ++i) { +// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens +// to be the set of C preprocessing numbers. +if (!isPreprocessingNumberBody(FileName[i])) + FileName[i] = '_'; + } + + return FileName; +} + void CodeGenModule::EmitCXXGlobalInitFunc() { while (!CXXGlobalInits.empty() && !CXXGlobalInits.back()) @@ -577,22 +593,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() { PrioritizedCXXGlobalInits.clear(); } - // Include the filename in the symbol name. Including "sub_" matches gcc and - // makes sure these symbols appear lexicographically behind the symbols with - // priority emitted above. - SmallString<128> FileName = llvm::sys::path::filename(getModule().getName()); - if (FileName.empty()) -FileName = ""; - - for (size_t i = 0; i < FileName.size(); ++i) { -// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens -// to be the set of C preprocessing numbers. -if (!isPreprocessingNumberBody(FileName[i])) - FileName[i] = '_'; - } - + // Include the filename in the symbol name. Including "sub_" matches gcc + // and makes sure these symbols appear lexicographically behind the symbols + // with priority emitted above. llvm::Function *Fn = CreateGlobalInitOrDestructFunction( - FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI); + FTy, + llvm::Twine("_GLOBAL__sub_I_", getTransformedFileName(getModule())), FI); CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits); AddGlobalCtor(Fn); @@ -631,6 +637,7 @@ void CodeGenModule::EmitCXXGlobalDtorFunc() { CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors); AddGlobalDtor(Fn); + CXXGlobalDtors.clear(); } /// Emit the code necessary to initialize the given global variable. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 22337bf - [AIX][Frontend] Static init implementation for AIX considering no priority
Author: Xiangling Liao Date: 2020-06-19T08:27:07-04:00 New Revision: 22337bfe7d87f9bf2b072ec7fe9165f7b9e2d793 URL: https://github.com/llvm/llvm-project/commit/22337bfe7d87f9bf2b072ec7fe9165f7b9e2d793 DIFF: https://github.com/llvm/llvm-project/commit/22337bfe7d87f9bf2b072ec7fe9165f7b9e2d793.diff LOG: [AIX][Frontend] Static init implementation for AIX considering no priority 1. Provides no piroirity supoort && disables three priority related attributes: init_priority, ctor attr, dtor attr; 2. '-qunique' in XL compiler equivalent behavior of emitting sinit and sterm functions name using getUniqueModuleId() util function in LLVM (currently no support for InternalLinkage and WeakODRLinkage symbols); 3. Add testcases to emit IR sample with __sinit8000, __dtor, and __sterm8000; 4. Temporarily side-steps the need to implement the functionality of llvm.global_ctors and llvm.global_dtors arrays. The uses of that functionality in this patch (with respect to the name of the functions involved) are not representative of how the functionality will be used once implemented. Differential Revision: https://reviews.llvm.org/D74166 Added: clang/test/CodeGen/aix-constructor-attribute.cpp clang/test/CodeGen/aix-destructor-attribute.cpp clang/test/CodeGen/aix-init-priority-attribute.cpp clang/test/CodeGenCXX/aix-static-init.cpp Modified: clang/include/clang/AST/Mangle.h clang/lib/AST/ItaniumMangle.cpp clang/lib/CodeGen/CGCXXABI.h clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/CodeGen/MicrosoftCXXABI.cpp clang/lib/Sema/SemaDeclAttr.cpp Removed: clang/test/CodeGen/static-init.cpp diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h index b39a81462efd..011d1faab8ea 100644 --- a/clang/include/clang/AST/Mangle.h +++ b/clang/include/clang/AST/Mangle.h @@ -175,6 +175,8 @@ class ItaniumMangleContext : public MangleContext { virtual void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &) = 0; + virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 0; + bool isUniqueNameMangler() { return IsUniqueNameMangler; } static bool classof(const MangleContext *C) { diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index ad4ecad151f5..ddfbe9f86499 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -160,6 +160,7 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext { void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out) override; void mangleDynamicAtExitDestructor(const VarDecl *D, raw_ostream &Out) override; + void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &Out) override; void mangleSEHFilterExpression(const NamedDecl *EnclosingDecl, raw_ostream &Out) override; void mangleSEHFinallyBlock(const NamedDecl *EnclosingDecl, @@ -5230,6 +5231,18 @@ void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(const VarDecl *D, Mangler.getStream() << D->getName(); } +void ItaniumMangleContextImpl::mangleDynamicStermFinalizer(const VarDecl *D, + raw_ostream &Out) { + // Clang generates these internal-linkage functions as part of its + // implementation of the XL ABI. + CXXNameMangler Mangler(*this, Out); + Mangler.getStream() << "__finalize_"; + if (shouldMangleDeclName(D)) +Mangler.mangle(D); + else +Mangler.getStream() << D->getName(); +} + void ItaniumMangleContextImpl::mangleSEHFilterExpression( const NamedDecl *EnclosingDecl, raw_ostream &Out) { CXXNameMangler Mangler(*this, Out); diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h index f5f378510950..2b7f45fcab98 100644 --- a/clang/lib/CodeGen/CGCXXABI.h +++ b/clang/lib/CodeGen/CGCXXABI.h @@ -108,6 +108,8 @@ class CGCXXABI { virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; } + virtual bool useSinitAndSterm() const { return false; } + /// Returns true if the target allows calling a function through a pointer /// with a diff erent signature than the actual function (or equivalently, /// bitcasting a function or function pointer to a diff erent function type). diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index b4a8d551a5ae..5a8500364295 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/Support/Path.h" +#include "llvm/Transforms/Utils/ModuleUtils.h" using
[clang] 3f2e61c - [AIX] Default AIX to using -fno-use-cxa-atexit
Author: Xiangling Liao Date: 2020-06-19T08:27:07-04:00 New Revision: 3f2e61c1fe42e5b790096d6962f6bc2de6ee00ce URL: https://github.com/llvm/llvm-project/commit/3f2e61c1fe42e5b790096d6962f6bc2de6ee00ce DIFF: https://github.com/llvm/llvm-project/commit/3f2e61c1fe42e5b790096d6962f6bc2de6ee00ce.diff LOG: [AIX] Default AIX to using -fno-use-cxa-atexit On AIX, we use __atexit to register dtor functions rather than __cxa_atexit. So a driver change is needed to default AIX to using -fno-use-cxa-atexit. Windows platform does not uses __cxa_atexit either. Following its precedent, we remove the assertion for when -fuse-cxa-atexit is specified by the user, do not produce a message and silently default to -fno-use-cxa-atexit behavior. Differential Revision: https://reviews.llvm.org/D82136 Added: Modified: clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/CodeGenCXX/aix-static-init.cpp clang/test/Driver/cxa-atexit.cpp Removed: diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 18aff757f7b5..2829877cfe5d 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -4528,8 +4528,6 @@ void XLCXXABI::registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D, // Create __dtor function for the var decl. llvm::Function *dtorStub = CGF.createAtExitStub(D, dtor, addr); - if (CGM.getCodeGenOpts().CXAAtExit) -llvm::report_fatal_error("using __cxa_atexit unsupported on AIX"); // Register above __dtor with atexit(). CGF.registerGlobalDtorWithAtExit(dtorStub); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 0ff8d1250242..70d0fe0021a9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5498,7 +5498,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -fuse-cxa-atexit is default. if (!Args.hasFlag( options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit, - !RawTriple.isOSWindows() && + !RawTriple.isOSAIX() && !RawTriple.isOSWindows() && TC.getArch() != llvm::Triple::xcore && ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) || RawTriple.hasEnvironment())) || diff --git a/clang/test/CodeGenCXX/aix-static-init.cpp b/clang/test/CodeGenCXX/aix-static-init.cpp index 7307d3d448f1..606e51328ffb 100644 --- a/clang/test/CodeGenCXX/aix-static-init.cpp +++ b/clang/test/CodeGenCXX/aix-static-init.cpp @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \ -// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \ +// RUN: -std=c++2a < %s | \ // RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \ -// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \ +// RUN: -std=c++2a < %s | \ // RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s namespace test1 { diff --git a/clang/test/Driver/cxa-atexit.cpp b/clang/test/Driver/cxa-atexit.cpp index 336756dedcec..e81af6cd5963 100644 --- a/clang/test/Driver/cxa-atexit.cpp +++ b/clang/test/Driver/cxa-atexit.cpp @@ -17,6 +17,8 @@ // RUN: %clang -### -target mips-unknown-none-gnu -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MIPS // RUN: %clang -### -target mips-mti-none-gnu -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MIPS // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-SOLARIS +// RUN: %clang -### -target powerpc-ibm-aix-xcoff -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-AIX +// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-AIX // CHECK-WINDOWS: "-fno-use-cxa-atexit" // CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit" @@ -24,6 +26,7 @@ // CHECK-XCORE: "-fno-use-cxa-atexit" // CHECK-MTI: "-fno-use-cxa-atexit" // CHECK-MIPS-NOT: "-fno-use-cxa-atexit" +// CHECK-AIX: "-fno-use-cxa-atexit" // RUN: %clang -target x86_64-apple-darwin -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6ef801a - [AIX] Static init frontend recovery and backend support
Author: Xiangling Liao Date: 2020-08-10T10:10:49-04:00 New Revision: 6ef801aa6bc01fc49a8e83ddb217470b5e2337dd URL: https://github.com/llvm/llvm-project/commit/6ef801aa6bc01fc49a8e83ddb217470b5e2337dd DIFF: https://github.com/llvm/llvm-project/commit/6ef801aa6bc01fc49a8e83ddb217470b5e2337dd.diff LOG: [AIX] Static init frontend recovery and backend support On the frontend side, this patch recovers AIX static init implementation to use the linkage type and function names Clang chooses for sinit related function. On the backend side, this patch sets correct linkage and function names on aliases created for sinit/sterm functions. Differential Revision: https://reviews.llvm.org/D84534 Added: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll llvm/test/CodeGen/PowerPC/aix-static-init-key-object.ll llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll Modified: clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ItaniumCXXABI.cpp clang/test/CodeGenCXX/aix-static-init-debug-info.cpp clang/test/CodeGenCXX/aix-static-init.cpp clang/unittests/CodeGen/IncrementalProcessingTest.cpp llvm/include/llvm/CodeGen/AsmPrinter.h llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Removed: diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 4e941021daa3..bfefd7956157 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -21,7 +21,6 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/Support/Path.h" -#include "llvm/Transforms/Utils/ModuleUtils.h" using namespace clang; using namespace CodeGen; @@ -365,12 +364,9 @@ void CodeGenFunction::EmitCXXGuardedInitBranch(llvm::Value *NeedsInit, llvm::Function *CodeGenModule::CreateGlobalInitOrCleanUpFunction( llvm::FunctionType *FTy, const Twine &Name, const CGFunctionInfo &FI, -SourceLocation Loc, bool TLS, bool IsExternalLinkage) { +SourceLocation Loc, bool TLS) { llvm::Function *Fn = llvm::Function::Create( - FTy, - IsExternalLinkage ? llvm::GlobalValue::ExternalLinkage -: llvm::GlobalValue::InternalLinkage, - Name, &getModule()); + FTy, llvm::GlobalValue::InternalLinkage, Name, &getModule()); if (!getLangOpts().AppleKext && !TLS) { // Set the section if needed. @@ -378,8 +374,7 @@ llvm::Function *CodeGenModule::CreateGlobalInitOrCleanUpFunction( Fn->setSection(Section); } - if (Fn->hasInternalLinkage()) -SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); + SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); Fn->setCallingConv(getRuntimeCC()); @@ -589,22 +584,10 @@ CodeGenModule::EmitCXXGlobalInitFunc() { if (CXXGlobalInits.empty() && PrioritizedCXXGlobalInits.empty()) return; - const bool UseSinitAndSterm = getCXXABI().useSinitAndSterm(); - if (UseSinitAndSterm) { -GlobalUniqueModuleId = getUniqueModuleId(&getModule()); - -// FIXME: We need to figure out what to hash on or encode into the unique ID -// we need. -if (GlobalUniqueModuleId.compare("") == 0) - llvm::report_fatal_error( - "cannot produce a unique identifier for this module" - " based on strong external symbols"); -GlobalUniqueModuleId = GlobalUniqueModuleId.substr(1); - } - llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false); const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction(); + const bool UseSinitAndSterm = getCXXABI().useSinitAndSterm(); // Create our global prioritized initialization function. if (!PrioritizedCXXGlobalInits.empty()) { assert(!UseSinitAndSterm && "Prioritized sinit and sterm functions are not" @@ -644,24 +627,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() { if (UseSinitAndSterm && CXXGlobalInits.empty()) return; - // Create our global initialization function. - SmallString<128> FuncName; - bool IsExternalLinkage = false; - if (UseSinitAndSterm) { -llvm::Twine("__sinit8000_clang_", GlobalUniqueModuleId) -.toVector(FuncName); -IsExternalLinkage = true; - } else { -// Include the filename in the symbol name. Including "sub_" matches gcc -// and makes sure these symbols appear lexicographically behind the symbols -// with priority emitted above. -llvm::Twine("_GLOBAL__sub_I_", getTransformedFileName(getModule())) -.toVector(FuncName); - } - + // Include the filename in the symbol name. Including "sub_" matches gcc + // and makes sure these symbols appear lexicographically behind the symbols + // with priority emitted above.
[clang] 9e407af - [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default
Author: Xiangling Liao Date: 2020-11-16T10:07:57-05:00 New Revision: 9e407afd9bd3b5181db24b08f78cb43344bd8292 URL: https://github.com/llvm/llvm-project/commit/9e407afd9bd3b5181db24b08f78cb43344bd8292 DIFF: https://github.com/llvm/llvm-project/commit/9e407afd9bd3b5181db24b08f78cb43344bd8292.diff LOG: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default In order to support attribute((constructor)) and attribute((destructor)), which is used by various LLVM non-C++ runtime components, AIX will include crti[_64].o and -bcdtors for C language link invocations by default. Differential Revision: https://reviews.llvm.org/D91361 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 47ce99a7c625..7b5d7da8c873 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -134,16 +134,15 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back( Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(; -if (D.CCCIsCXX()) - CmdArgs.push_back(Args.MakeArgString( - ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o"))); +CmdArgs.push_back(Args.MakeArgString( +ToolChain.GetFilePath(IsArch32Bit ? "crti.o" : "crti_64.o"))); } - // 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"); + // Collect all static constructor and destructor functions in both C and CXX + // language link invocations. This has to come before AddLinkerInputs as the + // implied option needs to precede any other '-bcdtors' settings or + // '-bnocdtors' that '-Wl' might forward. + 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 89959d851b93..6abfa10c92f6 100644 --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -16,7 +16,7 @@ // CHECK-LD32: "-b32" // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" -// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o" +// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o" // CHECK-LD32: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-NOT: "-lc++" // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a" @@ -38,7 +38,7 @@ // CHECK-LD64: "-b64" // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o" -// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o" +// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o" // CHECK-LD64: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-NOT: "-lc++" // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a" @@ -61,7 +61,7 @@ // CHECK-LD32-PTHREAD: "-b32" // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o" -// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o" +// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o" // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-PTHREAD-NOT: "-lc++" // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a" @@ -85,7 +85,7 @@ // CHECK-LD64-PTHREAD: "-b64" // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000" // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o" -// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o" +// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o" // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib" // CHECK-LD64-PTHREAD-NOT: "-lc++" // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a" @@ -109,7 +109,7 @@ // CHECK-LD32-PROF: "-b32" // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000" // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o" -// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o" +// CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o" // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib" // CHECK-LD32-PROF-NOT: "-lc++" // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a" @@ -132,7 +132,7 @@ // CHECK-LD64-GPROF: "-b64" // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:
[clang] 17497ec - [AIX][FE] Support constructor/destructor attribute
Author: Xiangling Liao Date: 2020-11-19T09:24:01-05:00 New Revision: 17497ec514f7a87e0ac39a803534b3a324a19324 URL: https://github.com/llvm/llvm-project/commit/17497ec514f7a87e0ac39a803534b3a324a19324 DIFF: https://github.com/llvm/llvm-project/commit/17497ec514f7a87e0ac39a803534b3a324a19324.diff LOG: [AIX][FE] Support constructor/destructor attribute Support attribute((constructor)) and attribute((destructor)) on AIX Differential Revision: https://reviews.llvm.org/D90892 Added: clang/test/CodeGen/aix-constructor-attribute.c clang/test/CodeGen/aix-destructor-attribute.c clang/test/CodeGenCXX/aix-constructor-attribute.cpp clang/test/CodeGenCXX/aix-destructor-attribute.cpp Modified: clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Sema/SemaDeclAttr.cpp Removed: clang/test/CodeGen/aix-constructor-attribute.cpp clang/test/CodeGen/aix-destructor-attribute.cpp clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index b9ff561aa641..3dbf4cc7cb97 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -273,8 +273,10 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(const VarDecl &VD, void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); - assert(cast(dtorStub)->getFunctionType() == - llvm::FunctionType::get(CGM.VoidTy, false) && + assert(dtorStub->getType() == + llvm::PointerType::get( + llvm::FunctionType::get(CGM.VoidTy, false), + dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); llvm::FunctionType *atexitTy = @@ -290,7 +292,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { } llvm::Value * -CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub) { +CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // The unatexit subroutine unregisters __dtor functions that were previously // registered by the atexit subroutine. If the referenced function is found, // it is removed from the list of functions that are called at normal program @@ -298,8 +300,10 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub) { // value is returned. // // extern "C" int unatexit(void (*f)(void)); - assert(dtorStub->getFunctionType() == - llvm::FunctionType::get(CGM.VoidTy, false) && + assert(dtorStub->getType() == + llvm::PointerType::get( + llvm::FunctionType::get(CGM.VoidTy, false), + dtorStub->getType()->getPointerAddressSpace()) && "Argument to unatexit has a wrong type."); llvm::FunctionType *unatexitTy = diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 8a1e47db33ff..40efa6dbc5ff 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4304,7 +4304,7 @@ class CodeGenFunction : public CodeGenTypeCache { void registerGlobalDtorWithAtExit(llvm::Constant *dtorStub); /// Call unatexit() with function dtorStub. - llvm::Value *unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub); + llvm::Value *unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub); /// Emit code in this function to perform a guarded variable /// initialization. Guarded initializations are used when it's not diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1f81faaa2c6f..f56b7374082f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1278,11 +1278,10 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, /// AddGlobalDtor - Add a function to the list that will be called /// when the module is unloaded. -void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { - if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) { -if (getCXXABI().useSinitAndSterm()) - llvm::report_fatal_error( - "register global dtors with atexit() is not supported yet"); +void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority, + bool IsDtorAttrFunc) { + if (CodeGenOpts.RegisterGlobalDtorsWithAtExit && + (!getContext().getTargetInfo().getTriple().isOSAIX() || IsDtorAttrFunc)) { DtorsUsingAtExit[Priority].push_back(Dtor); return; } @@ -4716,7 +4715,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, if (const ConstructorAttr *CA = D->getAttr()) AddGlobalCtor(Fn, CA->getPriority()
[clang] 944691f - [NFC][FE] Replace TypeSize with StorageUnitSize
Author: Xiangling Liao Date: 2020-09-30T10:32:53-04:00 New Revision: 944691f0b7fa8d99790a4544545e55f014c37295 URL: https://github.com/llvm/llvm-project/commit/944691f0b7fa8d99790a4544545e55f014c37295 DIFF: https://github.com/llvm/llvm-project/commit/944691f0b7fa8d99790a4544545e55f014c37295.diff LOG: [NFC][FE] Replace TypeSize with StorageUnitSize On some targets like AIX, last bitfield size is not always equal to last bitfield type size. Some bitfield like bool will have the same alignment as [unsigned]. So we'd like to use a more general term `StorageUnit` to replace type in this field. Differential Revision: https://reviews.llvm.org/D88260 Added: Modified: clang/lib/AST/RecordLayoutBuilder.cpp Removed: diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 715b629e290d..1c185bb08212 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -622,9 +622,10 @@ class ItaniumRecordLayoutBuilder { /// an adjacent bitfield if necessary. The unit in question is usually /// a byte, but larger units are used if IsMsStruct. unsigned char UnfilledBitsInLastUnit; - /// LastBitfieldTypeSize - If IsMsStruct, represents the size of the type - /// of the previous field if it was a bitfield. - unsigned char LastBitfieldTypeSize; + + /// LastBitfieldStorageUnitSize - If IsMsStruct, represents the size of the + /// storage unit of the previous field if it was a bitfield. + unsigned char LastBitfieldStorageUnitSize; /// MaxFieldAlignment - The maximum allowed field alignment. This is set by /// #pragma pack. @@ -693,7 +694,7 @@ class ItaniumRecordLayoutBuilder { UnadjustedAlignment(CharUnits::One()), UseExternalLayout(false), InferAlignment(false), Packed(false), IsUnion(false), IsMac68kAlign(false), IsMsStruct(false), UnfilledBitsInLastUnit(0), -LastBitfieldTypeSize(0), MaxFieldAlignment(CharUnits::Zero()), +LastBitfieldStorageUnitSize(0), MaxFieldAlignment(CharUnits::Zero()), DataSize(0), NonVirtualSize(CharUnits::Zero()), NonVirtualAlignment(CharUnits::One()), PreferredNVAlignment(CharUnits::One()), @@ -708,7 +709,7 @@ class ItaniumRecordLayoutBuilder { void LayoutFields(const RecordDecl *D); void LayoutField(const FieldDecl *D, bool InsertExtraPadding); - void LayoutWideBitField(uint64_t FieldSize, uint64_t TypeSize, + void LayoutWideBitField(uint64_t FieldSize, uint64_t StorageUnitSize, bool FieldPacked, const FieldDecl *D); void LayoutBitField(const FieldDecl *D); @@ -1451,7 +1452,7 @@ roundUpSizeToCharAlignment(uint64_t Size, } void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize, -uint64_t TypeSize, +uint64_t StorageUnitSize, bool FieldPacked, const FieldDecl *D) { assert(Context.getLangOpts().CPlusPlus && @@ -1481,7 +1482,7 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize, // We're not going to use any of the unfilled bits in the last byte. UnfilledBitsInLastUnit = 0; - LastBitfieldTypeSize = 0; + LastBitfieldStorageUnitSize = 0; uint64_t FieldOffset; uint64_t UnpaddedFieldOffset = getDataSizeInBits() - UnfilledBitsInLastUnit; @@ -1520,7 +1521,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { bool FieldPacked = Packed || D->hasAttr(); uint64_t FieldSize = D->getBitWidthValue(Context); TypeInfo FieldInfo = Context.getTypeInfo(D->getType()); - uint64_t TypeSize = FieldInfo.Width; + uint64_t StorageUnitSize = FieldInfo.Width; unsigned FieldAlign = FieldInfo.Align; // UnfilledBitsInLastUnit is the diff erence between the end of the @@ -1529,7 +1530,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { // first bit offset available for non-bitfields). The current data // size in bits is always a multiple of the char size; additionally, // for ms_struct records it's also a multiple of the - // LastBitfieldTypeSize (if set). + // LastBitfieldStorageUnitSize (if set). // The struct-layout algorithm is dictated by the platform ABI, // which in principle could use almost any rules it likes. In @@ -1583,26 +1584,26 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { // First, some simple bookkeeping to perform for ms_struct structs. if (IsMsStruct) { // The field alignment for integer types is always the size. -FieldAlign = TypeSize; +FieldAlign = StorageUnitSize; // If the previous field was not a bitfield, or was a bitfield // with a diff erent storage unit size, or if this field doesn't
[clang] 3a7487f - [FE] Use preferred alignment instead of ABI alignment for complete object when applicable
Author: Xiangling Liao Date: 2020-09-30T10:48:28-04:00 New Revision: 3a7487f903e2a6be29de39058eee2372e30798d5 URL: https://github.com/llvm/llvm-project/commit/3a7487f903e2a6be29de39058eee2372e30798d5 DIFF: https://github.com/llvm/llvm-project/commit/3a7487f903e2a6be29de39058eee2372e30798d5.diff LOG: [FE] Use preferred alignment instead of ABI alignment for complete object when applicable On some targets, preferred alignment is larger than ABI alignment in some cases. For example, on AIX we have special power alignment rules which would cause that. Previously, to support those cases, we added a “PreferredAlignment” field in the `RecordLayout` to store the AIX special alignment values in “PreferredAlignment” as the community suggested. However, that patch alone is not enough. There are places in the Clang where `PreferredAlignment` should have been used instead of ABI-specified alignment. This patch is aimed at fixing those spots. Differential Revision: https://reviews.llvm.org/D86790 Added: clang/test/CodeGen/aix-alignment.c clang/test/CodeGenCXX/aix-alignment.cpp Modified: clang/include/clang/AST/ASTContext.h clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CGExprCXX.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/CodeGen/TargetInfo.cpp Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index de0d1198b6d4..d30cf045f104 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2134,16 +2134,25 @@ class ASTContext : public RefCountedBase { } unsigned getTypeUnadjustedAlign(const Type *T) const; - /// Return the ABI-specified alignment of a type, in bits, or 0 if + /// Return the alignment of a type, in bits, or 0 if /// the type is incomplete and we cannot determine the alignment (for - /// example, from alignment attributes). - unsigned getTypeAlignIfKnown(QualType T) const; + /// example, from alignment attributes). The returned alignment is the + /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the + /// ABI alignment. + unsigned getTypeAlignIfKnown(QualType T, + bool NeedsPreferredAlignment = false) const; /// Return the ABI-specified alignment of a (complete) type \p T, in /// characters. CharUnits getTypeAlignInChars(QualType T) const; CharUnits getTypeAlignInChars(const Type *T) const; + /// Return the PreferredAlignment of a (complete) type \p T, in + /// characters. + CharUnits getPreferredTypeAlignInChars(QualType T) const { +return toCharUnitsFromBits(getPreferredTypeAlign(T)); + } + /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, /// in characters, before alignment adjustments. This method does not work on /// incomplete types. @@ -2166,7 +2175,12 @@ class ASTContext : public RefCountedBase { /// the current target, in bits. /// /// This can be diff erent than the ABI alignment in cases where it is - /// beneficial for performance to overalign a data type. + /// beneficial for performance or backwards compatibility preserving to + /// overalign a data type. (Note: despite the name, the preferred alignment + /// is ABI-impacting, and not an optimization.) + unsigned getPreferredTypeAlign(QualType T) const { +return getPreferredTypeAlign(T.getTypePtr()); + } unsigned getPreferredTypeAlign(const Type *T) const; /// Return the default alignment for __attribute__((aligned)) on diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index fc7abeaae9b1..376a0b044010 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1836,7 +1836,8 @@ bool ASTContext::isAlignmentRequired(QualType T) const { return isAlignmentRequired(T.getTypePtr()); } -unsigned ASTContext::getTypeAlignIfKnown(QualType T) const { +unsigned ASTContext::getTypeAlignIfKnown(QualType T, + bool NeedsPreferredAlignment) const { // An alignment on a typedef overrides anything else. if (const auto *TT = T->getAs()) if (unsigned Align = TT->getDecl()->getMaxAlignment()) @@ -1845,7 +1846,7 @@ unsigned ASTContext::getTypeAlignIfKnown(QualType T) const { // If we have an (array of) complete type, we're done. T = getBaseElementType(T); if (!T->isIncompleteType()) -return getTypeAlign(T); +return NeedsPreferredAlignment ? getPreferredTypeAlign(T) : getTypeAlign(T); // If we had an array type, its element type might be a typedef // type with an alignment attribute. @@ -2402,7 +2403,8 @@ CharUnits ASTContext::getTypeUnadjustedAlignInChars(const Type *T) const { /// getPreferredTypeAlign - Return the "preferred" alignment of the specified /// type for the current target in bits. This can be diff erent than the ABI /// alignment in c
[clang] 4c10d65 - [AIX] Support two itanium alignment LIT testcases for AIX using regex
Author: Xiangling Liao Date: 2020-10-13T16:47:01-04:00 New Revision: 4c10d6508f546ee986df0994663984cb15354c08 URL: https://github.com/llvm/llvm-project/commit/4c10d6508f546ee986df0994663984cb15354c08 DIFF: https://github.com/llvm/llvm-project/commit/4c10d6508f546ee986df0994663984cb15354c08.diff LOG: [AIX] Support two itanium alignment LIT testcases for AIX using regex AIX has different layout dumping format from other itanium ABIs. And for these two cases, use regex to match AIX format. Differential Revision: https://reviews.llvm.org/D89064 Added: Modified: clang/test/Layout/itanium-pack-and-align.cpp clang/test/Layout/itanium-union-bitfield.cpp Removed: diff --git a/clang/test/Layout/itanium-pack-and-align.cpp b/clang/test/Layout/itanium-pack-and-align.cpp index ac64979af33b..94a35448db61 100644 --- a/clang/test/Layout/itanium-pack-and-align.cpp +++ b/clang/test/Layout/itanium-pack-and-align.cpp @@ -16,11 +16,11 @@ T t; // CHECK: 0 | struct T // CHECK-NEXT: 0 | char x // CHECK-NEXT: 1 | int y -// CHECK-NEXT:| [sizeof=8, dsize=8, align=8, -// CHECK-NEXT:| nvsize=8, nvalign=8] +// CHECK-NEXT:| [sizeof=8, dsize=8, align=8,{{( preferredalign=8,)?}} +// CHECK-NEXT:| nvsize=8, nvalign=8{{(, preferrednvalign=8)?}}] // CHECK: 0 | struct S // CHECK-NEXT: 0 | char x // CHECK-NEXT: 1 | int y -// CHECK-NEXT:| [sizeof=8, dsize=8, align=8, -// CHECK-NEXT:| nvsize=8, nvalign=8] +// CHECK-NEXT:| [sizeof=8, dsize=8, align=8,{{( preferredalign=8,)?}} +// CHECK-NEXT:| nvsize=8, nvalign=8{{(, preferrednvalign=8)?}}] diff --git a/clang/test/Layout/itanium-union-bitfield.cpp b/clang/test/Layout/itanium-union-bitfield.cpp index 289a565359e9..961bf5b6f3b4 100644 --- a/clang/test/Layout/itanium-union-bitfield.cpp +++ b/clang/test/Layout/itanium-union-bitfield.cpp @@ -18,12 +18,11 @@ B::B() {} // CHECK:*** Dumping AST Record Layout // CHECK-NEXT: 0 | union A // CHECK-NEXT: 0:0-2 | int f1 -// CHECK-NEXT: | [sizeof=4, dsize=1, align=4 -// CHECK-NEXT: | nvsize=1, nvalign=4] +// CHECK-NEXT: | [sizeof=4, dsize=1, align=4{{(, preferredalign=4,)?}} +// CHECK-NEXT: | nvsize=1, nvalign=4{{(, preferrednvalign=4)?}}] // CHECK:*** Dumping AST Record Layout // CHECK-NEXT: 0 | union B // CHECK-NEXT: 0:0-34 | char f1 -// CHECK-NEXT:| [sizeof=8, dsize=5, align=4 -// CHECK-NEXT:| nvsize=5, nvalign=4] - +// CHECK-NEXT:| [sizeof=8, dsize=5, align=4{{(, preferredalign=4,)?}} +// CHECK-NEXT:| nvsize=5, nvalign=4{{(, preferrednvalign=4)?}}] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cf11f01 - [NFC] Fix the definition of SuitableAlign
Author: Xiangling Liao Date: 2020-10-21T13:34:56-04:00 New Revision: cf11f017af32a797e301f56b163a989ad73630fa URL: https://github.com/llvm/llvm-project/commit/cf11f017af32a797e301f56b163a989ad73630fa DIFF: https://github.com/llvm/llvm-project/commit/cf11f017af32a797e301f56b163a989ad73630fa.diff LOG: [NFC] Fix the definition of SuitableAlign Added: Modified: clang/include/clang/Basic/TargetInfo.h Removed: diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 7253b5ea9abe..26dc6eacb204 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -581,8 +581,9 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Determine whether constrained floating point is supported on this target. virtual bool hasStrictFP() const { return HasStrictFP; } - /// Return the alignment that is suitable for storing any - /// object with a fundamental alignment requirement. + /// Return the alignment that is the largest alignment ever used for any + /// scalar/SIMD data type on the target machine you are compiling for + /// (including types with an extended alignment requirement). unsigned getSuitableAlign() const { return SuitableAlign; } /// Return the default alignment for __attribute__((aligned)) on ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0ba9843 - [AIX] Emit error for -G option on AIX
Author: Xiangling Liao Date: 2020-10-22T16:16:39-04:00 New Revision: 0ba98433971f6aa7cf4dc2befe7b5446d25d5956 URL: https://github.com/llvm/llvm-project/commit/0ba98433971f6aa7cf4dc2befe7b5446d25d5956 DIFF: https://github.com/llvm/llvm-project/commit/0ba98433971f6aa7cf4dc2befe7b5446d25d5956.diff LOG: [AIX] Emit error for -G option on AIX 1. Emit error for -G driver option on AIX 2. Adjust cmake file to use -Wl,-G instead of -G On AIX, legacy XL compiler uses -G to produce a shared object enabled for use with the run-time linker, which has different meanings from what it is used for in Clang. And in Clang, other targets do not have -G map to another functionality in their legacy compiler. So this error is more important when we are on AIX. Differential Revision: https://reviews.llvm.org/D89897 Added: clang/test/Driver/aix-err-options.c Modified: clang/lib/Driver/ToolChains/Clang.cpp llvm/CMakeLists.txt Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 61e367bd835d..61b6af59e8b5 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4958,6 +4958,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (D.CCGenDiagnostics) CmdArgs.push_back("-disable-pragma-debug-crash"); + if (RawTriple.isOSAIX()) +if (Arg *A = Args.getLastArg(options::OPT_G)) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getSpelling() << RawTriple.str(); + bool UseSeparateSections = isUseSeparateSections(Triple); if (Args.hasFlag(options::OPT_ffunction_sections, diff --git a/clang/test/Driver/aix-err-options.c b/clang/test/Driver/aix-err-options.c new file mode 100644 index ..6ed8363c161f --- /dev/null +++ b/clang/test/Driver/aix-err-options.c @@ -0,0 +1,7 @@ +// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK32 %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK64 %s + +// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff' +// CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff' diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 344ccb6fda2f..39d78c70c02e 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -930,7 +930,7 @@ if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") # Modules should be built with -G, so we can use runtime linking with # plugins. - string(APPEND CMAKE_MODULE_LINKER_FLAGS " -G") + string(APPEND CMAKE_MODULE_LINKER_FLAGS " -Wl,-G") # Also set the correct flags for building shared libraries. string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 05bef88 - [AIX] Let alloca return 16 bytes alignment
Author: Xiangling Liao Date: 2020-10-23T14:41:32-04:00 New Revision: 05bef88eb3ecb8519a871ca9aa53caeca5add555 URL: https://github.com/llvm/llvm-project/commit/05bef88eb3ecb8519a871ca9aa53caeca5add555 DIFF: https://github.com/llvm/llvm-project/commit/05bef88eb3ecb8519a871ca9aa53caeca5add555.diff LOG: [AIX] Let alloca return 16 bytes alignment On AIX, to support vector types, which should always be 16 bytes aligned, we set alloca to return 16 bytes aligned memory space. Differential Revision: https://reviews.llvm.org/D89910 Added: clang/test/CodeGen/aix_alloca_align.c Modified: clang/lib/Basic/Targets/PPC.h clang/test/Preprocessor/init-ppc.c clang/test/Preprocessor/init-ppc64.c Removed: diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h index 597508207ffb..ad754462370f 100644 --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -370,7 +370,6 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo { SizeType = UnsignedLong; PtrDiffType = SignedLong; IntPtrType = SignedLong; - SuitableAlign = 64; LongDoubleWidth = 64; LongDoubleAlign = DoubleAlign = 32; LongDoubleFormat = &llvm::APFloat::IEEEdouble(); @@ -409,7 +408,6 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo { if (Triple.isOSAIX()) { // TODO: Set appropriate ABI for AIX platform. DataLayout = "E-m:a-i64:64-n32:64"; - SuitableAlign = 64; LongDoubleWidth = 64; LongDoubleAlign = DoubleAlign = 32; LongDoubleFormat = &llvm::APFloat::IEEEdouble(); diff --git a/clang/test/CodeGen/aix_alloca_align.c b/clang/test/CodeGen/aix_alloca_align.c new file mode 100644 index ..e235abdd1630 --- /dev/null +++ b/clang/test/CodeGen/aix_alloca_align.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -S -emit-llvm < %s | \ +// RUN: FileCheck --check-prefix=32BIT %s + +// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -S -emit-llvm < %s | \ +// RUN: FileCheck --check-prefix=64BIT %s + +typedef __SIZE_TYPE__ size_t; +extern void *alloca(size_t __size) __attribute__((__nothrow__)); + +void foo() { + char *ptr1 = (char *)alloca(sizeof(char) * 9); + char *ptr2 = (char *)alloca(sizeof(char) * 32); +} + +// 32BIT: %0 = alloca i8, i32 9, align 16 +// 32BIT: %1 = alloca i8, i32 32, align 16 + +// 64BIT: %0 = alloca i8, i64 9, align 16 +// 64BIT: %1 = alloca i8, i64 32, align 16 diff --git a/clang/test/Preprocessor/init-ppc.c b/clang/test/Preprocessor/init-ppc.c index 275757631c6c..aa0f8c97de12 100644 --- a/clang/test/Preprocessor/init-ppc.c +++ b/clang/test/Preprocessor/init-ppc.c @@ -398,7 +398,7 @@ // PPC-AIX:#define _LONG_LONG 1 // PPC-AIX-NOT:#define _LP64 1 // PPC-AIX:#define _POWER 1 -// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 8 +// PPC-AIX:#define __BIGGEST_ALIGNMENT__ 16 // PPC-AIX:#define __BIG_ENDIAN__ 1 // PPC-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC-AIX:#define __CHAR16_TYPE__ unsigned short diff --git a/clang/test/Preprocessor/init-ppc64.c b/clang/test/Preprocessor/init-ppc64.c index b553d07183ec..dd965b86b879 100644 --- a/clang/test/Preprocessor/init-ppc64.c +++ b/clang/test/Preprocessor/init-ppc64.c @@ -666,7 +666,7 @@ // PPC64-AIX:#define _LP64 1 // PPC64-AIX:#define _POWER 1 // PPC64-AIX:#define __64BIT__ 1 -// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 8 +// PPC64-AIX:#define __BIGGEST_ALIGNMENT__ 16 // PPC64-AIX:#define __BIG_ENDIAN__ 1 // PPC64-AIX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC64-AIX:#define __CHAR16_TYPE__ unsigned short ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3d4aebb - [AIX] Also error on -G for link-only step
Author: Xiangling Liao Date: 2020-10-26T16:51:28-04:00 New Revision: 3d4aebbb9d99642fcc277c8bd199ead400de2703 URL: https://github.com/llvm/llvm-project/commit/3d4aebbb9d99642fcc277c8bd199ead400de2703 DIFF: https://github.com/llvm/llvm-project/commit/3d4aebbb9d99642fcc277c8bd199ead400de2703.diff LOG: [AIX] Also error on -G for link-only step Error on -G on AIX for all modes(preprocess, assemble, compile, link). Differential Revision: https://reviews.llvm.org/D90063 Added: Modified: clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/aix-err-options.c Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index aaa1af75..97d411d8e9f4 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3888,9 +3888,15 @@ void Driver::BuildJobs(Compilation &C) const { } } + const llvm::Triple &RawTriple = C.getDefaultToolChain().getTriple(); + if (RawTriple.isOSAIX()) +if (Arg *A = C.getArgs().getLastArg(options::OPT_G)) + Diag(diag::err_drv_unsupported_opt_for_target) + << A->getSpelling() << RawTriple.str(); + // Collect the list of architectures. llvm::StringSet<> ArchNames; - if (C.getDefaultToolChain().getTriple().isOSBinFormatMachO()) + if (RawTriple.isOSBinFormatMachO()) for (const Arg *A : C.getArgs()) if (A->getOption().matches(options::OPT_arch)) ArchNames.insert(A->getValue()); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 61b6af59e8b5..61e367bd835d 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4958,11 +4958,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (D.CCGenDiagnostics) CmdArgs.push_back("-disable-pragma-debug-crash"); - if (RawTriple.isOSAIX()) -if (Arg *A = Args.getLastArg(options::OPT_G)) - D.Diag(diag::err_drv_unsupported_opt_for_target) - << A->getSpelling() << RawTriple.str(); - bool UseSeparateSections = isUseSeparateSections(Triple); if (Args.hasFlag(options::OPT_ffunction_sections, diff --git a/clang/test/Driver/aix-err-options.c b/clang/test/Driver/aix-err-options.c index 6ed8363c161f..266153371bf8 100644 --- a/clang/test/Driver/aix-err-options.c +++ b/clang/test/Driver/aix-err-options.c @@ -1,7 +1,28 @@ -// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \ +// RUN: %clang -target powerpc-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \ // RUN: FileCheck --check-prefix=CHECK32 %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK32 %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK32 %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -### -c \ +// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK32 %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -### -o dummy.so \ +// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK32 %s + +// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -E -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK64 %s // RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \ // RUN: FileCheck --check-prefix=CHECK64 %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c -G 0 2>&1 %s | \ +// RUN: FileCheck --check-prefix=CHECK64 %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -c \ +// RUN: %S/Inputs/aix_ppc_tree/dummy0.s -G 0 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK64 %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -o dummy.so \ +// RUN: %S/Inputs/aix_ppc_tree/dummy0.o -G 0 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK64 %s -// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff' +// CHECK32: error: unsupported option '-G' for target 'powerpc-ibm-aix-xcoff' // CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 357715c - [NFC] Remove max_align.c LIT testcase
Author: Xiangling Liao Date: 2020-10-26T17:14:30-04:00 New Revision: 357715ce97d0bc937301b0b006d145c24a9d23aa URL: https://github.com/llvm/llvm-project/commit/357715ce97d0bc937301b0b006d145c24a9d23aa DIFF: https://github.com/llvm/llvm-project/commit/357715ce97d0bc937301b0b006d145c24a9d23aa.diff LOG: [NFC] Remove max_align.c LIT testcase Since we fixed the definition of `SuitableAlign`[https://reviews.llvm.org/D88659], `max_align_t` and `__BIGGEST_ALIGNMENT__` are not necessarily the same always. The original testcase was added here: https://reviews.llvm.org/D59048 Differential Revision: https://reviews.llvm.org/D90187 Added: Modified: Removed: clang/test/Headers/max_align.c diff --git a/clang/test/Headers/max_align.c b/clang/test/Headers/max_align.c deleted file mode 100644 index 67a914d6b67e.. --- a/clang/test/Headers/max_align.c +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify %s -// expected-no-diagnostics - -// XFAIL: windows-, i686 - -#ifndef __BIGGEST_ALIGNMENT__ -#error __BIGGEST_ALIGNMENT__ not defined -#endif - -#include - -_Static_assert(__BIGGEST_ALIGNMENT__ == _Alignof(max_align_t), ""); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e092165 - [AIX] Implement AIX special bitfield related alignment rules
Author: Xiangling Liao Date: 2021-05-17T11:30:29-04:00 New Revision: e0921655b1ff8d4ba7c14be59252fe05b705920e URL: https://github.com/llvm/llvm-project/commit/e0921655b1ff8d4ba7c14be59252fe05b705920e DIFF: https://github.com/llvm/llvm-project/commit/e0921655b1ff8d4ba7c14be59252fe05b705920e.diff LOG: [AIX] Implement AIX special bitfield related alignment rules 1.[bool, char, short] bitfields have the same alignment as unsigned int 2.Adjust alignment on typedef field decls/honor align attribute 3.Fix alignment for scoped enum class 4.Long long bitfield has 4bytes alignment and StorageUnitSize under 32 bit compile mode Differential Revision: https://reviews.llvm.org/D87029 Added: clang/test/Layout/aix-bitfield-alignment.c clang/test/Layout/aix-bitfield-alignment.cpp Modified: clang/lib/AST/RecordLayoutBuilder.cpp Removed: diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 8a25b5cbd84a..beb111e2e971 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1528,12 +1528,17 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize, UpdateAlignment(TypeAlign); } +static bool isAIXLayout(const ASTContext &Context) { + return Context.getTargetInfo().getTriple().getOS() == llvm::Triple::AIX; +} + void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { bool FieldPacked = Packed || D->hasAttr(); uint64_t FieldSize = D->getBitWidthValue(Context); TypeInfo FieldInfo = Context.getTypeInfo(D->getType()); uint64_t StorageUnitSize = FieldInfo.Width; unsigned FieldAlign = FieldInfo.Align; + bool AlignIsRequired = FieldInfo.AlignIsRequired; // UnfilledBitsInLastUnit is the diff erence between the end of the // last allocated bitfield (i.e. the first bit offset available for @@ -1611,9 +1616,33 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) { } } + if (isAIXLayout(Context)) { +if (StorageUnitSize < Context.getTypeSize(Context.UnsignedIntTy)) { + // On AIX, [bool, char, short] bitfields have the same alignment + // as [unsigned]. + StorageUnitSize = Context.getTypeSize(Context.UnsignedIntTy); +} else if (StorageUnitSize > Context.getTypeSize(Context.UnsignedIntTy) && + Context.getTargetInfo().getTriple().isArch32Bit() && + FieldSize <= 32) { + // Under 32-bit compile mode, the bitcontainer is 32 bits if a single + // long long bitfield has length no greater than 32 bits. + StorageUnitSize = 32; + + if (!AlignIsRequired) +FieldAlign = 32; +} + +if (FieldAlign < StorageUnitSize) { + // The bitfield alignment should always be greater than or equal to + // bitcontainer size. + FieldAlign = StorageUnitSize; +} + } + // If the field is wider than its declared type, it follows - // diff erent rules in all cases. - if (FieldSize > StorageUnitSize) { + // diff erent rules in all cases, except on AIX. + // On AIX, wide bitfield follows the same rules as normal bitfield. + if (FieldSize > StorageUnitSize && !isAIXLayout(Context)) { LayoutWideBitField(FieldSize, StorageUnitSize, FieldPacked, D); return; } diff --git a/clang/test/Layout/aix-bitfield-alignment.c b/clang/test/Layout/aix-bitfield-alignment.c new file mode 100644 index ..a736695cc603 --- /dev/null +++ b/clang/test/Layout/aix-bitfield-alignment.c @@ -0,0 +1,234 @@ +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s + +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only -fxl-pragma-pack -x c %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only -fxl-pragma-pack -x c++ %s | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s + +struct A { + unsigned char c : 2; +} A; + +int a = sizeof(A); + +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct A +// CHECK-NEXT: 0:0-1 | unsigned char c +// CHECK-NEXT: sizeof=4, {{(dsize=4, )?}}align=4, preferredalign=4 + +struct B { + char c; + int : 0; +} B; + +int b = sizeof(B); + +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct B +// CHECK-NEXT: 0 | char c +// CHECK-NEXT:4:- | int +// CHECK-NEXT: sizeof=4, {{(dsize=4, )?}}align=4, preferredalign=4 + +struct C { + signed int a1 : 6; + signed char a2 : 4; +
[clang] d74b663 - Fix LIT failure on native aix
Author: Xiangling Liao Date: 2021-05-20T09:38:52-04:00 New Revision: d74b6635ef38d123793f025a2ea1ef28153d803a URL: https://github.com/llvm/llvm-project/commit/d74b6635ef38d123793f025a2ea1ef28153d803a DIFF: https://github.com/llvm/llvm-project/commit/d74b6635ef38d123793f025a2ea1ef28153d803a.diff LOG: Fix LIT failure on native aix On AIX, char bitfields have the same alignment as unsigned int. Reference: https://reviews.llvm.org/D87029 Differential Revision: https://reviews.llvm.org/D102715 Added: Modified: clang/test/Sema/struct-packed-align.c Removed: diff --git a/clang/test/Sema/struct-packed-align.c b/clang/test/Sema/struct-packed-align.c index 122b7f2764612..b4bddebe230e2 100644 --- a/clang/test/Sema/struct-packed-align.c +++ b/clang/test/Sema/struct-packed-align.c @@ -146,18 +146,17 @@ extern int n2[__alignof(struct nS) == 1 ? 1 : -1]; // GCC 4.4 but the change can lead to diff erences in the structure layout. // See the documentation of -Wpacked-bitfield-compat for more information. struct packed_chars { - char a:4; + char a : 8, b : 8, c : 8, d : 4; #ifdef __ORBIS__ // Test for pre-r254596 clang behavior on the PS4 target. PS4 must maintain // ABI backwards compatibility. - char b:8 __attribute__ ((packed)); + char e : 8 __attribute__((packed)); // expected-warning@-1 {{'packed' attribute ignored for field of type 'char'}} - char c:4; #else - char b:8 __attribute__ ((packed)); + char e : 8 __attribute__((packed)); // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with single-byte alignment in older versions of GCC and Clang}} - char c:4; #endif + char f : 4, g : 8, h : 8, i : 8; }; #if (defined(_WIN32) || defined(__ORBIS__)) && !defined(__declspec) // _MSC_VER is unavailable in cc1. @@ -165,9 +164,13 @@ struct packed_chars { // // Additionally, test for pre-r254596 clang behavior on the PS4 target. PS4 // must maintain ABI backwards compatibility. -extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1]; +extern int o1[sizeof(struct packed_chars) == 9 ? 1 : -1]; extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1]; +#elif defined(_AIX) +// On AIX, char bitfields have the same alignment as unsigned int. +extern int o1[sizeof(struct packed_chars) == 8 ? 1 : -1]; +extern int o2[__alignof(struct packed_chars) == 4 ? 1 : -1]; #else -extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1]; +extern int o1[sizeof(struct packed_chars) == 8 ? 1 : -1]; extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1]; #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6b1e2fc - [FE] Manipulate the first byte of guard variable type in both load and store operation
Author: Xiangling Liao Date: 2021-02-08T11:14:34-05:00 New Revision: 6b1e2fc89327a64c9300d543e00f12435c32dfcf URL: https://github.com/llvm/llvm-project/commit/6b1e2fc89327a64c9300d543e00f12435c32dfcf DIFF: https://github.com/llvm/llvm-project/commit/6b1e2fc89327a64c9300d543e00f12435c32dfcf.diff LOG: [FE] Manipulate the first byte of guard variable type in both load and store operation As Itanium ABI[http://itanium-cxx-abi.github.io/cxx-abi/abi.html#once-ctor] points out: "The size of the guard variable is 64 bits. The first byte (i.e. the byte at the address of the full variable) shall contain the value 0 prior to initialization of the associated variable, and 1 after initialization is complete." Differential Revision: https://reviews.llvm.org/D95822 Added: Modified: clang/lib/CodeGen/ItaniumCXXABI.cpp clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp clang/test/CodeGenCXX/aix-static-init.cpp clang/test/CodeGenCXX/cxx11-thread-local.cpp clang/test/CodeGenCXX/global-init.cpp clang/test/CodeGenCXX/static-data-member.cpp Removed: diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 50fb30a95cbb..b92801a516e9 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2472,7 +2472,10 @@ void ItaniumCXXABI::EmitGuardedInit(CodeGenFunction &CGF, CGF.EmitNounwindRuntimeCall(getGuardReleaseFn(CGM, guardPtrTy), guardAddr.getPointer()); } else { -Builder.CreateStore(llvm::ConstantInt::get(guardTy, 1), guardAddr); +// Store 1 into the first byte of the guard variable after initialization is +// complete. +Builder.CreateStore(llvm::ConstantInt::get(CGM.Int8Ty, 1), +Builder.CreateElementBitCast(guardAddr, CGM.Int8Ty)); } CGF.EmitBlock(EndBlock); diff --git a/clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp b/clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp index f7e4c0a86b46..799b158bcf60 100644 --- a/clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp +++ b/clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp @@ -44,6 +44,9 @@ template <> A A::instance = bar(); } // namespace test2 +// CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8 +// CHECK: @_ZGVN5test21AIvE8instanceE = weak_odr global i64 0, align 8 +// CHECK: @_ZGVN5test12t1IiEE = linkonce_odr global i64 0, align 8 // CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.2, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.4, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }] // CHECK: @llvm.global_dtors = appending global [4 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__finalize__ZN5test12t2E, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__finalize__ZN5test21AIvE8instanceE, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__finalize__ZN5test12t1IiEE, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }] @@ -77,7 +80,7 @@ A A::instance = bar(); // CHECK: define internal void @__cxx_global_var_init.1() [[ATTR:#[0-9]+]] { // CHECK: entry: -// CHECK: %0 = load atomic i8, i8* bitcast (i64* @_ZGVN5test12t2E to i8*) acquire +// CHECK: %0 = load atomic i8, i8* bitcast (i64* @_ZGVN5test12t2E to i8*) acquire, align 8 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end @@ -119,14 +122,14 @@ A A::instance = bar(); // CHECK: define internal void @__cxx_global_var_init.2() [[ATTR:#[0-9]+]] { // CHECK: entry: -// CHECK: %0 = load i8, i8* bitcast (i64* @_ZGVN5test21AIvE8instanceE to i8*) +// CHECK: %0 = load i8, i8* bitcast (i64* @_ZGVN5test21AIvE8instanceE to i8*), align 8 // CHECK: %guard.uninitialized = icmp eq i8 %0, 0 // CHECK: br i1 %guard.uninitialized, label %init.check, label %init.end // CHECK: init.check: // CHECK: call void @_ZN5test21AIvEC1Ev(%"struct.test2::A"* {{[^,]*}} @_ZN5test21AIvE8instanceE) // CHECK: %1 = call i32 @atexit(void ()* @__dtor__ZN5test21AIvE8instanceE) -// CHECK: store i64 1, i64* @_ZGVN5test21AIvE8instanceE +// CHECK: store i8 1, i8* bitcast (i64* @_ZGVN5test21AIvE8instanceE to i8*), align 8 // CHECK: br label %init.end // CHECK: init.end: @@ -182,7 +185,7 @@ A A::instance = bar(); // CHECK: define internal void @__cxx_global_var_init.4() [[ATTR:#[0-9]+]] { // CHECK: entry: -// CHECK: %0 = load i8, i8* bitcast (i64* @_ZGVN5test12t1IiEE to i8*) +// CHECK: %0 = load i8, i8* bitcast (i64* @_ZGV
[clang] 561fb7f - [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX
Author: Xiangling Liao Date: 2021-03-09T13:03:52-05:00 New Revision: 561fb7f60ab631e712c3fb6bbeb47061222c6818 URL: https://github.com/llvm/llvm-project/commit/561fb7f60ab631e712c3fb6bbeb47061222c6818 DIFF: https://github.com/llvm/llvm-project/commit/561fb7f60ab631e712c3fb6bbeb47061222c6818.diff LOG: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX LLVM is recommending to use SmallVector (that is, omitting the N), in the absence of a well-motivated choice for the number of inlined elements N. However, this doesn't work well with XL compiler on AIX since some header(s) aren't properly picked up with it. We need to take a further look into the real issue underneath and fix it in a later patch. But currently we'd like to use this patch to unblock the build compiler issue first. Differential Revision: https://reviews.llvm.org/D98265 Added: Modified: clang/lib/CodeGen/CGStmtOpenMP.cpp Removed: diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 2eaa481cd911..575d1143caab 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1913,7 +1913,7 @@ static llvm::CallInst * emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap, llvm::ArrayRef Args) { // Append the closure context to the argument. - SmallVector EffectiveArgs; + llvm::SmallVector EffectiveArgs; EffectiveArgs.reserve(Args.size() + 1); llvm::append_range(EffectiveArgs, Args); EffectiveArgs.push_back(Cap.second); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8bee52b - [AIX][Frontend] C++ ABI customizations for AIX boilerplate
Author: Xiangling Liao Date: 2020-02-24T10:26:51-05:00 New Revision: 8bee52bdb54a51ccfe1eb6c6ed5077132c2950a1 URL: https://github.com/llvm/llvm-project/commit/8bee52bdb54a51ccfe1eb6c6ed5077132c2950a1 DIFF: https://github.com/llvm/llvm-project/commit/8bee52bdb54a51ccfe1eb6c6ed5077132c2950a1.diff LOG: [AIX][Frontend] C++ ABI customizations for AIX boilerplate This PR enables "XL" C++ ABI in frontend AST to IR codegen. And it is driven by static init work. The current kind in Clang by default is Generic Itanium, which has different behavior on static init with IBM xlclang compiler on AIX. Differential Revision: https://reviews.llvm.org/D74015 Added: clang/test/CodeGen/static-init.cpp Modified: clang/include/clang/Basic/TargetCXXABI.h clang/lib/AST/ASTContext.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp Removed: diff --git a/clang/include/clang/Basic/TargetCXXABI.h b/clang/include/clang/Basic/TargetCXXABI.h index 1ab45d2ce9a1..93f70fc70dd8 100644 --- a/clang/include/clang/Basic/TargetCXXABI.h +++ b/clang/include/clang/Basic/TargetCXXABI.h @@ -109,6 +109,13 @@ class TargetCXXABI { /// - constructors and destructors return 'this', as in ARM. Fuchsia, +/// The XL ABI is the ABI used by IBM xlclang compiler and is a modified +/// version of the Itanium ABI. +/// +/// The relevant changes from the Itanium ABI are: +/// - static initialization is adjusted to use sinit and sterm functions; +XL, + /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and /// compatible compilers). /// @@ -148,6 +155,7 @@ class TargetCXXABI { case WatchOS: case GenericMIPS: case WebAssembly: +case XL: return true; case Microsoft: @@ -168,6 +176,7 @@ class TargetCXXABI { case WatchOS: case GenericMIPS: case WebAssembly: +case XL: return false; case Microsoft: @@ -202,6 +211,7 @@ class TargetCXXABI { case iOS64: case WatchOS: case Microsoft: +case XL: return true; } llvm_unreachable("bad ABI kind"); @@ -278,6 +288,7 @@ class TargetCXXABI { case iOS: // old iOS compilers did not follow this rule case Microsoft: case GenericMIPS: +case XL: return true; } llvm_unreachable("bad ABI kind"); @@ -315,6 +326,7 @@ class TargetCXXABI { case GenericARM: case iOS: case GenericMIPS: +case XL: return UseTailPaddingUnlessPOD03; // iOS on ARM64 and WebAssembly use the C++11 POD rules. They do not honor diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 50a0c3d76da2..b4527dc4b52a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -874,6 +874,7 @@ CXXABI *ASTContext::createCXXABI(const TargetInfo &T) { case TargetCXXABI::GenericMIPS: case TargetCXXABI::GenericItanium: case TargetCXXABI::WebAssembly: + case TargetCXXABI::XL: return CreateItaniumCXXABI(*this); case TargetCXXABI::Microsoft: return CreateMicrosoftCXXABI(*this); @@ -10253,6 +10254,7 @@ MangleContext *ASTContext::createMangleContext(const TargetInfo *T) { case TargetCXXABI::iOS64: case TargetCXXABI::WebAssembly: case TargetCXXABI::WatchOS: + case TargetCXXABI::XL: return ItaniumMangleContext::create(*this, getDiagnostics()); case TargetCXXABI::Microsoft: return MicrosoftMangleContext::create(*this, getDiagnostics()); diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 70fac030bc5d..e57ad7b9eeaf 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -706,6 +706,8 @@ class AIXTargetInfo : public OSTargetInfo { public: AIXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo(Triple, Opts) { +this->TheCXXABI.set(TargetCXXABI::XL); + if (this->PointerWidth == 64) { this->WCharType = this->UnsignedInt; } else { diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 235a40501afc..d4ed486b4079 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -83,6 +83,7 @@ static CGCXXABI *createCXXABI(CodeGenModule &CGM) { case TargetCXXABI::GenericMIPS: case TargetCXXABI::GenericItanium: case TargetCXXABI::WebAssembly: + case TargetCXXABI::XL: return CreateItaniumCXXABI(CGM); case TargetCXXABI::Microsoft: return CreateMicrosoftCXXABI(CGM); diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 057c726e355e..c8a73c2757ab 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -516,6 +516,16 @@ class WebAssemblyCXXABI final : public ItaniumCXXABI { } bool can
[clang] d508561 - [AIX] Support init priority attribute
Author: Xiangling Liao Date: 2021-04-08T15:40:09-04:00 New Revision: d5085617986e8ceabe7af02eb9c50f5350b3f980 URL: https://github.com/llvm/llvm-project/commit/d5085617986e8ceabe7af02eb9c50f5350b3f980 DIFF: https://github.com/llvm/llvm-project/commit/d5085617986e8ceabe7af02eb9c50f5350b3f980.diff LOG: [AIX] Support init priority attribute Differential Revision: https://reviews.llvm.org/D99291 Added: Modified: clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/CodeGen/aix-init-priority-attribute.cpp Removed: diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index c551901acc43..8131b5285075 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -499,7 +499,8 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, } else if (PerformInit && ISA) { EmitPointerToInitFunc(D, Addr, Fn, ISA); } else if (auto *IPA = D->getAttr()) { -OrderGlobalInits Key(IPA->getPriority(), PrioritizedCXXGlobalInits.size()); +OrderGlobalInitsOrStermFinalizers Key(IPA->getPriority(), + PrioritizedCXXGlobalInits.size()); PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn)); } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) || getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR) { @@ -566,6 +567,17 @@ static SmallString<128> getTransformedFileName(llvm::Module &M) { return FileName; } +static std::string getPrioritySuffix(unsigned int Priority) { + assert(Priority <= 65535 && "Priority should always be <= 65535."); + + // Compute the function suffix from priority. Prepend with zeroes to make + // sure the function names are also ordered as priorities. + std::string PrioritySuffix = llvm::utostr(Priority); + PrioritySuffix = std::string(6 - PrioritySuffix.size(), '0') + PrioritySuffix; + + return PrioritySuffix; +} + void CodeGenModule::EmitCXXGlobalInitFunc() { while (!CXXGlobalInits.empty() && !CXXGlobalInits.back()) @@ -577,12 +589,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() { llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false); const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction(); - const bool UseSinitAndSterm = getCXXABI().useSinitAndSterm(); // Create our global prioritized initialization function. if (!PrioritizedCXXGlobalInits.empty()) { -assert(!UseSinitAndSterm && "Prioritized sinit and sterm functions are not" -" supported yet."); - SmallVector LocalCXXGlobalInits; llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(), PrioritizedCXXGlobalInits.end()); @@ -596,14 +604,10 @@ CodeGenModule::EmitCXXGlobalInitFunc() { PrioE = std::upper_bound(I + 1, E, *I, GlobalInitPriorityCmp()); LocalCXXGlobalInits.clear(); - unsigned Priority = I->first.priority; - // Compute the function suffix from priority. Prepend with zeroes to make - // sure the function names are also ordered as priorities. - std::string PrioritySuffix = llvm::utostr(Priority); - // Priority is always <= 65535 (enforced by sema). - PrioritySuffix = std::string(6-PrioritySuffix.size(), '0')+PrioritySuffix; + + unsigned int Priority = I->first.priority; llvm::Function *Fn = CreateGlobalInitOrCleanUpFunction( - FTy, "_GLOBAL__I_" + PrioritySuffix, FI); + FTy, "_GLOBAL__I_" + getPrioritySuffix(Priority), FI); for (; I < PrioE; ++I) LocalCXXGlobalInits.push_back(I->second); @@ -614,7 +618,7 @@ CodeGenModule::EmitCXXGlobalInitFunc() { PrioritizedCXXGlobalInits.clear(); } - if (UseSinitAndSterm && CXXGlobalInits.empty()) + if (getCXXABI().useSinitAndSterm() && CXXGlobalInits.empty()) return; // Include the filename in the symbol name. Including "sub_" matches gcc @@ -649,12 +653,50 @@ CodeGenModule::EmitCXXGlobalInitFunc() { } void CodeGenModule::EmitCXXGlobalCleanUpFunc() { - if (CXXGlobalDtorsOrStermFinalizers.empty()) + if (CXXGlobalDtorsOrStermFinalizers.empty() && + PrioritizedCXXStermFinalizers.empty()) return; llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false); const CGFunctionInfo &FI = getTypes().arrangeNullaryFunction(); + // Create our global prioritized cleanup function. + if (!PrioritizedCXXStermFinalizers.empty()) { +SmallVector LocalCXXStermFinalizers; +llvm::array_pod_sort(PrioritizedCXXStermFinalizers.begin(), + PrioritizedCXXStermFinalizers.end()); +// Iterate over "chunks" of dtors with same priority and emit each chunk +// into separate function. Note - everything is sorted first by priority
[clang] e97071d - [NFC] Renaming PackStack to AlignPackStack
Author: Xiangling Liao Date: 2021-01-08T09:15:11-05:00 New Revision: e97071d7952068bbb5fee7bf9e46f304044d4aee URL: https://github.com/llvm/llvm-project/commit/e97071d7952068bbb5fee7bf9e46f304044d4aee DIFF: https://github.com/llvm/llvm-project/commit/e97071d7952068bbb5fee7bf9e46f304044d4aee.diff LOG: [NFC] Renaming PackStack to AlignPackStack This patch renames PackStack and related variable names to also contain align across Clang. As it is right now, Clang already uses one stack to record the information from both #pragma align and #pragma pack. Leaving it as PackStack is confusing, and could cause people to ignore #pragma align when developing code that interacts with PackStack. Differential Revision: https://reviews.llvm.org/D93901 Added: clang/test/Sema/Inputs/pragma-align-pack1.h clang/test/Sema/misleading-pragma-align-pack-diagnostics.c Modified: clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp Removed: diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 6b81494e8eff..acc3184aea97 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -568,14 +568,14 @@ class Sema final { // #pragma pack. // Sentinel to represent when the stack is set to mac68k alignment. static const unsigned kMac68kAlignmentSentinel = ~0U; - PragmaStack PackStack; - // The current #pragma pack values and locations at each #include. - struct PackIncludeState { + PragmaStack AlignPackStack; + // The current #pragma align/pack values and locations at each #include. + struct AlignPackIncludeState { unsigned CurrentValue; SourceLocation CurrentPragmaLocation; bool HasNonDefaultValue, ShouldWarnOnInclude; }; - SmallVector PackIncludeStack; + SmallVector AlignPackIncludeStack; // Segment #pragmas. PragmaStack DataSegStack; PragmaStack BSSSegStack; @@ -9721,14 +9721,14 @@ class Sema final { void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment); - enum class PragmaPackDiagnoseKind { + enum class PragmaAlignPackDiagnoseKind { NonDefaultStateAtInclude, ChangedStateAtExit }; - void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind, -SourceLocation IncludeLoc); - void DiagnoseUnterminatedPragmaPack(); + void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, + SourceLocation IncludeLoc); + void DiagnoseUnterminatedPragmaAlignPack(); /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off]. void ActOnPragmaMSStruct(PragmaMSStructKind Kind); diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index b4fd9e95d28f..e9fc202f8d1d 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -681,8 +681,8 @@ class TypeIdx { MODULAR_CODEGEN_DECLS = 60, - /// Record code for \#pragma pack options. - PACK_PRAGMA_OPTIONS = 61, + /// Record code for \#pragma align/pack options. + ALIGN_PACK_PRAGMA_OPTIONS = 61, /// The stack of open #ifs/#ifdefs recorded in a preamble. PP_CONDITIONAL_STACK = 62, diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 94491e45b55b..1dc1be00ea3a 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -869,17 +869,17 @@ class ASTReader llvm::SmallVector FpPragmaStack; llvm::SmallVector FpPragmaStrings; - /// The pragma pack state. - Optional PragmaPackCurrentValue; - SourceLocation PragmaPackCurrentLocation; - struct PragmaPackStackEntry { + /// The pragma align/pack state. + Optional PragmaAlignPackCurrentValue; + SourceLocation PragmaAlignPackCurrentLocation; + struct PragmaAlignPackStackEntry { unsigned Value; SourceLocation Location; SourceLocation PushLocation; StringRef SlotLabel; }; - llvm::SmallVector PragmaPackStack; - llvm::SmallVector PragmaPackStrings; + llvm::SmallVector PragmaAlignPackStack; + llvm::SmallVector PragmaAlignPackStrings; /// The OpenCL extension settings. OpenCLOptions OpenCLExtensions; diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 83df76b967c4..975fe9b81250 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -120,8 +120,9 @@ class SemaPPCallbacks : public PPCallbacks { } IncludeStack.push_back(IncludeLoc); -S->DiagnoseNonDef
[clang] f0abe2a - [Frontend] Add pragma align natural and sort out pragma pack stack effect
Author: Xiangling Liao Date: 2021-01-13T10:53:24-05:00 New Revision: f0abe2aeaca76a24b1e17295ab797068c057a15d URL: https://github.com/llvm/llvm-project/commit/f0abe2aeaca76a24b1e17295ab797068c057a15d DIFF: https://github.com/llvm/llvm-project/commit/f0abe2aeaca76a24b1e17295ab797068c057a15d.diff LOG: [Frontend] Add pragma align natural and sort out pragma pack stack effect - Implemente the natural align for XL on AIX - Sort out pragma pack stack effect - Add -fxl-pragma-stack option to enable XL on AIX pragma stack effect Differential Revision: https://reviews.llvm.org/D87702 Added: clang/test/Driver/aix-pragma-pack.c clang/test/Layout/aix-power-natural-interaction.cpp clang/test/PCH/aix-pragma-pack.c clang/test/Sema/aix-pragma-pack-and-align.c Modified: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ASTWriter.h clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Parse/ParsePragma.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/Layout/aix-double-struct-member.cpp Removed: diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index c51e95fa6fa8..b30b91d3d4a6 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -681,6 +681,13 @@ def AlignMac68k : InheritableAttr { let Documentation = [Undocumented]; } +def AlignNatural : InheritableAttr { + // This attribute has no spellings as it is only ever created implicitly. + let Spellings = []; + let SemaHandler = 0; + let Documentation = [Undocumented]; +} + def AlwaysInline : InheritableAttr { let Spellings = [GCC<"always_inline">, Keyword<"__forceinline">]; let Subjects = SubjectList<[Function]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 717bf6e12ccd..b387736832a9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -854,6 +854,8 @@ def err_pragma_options_align_mac68k_target_unsupported : Error< def warn_pragma_pack_invalid_alignment : Warning< "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">, InGroup; +def err_pragma_pack_invalid_alignment : Error< + warn_pragma_pack_invalid_alignment.Text>; def warn_pragma_pack_non_default_at_include : Warning< "non-default #pragma pack value changes the alignment of struct or union " "members in the included file">, InGroup, @@ -887,6 +889,8 @@ def warn_cxx_ms_struct : Warning<"ms_struct may not produce Microsoft-compatible layouts for classes " "with base classes or virtual functions">, DefaultError, InGroup; +def err_pragma_pack_identifer_not_supported : Error< + "specifying an identifier within `#pragma pack` is not supported on this target">; def err_section_conflict : Error<"%0 causes a section type conflict with %1">; def err_no_base_classes : Error<"invalid use of '__super', %0 has no base classes">; def err_invalid_super_scope : Error<"invalid use of '__super', " diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 963fde5f3ad4..c01f0cca9c9c 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -354,6 +354,8 @@ ENUM_LANGOPT(VtorDispMode, MSVtorDispMode, 2, MSVtorDispMode::ForVBaseOverride, LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling") +LANGOPT(XLPragmaPack, 1, 0, "IBM XL #pragma pack handling") + LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation comments from system headers in the AST") LANGOPT(SanitizeAddressFieldPadding, 2, 0, "controls how aggressive is ASan " diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index acc3db40bdc7..9ea3feccddff 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1026,6 +1026,8 @@ defm apple_pragma_pack : BoolFOption<"apple-pragma-pack", "LangOpts->ApplePragmaPack", DefaultsToFalse, ChangedBy, ResetBy>; +def fxl_pragma_pack : Flag<["-"], "fxl-pragma-pack">, Group, Flags<[CC1Option]>, + HelpText<"Enable IBM XL #pragma pack handling">; def shared_libsan : Flag<["-"], "shared-libsan">, HelpText<"Dynamically link the sanitizer runtime">; def static_libsan : Flag<["-"], "static-libsan">, @@ -1966,6 +1968,7 @@ def fmudflapth : Flag<["-"], "fmudflapth">, Group; def fmudf