[clang] [clang] Add `__has_feature(swiftcc)` support (PR #85347)
https://github.com/aschwaighofer edited https://github.com/llvm/llvm-project/pull/85347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__has_feature(swiftcc)` support (PR #85347)
@@ -102,6 +102,9 @@ FEATURE(memory_sanitizer, FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo)) +FEATURE(swiftcc, aschwaighofer wrote: I think we should use `EXTENSION` instead of `FEATURE`. https://github.com/llvm/llvm-project/pull/85347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__has_feature(swiftcc)` support (PR #85347)
https://github.com/aschwaighofer requested changes to this pull request. In a past review (https://github.com/llvm/llvm-project/pull/72159), @AaronBallman (https://github.com/AaronBallman) noted that the existing use of `FEATURE` (as in `FEATURE(swiftasynccc,...`) was not the right qualifier to use. And it should have been an `EXTENSION` instead. We should use `EXTENSION` for the `swiftcc` check. Quoting from the top of the file: ``` // FEATURE(...) should be used to advertise support for standard language // features, whereas EXTENSION(...) should be used for clang extensions. Note // that many of the identifiers in this file don't follow this rule for backward // compatibility reasons. ``` https://github.com/llvm/llvm-project/pull/85347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__has_feature(swiftcc)` support (PR #85347)
https://github.com/aschwaighofer edited https://github.com/llvm/llvm-project/pull/85347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] SwiftCallingConv: Fix the splitVectorEntry function (PR #69953)
https://github.com/aschwaighofer closed https://github.com/llvm/llvm-project/pull/69953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] SwiftCallingConv: Fix the splitVectorEntry function (PR #69953)
https://github.com/aschwaighofer updated https://github.com/llvm/llvm-project/pull/69953 >From 3dcc80df1acfe192e70f531995dff7518589d1ec Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 18 Oct 2023 11:44:16 -0700 Subject: [PATCH] SwiftCallingConv: Fix the splitVectorEntry function When splitting an entry into multiple entries, the indices of the split entries are a combination of the original split entry's and the number of elements we split that entry to. --- clang/lib/CodeGen/SwiftCallingConv.cpp | 7 --- clang/test/CodeGen/64bit-swiftcall.c | 21 +++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp index 055dd3704386673..16fbf52a517db48 100644 --- a/clang/lib/CodeGen/SwiftCallingConv.cpp +++ b/clang/lib/CodeGen/SwiftCallingConv.cpp @@ -409,9 +409,10 @@ void SwiftAggLowering::splitVectorEntry(unsigned index) { CharUnits begin = Entries[index].Begin; for (unsigned i = 0; i != numElts; ++i) { -Entries[index].Type = eltTy; -Entries[index].Begin = begin; -Entries[index].End = begin + eltSize; +unsigned idx = index + i; +Entries[idx].Type = eltTy; +Entries[idx].Begin = begin; +Entries[idx].End = begin + eltSize; begin += eltSize; } } diff --git a/clang/test/CodeGen/64bit-swiftcall.c b/clang/test/CodeGen/64bit-swiftcall.c index 5290de2471e8e55..da6f18248c2af29 100644 --- a/clang/test/CodeGen/64bit-swiftcall.c +++ b/clang/test/CodeGen/64bit-swiftcall.c @@ -985,8 +985,8 @@ struct { } s; } union_het_vecint; TEST(union_het_vecint) -// CHECK: define{{.*}} swiftcc void @return_union_het_vecint(ptr noalias sret([[UNION:.+]]) -// CHECK: define{{.*}} swiftcc void @take_union_het_vecint(ptr +// CHECK: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_union_het_vecint() +// CHECK: define{{.*}} swiftcc void @take_union_het_vecint(i64 %0, i64 %1, i64 %2, i64 %3) typedef struct { float3 f3; @@ -1044,3 +1044,20 @@ typedef struct { // CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1) SWIFTCALL void use_atomic_padded(atomic_padded a) {} + + +typedef union { + float4 v; + float3 v2; + struct { +float a; +float b; +float c; +float d; + }; +} vector_union; + +TEST(vector_union) + +// CHECK-LABEL: define swiftcc { float, float, float, float } @return_vector_union() +// CHECK-LABEL: define swiftcc void @take_vector_union(float %0, float %1, float %2, float %3) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] SwiftCallingConv: Fix the splitVectorEntry function (PR #69953)
aschwaighofer wrote: The failures are not related to this PR / pre-existing. `clang/docs/ReleaseNotes.rst:` is not touched by this PR. ``` + echo '*** Checking for trailing whitespace left in Clang source files ***' -- | *** Checking for trailing whitespace left in Clang source files *** | + grep -rnI '[[:blank:]] clang/lib clang/include clang/docs | clang/docs/ReleaseNotes.rst:108: when targetting MSVC to match the behavior of MSVC. | + echo '*** Trailing whitespace has been found in Clang source files as described above ***' | *** Trailing whitespace has been found in Clang source files as described above *** ``` And the `CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp` failure also occurs in the baseline. https://github.com/llvm/llvm-project/pull/69953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] SwiftCallingConv: Fix the splitVectorEntry function (PR #69953)
https://github.com/aschwaighofer created https://github.com/llvm/llvm-project/pull/69953 When splitting an entry into multiple entries, the indices of the split entries are a combination of the original split entry's and the number of elements we split that entry to. Failure to do so resulted in non-sensical entries leading e.g to assertion failures in `getCoerceAndExpandTypes` and runtime failures in Swift programs. >From 82b964224b4590c1765ac9a48edde997532a67ba Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 18 Oct 2023 11:44:16 -0700 Subject: [PATCH] SwiftCallingConv: Fix the splitVectorEntry function When splitting an entry into multiple entries, the indices of the split entries are a combination of the original split entry's and the number of elements we split that entry to. --- clang/lib/CodeGen/SwiftCallingConv.cpp | 7 --- clang/test/CodeGen/64bit-swiftcall.c | 21 +++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp index 055dd3704386673..16fbf52a517db48 100644 --- a/clang/lib/CodeGen/SwiftCallingConv.cpp +++ b/clang/lib/CodeGen/SwiftCallingConv.cpp @@ -409,9 +409,10 @@ void SwiftAggLowering::splitVectorEntry(unsigned index) { CharUnits begin = Entries[index].Begin; for (unsigned i = 0; i != numElts; ++i) { -Entries[index].Type = eltTy; -Entries[index].Begin = begin; -Entries[index].End = begin + eltSize; +unsigned idx = index + i; +Entries[idx].Type = eltTy; +Entries[idx].Begin = begin; +Entries[idx].End = begin + eltSize; begin += eltSize; } } diff --git a/clang/test/CodeGen/64bit-swiftcall.c b/clang/test/CodeGen/64bit-swiftcall.c index 5290de2471e8e55..da6f18248c2af29 100644 --- a/clang/test/CodeGen/64bit-swiftcall.c +++ b/clang/test/CodeGen/64bit-swiftcall.c @@ -985,8 +985,8 @@ struct { } s; } union_het_vecint; TEST(union_het_vecint) -// CHECK: define{{.*}} swiftcc void @return_union_het_vecint(ptr noalias sret([[UNION:.+]]) -// CHECK: define{{.*}} swiftcc void @take_union_het_vecint(ptr +// CHECK: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_union_het_vecint() +// CHECK: define{{.*}} swiftcc void @take_union_het_vecint(i64 %0, i64 %1, i64 %2, i64 %3) typedef struct { float3 f3; @@ -1044,3 +1044,20 @@ typedef struct { // CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1) SWIFTCALL void use_atomic_padded(atomic_padded a) {} + + +typedef union { + float4 v; + float3 v2; + struct { +float a; +float b; +float c; +float d; + }; +} vector_union; + +TEST(vector_union) + +// CHECK-LABEL: define swiftcc { float, float, float, float } @return_vector_union() +// CHECK-LABEL: define swiftcc void @take_vector_union(float %0, float %1, float %2, float %3) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f670c5a - Add a new frontend flag `-fswift-async-fp={auto|always|never}`
Author: Arnold Schwaighofer Date: 2021-09-16T08:48:51-07:00 New Revision: f670c5aeeef09cd7b88e72cf8c1f2505d044a8ea URL: https://github.com/llvm/llvm-project/commit/f670c5aeeef09cd7b88e72cf8c1f2505d044a8ea DIFF: https://github.com/llvm/llvm-project/commit/f670c5aeeef09cd7b88e72cf8c1f2505d044a8ea.diff LOG: Add a new frontend flag `-fswift-async-fp={auto|always|never}` Summary: Introduce a new frontend flag `-fswift-async-fp={auto|always|never}` that controls how code generation sets the Swift extended async frame info bit. There are three possibilities: * `auto`: which determines how to set the bit based on deployment target, either statically or dynamically via `swift_async_extendedFramePointerFlags`. * `always`: default, always set the bit statically, regardless of deployment target. * `never`: never set the bit, regardless of deployment target. Differential Revision: https://reviews.llvm.org/D109451 Added: clang/test/CodeGen/swift-async-extended-fp.c Modified: clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Driver/Options.td clang/lib/CodeGen/BackendUtil.cpp clang/lib/Driver/ToolChains/Clang.cpp Removed: diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 737d2d70bf46..37900bf3ead1 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -440,6 +440,11 @@ CODEGENOPT(AAPCSBitfieldWidth, 1, 1) /// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only) CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1) +// Whether to emit Swift Async function extended frame information: auto, +// never, always. +ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2, +SwiftAsyncFramePointerKind::Always) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 617c255641ef..6a0bce0ad80a 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -125,6 +125,13 @@ class CodeGenOptions : public CodeGenOptionsBase { All, // Keep all frame pointers. }; + enum class SwiftAsyncFramePointerKind { +Auto, // Choose Swift async extended frame info based on deployment target. +Always, // Unconditionally emit Swift async extended frame info. +Never, // Don't emit Swift async extended frame info. +Default = Always, + }; + enum FiniteLoopsKind { Language, // Not specified, use language standard. Always, // All loops are assumed to be finite. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 84b22df09ddd..f0932a0bd1de 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1275,6 +1275,13 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Filename defining the list of functions/files to instrument">, MarshallingInfoStringVector>; +def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">, +Group, Flags<[CC1Option, CC1AsOption, CoreOption]>, MetaVarName<"">, +HelpText<"Control emission of Swift async extended frame info (option: auto, always, never)">, +Values<"auto,always,never">, +NormalizedValuesScope<"CodeGenOptions::SwiftAsyncFramePointerKind">, +NormalizedValues<["Auto", "Always", "Never"]>, +MarshallingInfoEnum, "Always">; defm addrsig : BoolFOption<"addrsig", CodeGenOpts<"Addrsig">, DefaultFalse, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 2fdad81241c6..e31fa3f9f94d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -582,6 +582,21 @@ static bool initTargetOptions(DiagnosticsEngine , Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex; Options.LoopAlignment = CodeGenOpts.LoopAlignment; + switch (CodeGenOpts.getSwiftAsyncFramePointer()) { + case CodeGenOptions::SwiftAsyncFramePointerKind::Auto: +Options.SwiftAsyncFramePointer = +SwiftAsyncFramePointerMode::DeploymentBased; +break; + + case CodeGenOptions::SwiftAsyncFramePointerKind::Always: +Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Always; +break; + + case CodeGenOptions::SwiftAsyncFramePointerKind::Never: +Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Never; +break; + } + Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile; Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll; Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index
[clang] 9eb99d2 - CodeGen: No need to check for isExternC if HasStrictReturn is already false
Author: Arnold Schwaighofer Date: 2021-08-11T07:42:48-07:00 New Revision: 9eb99d2e73b5598076fbdd8abceb3549afa8f0ae URL: https://github.com/llvm/llvm-project/commit/9eb99d2e73b5598076fbdd8abceb3549afa8f0ae DIFF: https://github.com/llvm/llvm-project/commit/9eb99d2e73b5598076fbdd8abceb3549afa8f0ae.diff LOG: CodeGen: No need to check for isExternC if HasStrictReturn is already false NFC intended. Differential Revision: https://reviews.llvm.org/D107841 Added: Modified: clang/lib/CodeGen/CGCall.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 1296dfa18b9a5..43be6755a0745 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2241,7 +2241,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, // C++ explicitly makes returning undefined values UB. C's rule only applies // to used values, so we never mark them noundef for now. bool HasStrictReturn = getLangOpts().CPlusPlus; - if (TargetDecl) { + if (TargetDecl && HasStrictReturn) { if (const FunctionDecl *FDecl = dyn_cast(TargetDecl)) HasStrictReturn &= !FDecl->isExternC(); else if (const VarDecl *VDecl = dyn_cast(TargetDecl)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4163449 - Teach the swift calling convention about _Atomic types
Author: Arnold Schwaighofer Date: 2020-08-31T07:07:25-07:00 New Revision: 41634497d4fd21f28d08ac6f538ca4045f386c95 URL: https://github.com/llvm/llvm-project/commit/41634497d4fd21f28d08ac6f538ca4045f386c95 DIFF: https://github.com/llvm/llvm-project/commit/41634497d4fd21f28d08ac6f538ca4045f386c95.diff LOG: Teach the swift calling convention about _Atomic types rdar://67351073 Differential Revision: https://reviews.llvm.org/D86218 Added: Modified: clang/lib/CodeGen/SwiftCallingConv.cpp clang/test/CodeGen/64bit-swiftcall.c Removed: diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp index cbbe208426f7..1d712f4fde3c 100644 --- a/clang/lib/CodeGen/SwiftCallingConv.cpp +++ b/clang/lib/CodeGen/SwiftCallingConv.cpp @@ -93,11 +93,24 @@ void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) { // Just add it all as opaque. addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type)); - // Everything else is scalar and should not convert as an LLVM aggregate. +// Atomic types. + } else if (const auto *atomicType = type->getAs()) { +auto valueType = atomicType->getValueType(); +auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType); +auto valueSize = CGM.getContext().getTypeSizeInChars(valueType); + +addTypedData(atomicType->getValueType(), begin); + +// Add atomic padding. +auto atomicPadding = atomicSize - valueSize; +if (atomicPadding > CharUnits::Zero()) + addOpaqueData(begin + valueSize, begin + atomicSize); + +// Everything else is scalar and should not convert as an LLVM aggregate. } else { // We intentionally convert as !ForMem because we want to preserve // that a type was an i1. -auto llvmType = CGM.getTypes().ConvertType(type); +auto *llvmType = CGM.getTypes().ConvertType(type); addTypedData(llvmType, begin); } } diff --git a/clang/test/CodeGen/64bit-swiftcall.c b/clang/test/CodeGen/64bit-swiftcall.c index 51fb8545551f..5843b8cde4dc 100644 --- a/clang/test/CodeGen/64bit-swiftcall.c +++ b/clang/test/CodeGen/64bit-swiftcall.c @@ -10,6 +10,9 @@ #define ERROR __attribute__((swift_error_result)) #define CONTEXT __attribute__((swift_context)) +// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } } +// CHECK-DAG: %struct.packed = type <{ i64, i8 }> +// // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 } /*/ @@ -1042,3 +1045,27 @@ void no_lifetime_markers() { // CHECK-NOT: call void @llvm.lifetime. take_int5(return_int5()); } + +typedef struct { + unsigned long long a; + unsigned long long b; +} double_word; + +typedef struct { + _Atomic(double_word) a; +} atomic_double_word; + +// CHECK-LABEL: use_atomic(i64 %0, i64 %1) +SWIFTCALL void use_atomic(atomic_double_word a) {} + +typedef struct { + unsigned long long a; + unsigned char b; +} __attribute__((packed)) packed; + +typedef struct { + _Atomic(packed) a; +} atomic_padded; + +// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1) +SWIFTCALL void use_atomic_padded(atomic_padded a) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4a8120c - Fix ConstantAggregateBuilderBase::getRelativeOffset
Author: Arnold Schwaighofer Date: 2020-06-15T12:23:20-07:00 New Revision: 4a8120ca9fb904b50e6940457e0f891ca1fdb605 URL: https://github.com/llvm/llvm-project/commit/4a8120ca9fb904b50e6940457e0f891ca1fdb605 DIFF: https://github.com/llvm/llvm-project/commit/4a8120ca9fb904b50e6940457e0f891ca1fdb605.diff LOG: Fix ConstantAggregateBuilderBase::getRelativeOffset Summary: If a record has a mix of relative pointers and other fields they wouldn't necessarily be the same. Fallout from D77592. rdar://64309883 Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81857 Added: Modified: clang/lib/CodeGen/ConstantInitBuilder.cpp Removed: diff --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CodeGen/ConstantInitBuilder.cpp index 326f079e82fa..24e3ca19709c 100644 --- a/clang/lib/CodeGen/ConstantInitBuilder.cpp +++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp @@ -129,7 +129,7 @@ llvm::Constant * ConstantAggregateBuilderBase::getRelativeOffset(llvm::IntegerType *offsetType, llvm::Constant *target) { return getRelativeOffsetToPosition(offsetType, target, - Builder.SelfReferences.size()); + Builder.Buffer.size() - Begin); } llvm::Constant *ConstantAggregateBuilderBase::getRelativeOffsetToPosition( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 153dadf - [clang] CodeGen: Make getOrEmitProtocol public for Swift
Author: Arnold Schwaighofer Date: 2020-04-01T08:55:56-07:00 New Revision: 153dadf3a3ca3c47f8c0fb718ec96616a05e42fd URL: https://github.com/llvm/llvm-project/commit/153dadf3a3ca3c47f8c0fb718ec96616a05e42fd DIFF: https://github.com/llvm/llvm-project/commit/153dadf3a3ca3c47f8c0fb718ec96616a05e42fd.diff LOG: [clang] CodeGen: Make getOrEmitProtocol public for Swift Summary: Swift would like to use clang's apis to emit protocol declarations. This commits adds the public API: ``` emitObjCProtocolObject(CodeGenModule , const ObjCProtocolDecl *p); ``` rdar://60888524 Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77077 Added: Modified: clang/include/clang/CodeGen/CodeGenABITypes.h clang/lib/CodeGen/CGObjCGNU.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/CodeGen/CGObjCRuntime.cpp clang/lib/CodeGen/CGObjCRuntime.h Removed: diff --git a/clang/include/clang/CodeGen/CodeGenABITypes.h b/clang/include/clang/CodeGen/CodeGenABITypes.h index 31f0cea57232..5f4af7fd2a36 100644 --- a/clang/include/clang/CodeGen/CodeGenABITypes.h +++ b/clang/include/clang/CodeGen/CodeGenABITypes.h @@ -28,11 +28,12 @@ #include "clang/CodeGen/CGFunctionInfo.h" namespace llvm { - class DataLayout; - class Module; - class Function; - class FunctionType; - class Type; +class Constant; +class DataLayout; +class Module; +class Function; +class FunctionType; +class Type; } namespace clang { @@ -44,6 +45,7 @@ class CoverageSourceInfo; class DiagnosticsEngine; class HeaderSearchOptions; class ObjCMethodDecl; +class ObjCProtocolDecl; class PreprocessorOptions; namespace CodeGen { @@ -137,6 +139,13 @@ llvm::Function *getNonTrivialCStructDestructor(CodeGenModule , CharUnits DstAlignment, bool IsVolatile, QualType QT); +/// Get a pointer to a protocol object for the given declaration, emitting it if +/// it hasn't already been emitted in this translation unit. Note that the ABI +/// for emitting a protocol reference in code (e.g. for a protocol expression) +/// in most runtimes is not as simple as just materializing a pointer to this +/// object. +llvm::Constant *emitObjCProtocolObject(CodeGenModule , + const ObjCProtocolDecl *p); } // end namespace CodeGen } // end namespace clang diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index db78309e9fd9..35b926808492 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -617,6 +617,13 @@ class CGObjCGNU : public CGObjCRuntime { llvm::Value *GenerateProtocolRef(CodeGenFunction , const ObjCProtocolDecl *PD) override; void GenerateProtocol(const ObjCProtocolDecl *PD) override; + + virtual llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD); + + llvm::Constant *GetOrEmitProtocol(const ObjCProtocolDecl *PD) override { +return GenerateProtocolRef(PD); + } + llvm::Function *ModuleInitFunction() override; llvm::FunctionCallee GetPropertyGetFunction() override; llvm::FunctionCallee GetPropertySetFunction() override; @@ -1348,7 +1355,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { void GenerateProtocol(const ObjCProtocolDecl *PD) override { // Do nothing - we only emit referenced protocols. } - llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) { + llvm::Constant *GenerateProtocolRef(const ObjCProtocolDecl *PD) override { std::string ProtocolName = PD->getNameAsString(); auto * = ExistingProtocols[ProtocolName]; if (Protocol) @@ -3039,13 +3046,18 @@ CGObjCGNU::GenerateProtocolList(ArrayRef Protocols) { llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction , const ObjCProtocolDecl *PD) { + auto protocol = GenerateProtocolRef(PD); + llvm::Type *T = + CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType()); + return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T)); +} + +llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) { llvm::Constant * = ExistingProtocols[PD->getNameAsString()]; if (!protocol) GenerateProtocol(PD); assert(protocol && "Unknown protocol"); - llvm::Type *T = -CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType()); - return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T)); + return protocol; } llvm::Constant * diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 87fd51b5d8b1..3986310eaa70 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -1107,11 +1107,6 @@ class CGObjCCommonMac : public CodeGen::CGObjCRuntime { void GenerateProtocol(const ObjCProtocolDecl *PD)
r317589 - SystemZ Swift TargetInfo: swifterror support in the backend is broken
Author: arnolds Date: Tue Nov 7 08:40:51 2017 New Revision: 317589 URL: http://llvm.org/viewvc/llvm-project?rev=317589=rev Log: SystemZ Swift TargetInfo: swifterror support in the backend is broken Return false for swifterror support until the backend is fixed. Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=317589=317588=317589=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Nov 7 08:40:51 2017 @@ -6319,7 +6319,7 @@ public: return occupiesMoreThan(CGT, scalars, /*total*/ 4); } bool isSwiftErrorInRegister() const override { -return true; +return false; } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305956 - SwiftCC: Perform physical layout when computing coercion types
Author: arnolds Date: Wed Jun 21 16:43:40 2017 New Revision: 305956 URL: http://llvm.org/viewvc/llvm-project?rev=305956=rev Log: SwiftCC: Perform physical layout when computing coercion types We need to take type alignment padding into account whe computing physical layouts. The layout must be compatible with the input layout, offsets are defined in terms of offsets within a packed struct which are computed in terms of the alloc size of a type. Usingthe store size we would insert padding for the following type for example: struct { int3 v; long long l; } __attribute((packed)) On x86-64 int3 is padded to int4 alignment. The swiftcc type would be <{ <3 x float>, [4 x i8], i64 }> which is not compatible with <{ <3 x float>, i64 }>. The latter has i64 at offset 16 and the former at offset 20. rdar://32618125 Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp cfe/trunk/test/CodeGen/64bit-swiftcall.c Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=305956=305955=305956=diff == --- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original) +++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Wed Jun 21 16:43:40 2017 @@ -57,6 +57,10 @@ static CharUnits getTypeStoreSize(CodeGe return CharUnits::fromQuantity(CGM.getDataLayout().getTypeStoreSize(type)); } +static CharUnits getTypeAllocSize(CodeGenModule , llvm::Type *type) { + return CharUnits::fromQuantity(CGM.getDataLayout().getTypeAllocSize(type)); +} + void SwiftAggLowering::addTypedData(QualType type, CharUnits begin) { // Deal with various aggregate types as special cases: @@ -542,7 +546,9 @@ SwiftAggLowering::getCoerceAndExpandType packed = true; elts.push_back(entry.Type); -lastEnd = entry.End; + +lastEnd = entry.Begin + getTypeAllocSize(CGM, entry.Type); +assert(entry.End <= lastEnd); } // We don't need to adjust 'packed' to deal with possible tail padding Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=305956=305955=305956=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Wed Jun 21 16:43:40 2017 @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86-64 // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64 @@ -1014,3 +1015,20 @@ typedef struct { TEST(struct_v1f3) // ARM64-LABEL: define swiftcc { <2 x float>, float } @return_struct_v1f3() // ARM64-LABEL: define swiftcc void @take_struct_v1f3(<2 x float>, float) + +typedef struct { + int3 vect; + unsigned long long val; +} __attribute__((packed)) padded_alloc_size_vector; +TEST(padded_alloc_size_vector) +// X86-64-LABEL: take_padded_alloc_size_vector(<3 x i32>, i64) +// X86-64-NOT: [4 x i8] +// x86-64: ret void + +typedef union { + float f1; + float3 fv2; +} union_hom_fp_partial2; +TEST(union_hom_fp_partial2) +// X86-64-LABEL: take_union_hom_fp_partial2(i64, float) +// ARM64-LABEL: take_union_hom_fp_partial2(i64, float) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM
No, my change should have no effect on LLVM CodeGen. I don’t see how a change to clang’s CodeGen i.e different module that cannot affect an llvm test using llc. This API is only used by swift calling convention lowering. > On May 26, 2017, at 2:33 PM, Evgenii Stepanov <eugeni.stepa...@gmail.com> > wrote: > > I've got the same failure locally w/o MSan, in a regular > release+assertions build on linux x86_64. > > On Fri, May 26, 2017 at 2:15 PM, Vitaly Buka via cfe-commits > <cfe-commits@lists.llvm.org> wrote: >> Could this be the patch >> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio >> >> FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818) >> TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll' >> FAILED >> Script: >> -- >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0 >> -mtriple=armv7-apple-ios | >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> --check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE >> --check-prefix=ARM-ENABLE >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0 >> -mtriple=armv7-apple-ios | >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> --check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE >> --check-prefix=ARM-DISABLE >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0 >> -mtriple=thumbv7-apple-ios | >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE >> --check-prefix=THUMB-ENABLE >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0 >> -mtriple=thumbv7-apple-ios | >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll >> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE >> --check-prefix=THUMB-DISABLE >> -- >> Exit Code: 1 >> >> Command Output (stderr): >> -- >> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10: >> error: expected string not found in input >> ; CHECK: bl >> ^ >> :375:7: note: scanning from here >> vldr s0, LCPI12_0 >> ^ >> :377:2: note: possible intended match here >> bx lr >> ^ >> >> >> >> On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits >> <cfe-commits@lists.llvm.org> wrote: >>> >>> Author: arnolds >>> Date: Fri May 26 13:11:54 2017 >>> New Revision: 304017 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev >>> Log: >>> CodeGen: Define Swift's legal vector types for AArch64, ARM >>> >>> rdar://32401301 >>> >>> Modified: >>>cfe/trunk/lib/CodeGen/TargetInfo.cpp >>>cfe/trunk/test/CodeGen/64bit-swiftcall.c >>>cfe/trunk/test/CodeGen/arm-swiftcall.c >>> >>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff >>> >>>
r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM
Author: arnolds Date: Fri May 26 13:11:54 2017 New Revision: 304017 URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev Log: CodeGen: Define Swift's legal vector types for AArch64, ARM rdar://32401301 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGen/64bit-swiftcall.c cfe/trunk/test/CodeGen/arm-swiftcall.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017 @@ -4821,6 +4821,9 @@ private: bool isSwiftErrorInRegister() const override { return true; } + + bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy, + unsigned elts) const override; }; class AArch64TargetCodeGenInfo : public TargetCodeGenInfo { @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType return false; } +bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize, + llvm::Type *eltTy, + unsigned elts) const { + if (!llvm::isPowerOf2_32(elts)) +return false; + if (totalSize.getQuantity() != 8 && + (totalSize.getQuantity() != 16 || elts == 1)) +return false; + return true; +} + bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { // Homogeneous aggregates for AAPCS64 must have base types of a floating // point type or a short-vector type. This is the same as the 32-bit ABI, @@ -5382,6 +5396,8 @@ private: bool isSwiftErrorInRegister() const override { return true; } + bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy, + unsigned elts) const override; }; class ARMTargetCodeGenInfo : public TargetCodeGenInfo { @@ -5894,6 +5910,20 @@ bool ARMABIInfo::isIllegalVectorType(Qua return false; } +bool ARMABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize, + llvm::Type *eltTy, + unsigned numElts) const { + if (!llvm::isPowerOf2_32(numElts)) +return false; + unsigned size = getDataLayout().getTypeStoreSizeInBits(eltTy); + if (size > 64) +return false; + if (vectorSize.getQuantity() != 8 && + (vectorSize.getQuantity() != 16 || numElts == 1)) +return false; + return true; +} + bool ARMABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { // Homogeneous aggregates for AAPCS-VFP must have base types of float, // double, or 64-bit or 128-bit vectors. Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=304017=304016=304017=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Fri May 26 13:11:54 2017 @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64 // REQUIRES: aarch64-registered-target,x86-registered-target @@ -60,6 +61,7 @@ SWIFTCALL void context_error_2(short s, /** LOWERING */ /*/ +typedef float float3 __attribute__((ext_vector_type(3))); typedef float float4 __attribute__((ext_vector_type(4))); typedef float float8 __attribute__((ext_vector_type(8))); typedef double double2 __attribute__((ext_vector_type(2))); @@ -1005,3 +1007,10 @@ struct { TEST(union_het_vecint) // CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias sret // CHECK: define swiftcc void @take_union_het_vecint([[UNION]]* + +typedef struct { + float3 f3; +} struct_v1f3; +TEST(struct_v1f3) +// ARM64-LABEL: define swiftcc { <2 x float>, float } @return_struct_v1f3() +// ARM64-LABEL: define swiftcc void @take_struct_v1f3(<2 x float>, float) Modified: cfe/trunk/test/CodeGen/arm-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-swiftcall.c?rev=304017=304016=304017=diff == --- cfe/trunk/test/CodeGen/arm-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/arm-swiftcall.c Fri May 26 13:11:54 2017 @@ -57,6 +57,7 @@ SWIFTCALL void context_error_2(short s, /** LOWERING */
r288394 - swiftcc: Add an api to query whether a target ABI stores swifterror in a register
Author: arnolds Date: Thu Dec 1 12:07:38 2016 New Revision: 288394 URL: http://llvm.org/viewvc/llvm-project?rev=288394=rev Log: swiftcc: Add an api to query whether a target ABI stores swifterror in a register Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h cfe/trunk/lib/CodeGen/ABIInfo.h cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=288394=288393=288394=diff == --- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original) +++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Thu Dec 1 12:07:38 2016 @@ -160,6 +160,9 @@ ABIArgInfo classifyArgumentType(CodeGenM /// private interface for Clang. void computeABIInfo(CodeGenModule , CGFunctionInfo ); +/// Is swifterror lowered to a register by the target ABI. +bool isSwiftErrorLoweredInRegister(CodeGenModule ); + } // end namespace swiftcall } // end namespace CodeGen } // end namespace clang Modified: cfe/trunk/lib/CodeGen/ABIInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=288394=288393=288394=diff == --- cfe/trunk/lib/CodeGen/ABIInfo.h (original) +++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Dec 1 12:07:38 2016 @@ -142,6 +142,8 @@ namespace swiftcall { llvm::Type *eltTy, unsigned elts) const; +virtual bool isSwiftErrorInRegister() const = 0; + static bool classof(const ABIInfo *info) { return info->supportsSwift(); } Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=288394=288393=288394=diff == --- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original) +++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Dec 1 12:07:38 2016 @@ -828,3 +828,8 @@ void swiftcall::computeABIInfo(CodeGenMo argInfo.info = classifyArgumentType(CGM, argInfo.type); } } + +// Is swifterror lowered to a register by the target ABI. +bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule ) { + return getSwiftABIInfo(CGM).isSwiftErrorInRegister(); +} Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=288394=288393=288394=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Dec 1 12:07:38 2016 @@ -958,6 +958,11 @@ public: // scalar registers. return occupiesMoreThan(CGT, scalars, /*total*/ 3); } + + bool isSwiftErrorInRegister() const override { +// x86-32 lowering does not support passing swifterror in a register. +return false; + } }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { @@ -2012,6 +2017,9 @@ public: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { +return true; + } }; /// WinX86_64ABIInfo - The Windows X86_64 ABI information. @@ -2043,6 +2051,10 @@ public: return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { +return true; + } + private: ABIArgInfo classify(QualType Ty, unsigned , bool IsReturnType) const; @@ -4628,6 +4640,9 @@ private: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { +return true; + } }; class AArch64TargetCodeGenInfo : public TargetCodeGenInfo { @@ -5181,6 +5196,9 @@ private: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { +return true; + } }; class ARMTargetCodeGenInfo : public TargetCodeGenInfo { @@ -5949,6 +5967,9 @@ public: bool asReturnValue) const override { return occupiesMoreThan(CGT, scalars, /*total*/ 4); } + bool isSwiftErrorInRegister() const override { +return true; + } }; class SystemZTargetCodeGenInfo : public TargetCodeGenInfo { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284285 - Add more swift calling convention tests
Author: arnolds Date: Fri Oct 14 16:55:56 2016 New Revision: 284285 URL: http://llvm.org/viewvc/llvm-project?rev=284285=rev Log: Add more swift calling convention tests Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c cfe/trunk/test/CodeGen/arm-swiftcall.c Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284285=284284=284285=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Fri Oct 14 16:55:56 2016 @@ -71,6 +71,9 @@ typedef int int3 __attribute__((ext_vect typedef int int4 __attribute__((ext_vector_type(4))); typedef int int5 __attribute__((ext_vector_type(5))); typedef int int8 __attribute__((ext_vector_type(8))); +typedef char char16 __attribute__((ext_vector_type(16))); +typedef short short8 __attribute__((ext_vector_type(8))); +typedef long long long2 __attribute__((ext_vector_type(2))); #define TEST(TYPE) \ SWIFTCALL TYPE return_##TYPE(void) { \ @@ -510,8 +513,38 @@ typedef struct { double d1; } struct_d2; TEST(struct_d2) + // CHECK-LABEL: define swiftcc { double, double } @return_struct_d2() // CHECK-LABEL: define swiftcc void @take_struct_d2(double, double) +typedef struct { + double d0; + double d1; + double d2; +} struct_d3; +TEST(struct_d3) +// CHECK-LABEL: define swiftcc { double, double, double } @return_struct_d3() +// CHECK-LABEL: define swiftcc void @take_struct_d3(double, double, double) + +typedef struct { + double d0; + double d1; + double d2; + double d3; +} struct_d4; +TEST(struct_d4) +// CHECK-LABEL: define swiftcc { double, double, double, double } @return_struct_d4() +// CHECK-LABEL: define swiftcc void @take_struct_d4(double, double, double, double) + +typedef struct { + double d0; + double d1; + double d2; + double d3; + double d4; +} struct_d5; +TEST(struct_d5) +// CHECK: define swiftcc void @return_struct_d5([[STRUCT5:%.*]]* noalias sret +// CHECK: define swiftcc void @take_struct_d5([[STRUCT5]] typedef struct { char c0; @@ -700,6 +733,263 @@ TEST(struct_l5) // CHECK: define swiftcc void @return_struct_l5([[STRUCT5:%.*]]* noalias sret // CHECK: define swiftcc void @take_struct_l5([[STRUCT5]]* +typedef struct { + char16 c0; +} struct_vc1; +TEST(struct_vc1) +// CHECK-LABEL: define swiftcc <16 x i8> @return_struct_vc1() +// CHECK-LABEL: define swiftcc void @take_struct_vc1(<16 x i8>) + +typedef struct { + char16 c0; + char16 c1; +} struct_vc2; +TEST(struct_vc2) +// CHECK-LABEL: define swiftcc { <16 x i8>, <16 x i8> } @return_struct_vc2() +// CHECK-LABEL: define swiftcc void @take_struct_vc2(<16 x i8>, <16 x i8>) + +typedef struct { + char16 c0; + char16 c1; + char16 c2; +} struct_vc3; +TEST(struct_vc3) +// CHECK-LABEL: define swiftcc { <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc3() +// CHECK-LABEL: define swiftcc void @take_struct_vc3(<16 x i8>, <16 x i8>, <16 x i8>) + +typedef struct { + char16 c0; + char16 c1; + char16 c2; + char16 c3; +} struct_vc4; +TEST(struct_vc4) +// CHECK-LABEL: define swiftcc { <16 x i8>, <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc4() +// CHECK-LABEL: define swiftcc void @take_struct_vc4(<16 x i8>, <16 x i8>, <16 x i8>, <16 x i8>) + +typedef struct { + char16 c0; + char16 c1; + char16 c2; + char16 c3; + char16 c4; +} struct_vc5; +TEST(struct_vc5) +// CHECK: define swiftcc void @return_struct_vc5([[STRUCT:%.*]]* noalias sret +// CHECK: define swiftcc void @take_struct_vc5([[STRUCT]] + +typedef struct { + short8 c0; +} struct_vs1; +TEST(struct_vs1) +// CHECK-LABEL: define swiftcc <8 x i16> @return_struct_vs1() +// CHECK-LABEL: define swiftcc void @take_struct_vs1(<8 x i16>) + +typedef struct { + short8 c0; + short8 c1; +} struct_vs2; +TEST(struct_vs2) +// CHECK-LABEL: define swiftcc { <8 x i16>, <8 x i16> } @return_struct_vs2() +// CHECK-LABEL: define swiftcc void @take_struct_vs2(<8 x i16>, <8 x i16>) + +typedef struct { + short8 c0; + short8 c1; + short8 c2; +} struct_vs3; +TEST(struct_vs3) +// CHECK-LABEL: define swiftcc { <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs3() +// CHECK-LABEL: define swiftcc void @take_struct_vs3(<8 x i16>, <8 x i16>, <8 x i16>) + +typedef struct { + short8 c0; + short8 c1; + short8 c2; + short8 c3; +} struct_vs4; +TEST(struct_vs4) +// CHECK-LABEL: define swiftcc { <8 x i16>, <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs4() +// CHECK-LABEL: define swiftcc void @take_struct_vs4(<8 x i16>, <8 x i16>, <8 x i16>, <8 x i16>) + +typedef struct { + short8 c0; + short8 c1; + short8 c2; + short8 c3; + short8 c4; +} struct_vs5; +TEST(struct_vs5) +// CHECK: define swiftcc void @return_struct_vs5([[STRUCT:%.*]]* noalias sret +// CHECK: define swiftcc void @take_struct_vs5([[STRUCT]] + +typedef struct { + int4 c0; +} struct_vi1; +TEST(struct_vi1) +// CHECK-LABEL: define swiftcc
Re: r284174 - Disable swiftcall test on windows: More brutal way to appease windows bots
https://llvm.org/bugs/show_bug.cgi?id=30699 > On Oct 14, 2016, at 7:11 AM, Robinson, Paul <paul.robin...@sony.com> wrote: > > Is there a bug to track this problem so it doesn't get lost? > --paulr > > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of > Reid Kleckner via cfe-commits > Sent: Thursday, October 13, 2016 4:02 PM > To: Arnold Schwaighofer > Cc: cfe-commits > Subject: Re: r284174 - Disable swiftcall test on windows: More brutal way to > appease windows bots > > These kinds of crashes typically happen when you have something like a > use-after-destroy of a temporary, like a misuse of Twine or > std::initializer_list. > > On Thu, Oct 13, 2016 at 3:47 PM, Arnold Schwaighofer via cfe-commits > <cfe-commits@lists.llvm.org> wrote: > Author: arnolds > Date: Thu Oct 13 17:47:03 2016 > New Revision: 284174 > > URL: http://llvm.org/viewvc/llvm-project?rev=284174=rev > Log: > Disable swiftcall test on windows: More brutal way to appease windows bots > > The backtrace on the bot does not give me any indication what is wrong. > The test case interestingly passes in stage2 of the build. > I don't have a way of debugging this. > > Disable the test on windows and hope if there is truly a bug in the code that > was causing we will eventually run into this on other platforms. > > Modified: > cfe/trunk/test/CodeGen/64bit-swiftcall.c > > Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284174=284173=284174=diff > == > --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) > +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 17:47:03 2016 > @@ -3,6 +3,9 @@ > > // REQUIRES: aarch64-registered-target,x86-registered-target > > +// The union_het_vecint test case crashes on windows bot but only in stage1 > and not in stage2. > +// UNSUPPORTED: system-windows > + > #define SWIFTCALL __attribute__((swiftcall)) > #define OUT __attribute__((swift_indirect_result)) > #define ERROR __attribute__((swift_error_result)) > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284174 - Disable swiftcall test on windows: More brutal way to appease windows bots
Author: arnolds Date: Thu Oct 13 17:47:03 2016 New Revision: 284174 URL: http://llvm.org/viewvc/llvm-project?rev=284174=rev Log: Disable swiftcall test on windows: More brutal way to appease windows bots The backtrace on the bot does not give me any indication what is wrong. The test case interestingly passes in stage2 of the build. I don't have a way of debugging this. Disable the test on windows and hope if there is truly a bug in the code that was causing we will eventually run into this on other platforms. Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284174=284173=284174=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 17:47:03 2016 @@ -3,6 +3,9 @@ // REQUIRES: aarch64-registered-target,x86-registered-target +// The union_het_vecint test case crashes on windows bot but only in stage1 and not in stage2. +// UNSUPPORTED: system-windows + #define SWIFTCALL __attribute__((swiftcall)) #define OUT __attribute__((swift_indirect_result)) #define ERROR __attribute__((swift_error_result)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284162 - Add required targets to tests to (hopefully) appease bots
Author: arnolds Date: Thu Oct 13 15:59:23 2016 New Revision: 284162 URL: http://llvm.org/viewvc/llvm-project?rev=284162=rev Log: Add required targets to tests to (hopefully) appease bots Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284162=284161=284162=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 15:59:23 2016 @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s +// REQUIRES: aarch64-registered-target,x86-registered-target + #define SWIFTCALL __attribute__((swiftcall)) #define OUT __attribute__((swift_indirect_result)) #define ERROR __attribute__((swift_error_result)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284150 - Swift Calling Convention: Fix out of bounds access
Author: arnolds Date: Thu Oct 13 14:19:37 2016 New Revision: 284150 URL: http://llvm.org/viewvc/llvm-project?rev=284150=rev Log: Swift Calling Convention: Fix out of bounds access Use iterator instead of address of element in vector It is not valid to access one after the last element. rdar://28759508 Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp cfe/trunk/test/CodeGen/64bit-swiftcall.c Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=284150=284149=284150=diff == --- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original) +++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Oct 13 14:19:37 2016 @@ -384,7 +384,7 @@ void SwiftAggLowering::splitVectorEntry( auto eltTy = split.first; CharUnits eltSize = getTypeStoreSize(CGM, eltTy); auto numElts = split.second; - Entries.insert([index + 1], numElts - 1, StorageEntry()); + Entries.insert(Entries.begin() + index + 1, numElts - 1, StorageEntry()); CharUnits begin = Entries[index].Begin; for (unsigned i = 0; i != numElts; ++i) { Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284150=284149=284150=diff == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 14:19:37 2016 @@ -694,3 +694,22 @@ typedef struct { TEST(struct_l5) // CHECK: define swiftcc void @return_struct_l5([[STRUCT5:%.*]]* noalias sret // CHECK: define swiftcc void @take_struct_l5([[STRUCT5]]* + + +// Don't crash. +typedef union { +int4 v[2]; +struct { + int LSW; + int d7; + int d6; + int d5; + int d4; + int d3; + int d2; + int MSW; +} s; +} union_het_vecint; +TEST(union_het_vecint) +// CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias sret +// CHECK: define swiftcc void @take_union_het_vecint([[UNION]]* ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284133 - Add more 64bit swiftcall convention tests
Author: arnolds Date: Thu Oct 13 12:17:36 2016 New Revision: 284133 URL: http://llvm.org/viewvc/llvm-project?rev=284133=rev Log: Add more 64bit swiftcall convention tests Added: cfe/trunk/test/CodeGen/64bit-swiftcall.c Added: cfe/trunk/test/CodeGen/64bit-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284133=auto == --- cfe/trunk/test/CodeGen/64bit-swiftcall.c (added) +++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 12:17:36 2016 @@ -0,0 +1,696 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s + +#define SWIFTCALL __attribute__((swiftcall)) +#define OUT __attribute__((swift_indirect_result)) +#define ERROR __attribute__((swift_error_result)) +#define CONTEXT __attribute__((swift_context)) + +// CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, float 0.00e+00, float 0.00e+00 } + +/*/ +/** PARAMETER ABIS ***/ +/*/ + +SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {} +// CHECK-LABEL: define {{.*}} void @indirect_result_1(i32* noalias sret align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +// TODO: maybe this shouldn't suppress sret. +SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } +// CHECK-LABEL: define {{.*}} i32 @indirect_result_2(i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +typedef struct { char array[1024]; } struct_reallybig; +SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } +// CHECK-LABEL: define {{.*}} void @indirect_result_3({{.*}}* noalias sret {{.*}}, i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +SWIFTCALL void context_1(CONTEXT void *self) {} +// CHECK-LABEL: define {{.*}} void @context_1(i8* swiftself + +SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {} +// CHECK-LABEL: define {{.*}} void @context_2(i8*{{.*}}, i8* swiftself + +SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {} +// CHECK-LABEL: define {{.*}} void @context_error_1(i32* swiftself{{.*}}, float** swifterror) +// CHECK: [[TEMP:%.*]] = alloca float*, align 8 +// CHECK: [[T0:%.*]] = load float*, float** [[ERRORARG:%.*]], align 8 +// CHECK: store float* [[T0]], float** [[TEMP]], align 8 +// CHECK: [[T0:%.*]] = load float*, float** [[TEMP]], align 8 +// CHECK: store float* [[T0]], float** [[ERRORARG]], align 8 +void test_context_error_1() { + int x; + float *error; + context_error_1(, ); +} +// CHECK-LABEL: define void @test_context_error_1() +// CHECK: [[X:%.*]] = alloca i32, align 4 +// CHECK: [[ERROR:%.*]] = alloca float*, align 8 +// CHECK: [[TEMP:%.*]] = alloca swifterror float*, align 8 +// CHECK: [[T0:%.*]] = load float*, float** [[ERROR]], align 8 +// CHECK: store float* [[T0]], float** [[TEMP]], align 8 +// CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(i32* swiftself [[X]], float** swifterror [[TEMP]]) +// CHECK: [[T0:%.*]] = load float*, float** [[TEMP]], align 8 +// CHECK: store float* [[T0]], float** [[ERROR]], align 8 + +SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {} +// CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, i32* swiftself{{.*}}, float** swifterror) + +/*/ +/** LOWERING */ +/*/ + +typedef float float4 __attribute__((ext_vector_type(4))); +typedef float float8 __attribute__((ext_vector_type(8))); +typedef double double2 __attribute__((ext_vector_type(2))); +typedef double double4 __attribute__((ext_vector_type(4))); +typedef int int3 __attribute__((ext_vector_type(3))); +typedef int int4 __attribute__((ext_vector_type(4))); +typedef int int5 __attribute__((ext_vector_type(5))); +typedef int int8 __attribute__((ext_vector_type(8))); + +#define TEST(TYPE) \ + SWIFTCALL TYPE return_##TYPE(void) { \ +TYPE result = {};\ +return result; \ + } \ + SWIFTCALL void take_##TYPE(TYPE v) { \ + } \ + void test_##TYPE() { \ +
r284055 - Remove basic block label in test case
Author: arnolds Date: Wed Oct 12 16:36:15 2016 New Revision: 284055 URL: http://llvm.org/viewvc/llvm-project?rev=284055=rev Log: Remove basic block label in test case Another attempt to make a bot happy Modified: cfe/trunk/test/CodeGen/windows-swiftcall.c Modified: cfe/trunk/test/CodeGen/windows-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/windows-swiftcall.c?rev=284055=284054=284055=diff == --- cfe/trunk/test/CodeGen/windows-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/windows-swiftcall.c Wed Oct 12 16:36:15 2016 @@ -121,7 +121,6 @@ TEST(struct_1); // CHECK: ret void // CHECK: } // CHECK-LABEL: define void @test_struct_1() {{.*}}{ -// CHECK: entry: // CHECK: [[AGG:%.*]] = alloca [[STRUCT1:%.*]], align 4 // CHECK: [[RET:%.*]] = call swiftcc { i64, i64 } @return_struct_1() // CHECK: [[CAST:%.*]] = bitcast [[STRUCT1]]* [[AGG]] to { i64, i64 }* ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284048 - Specify a target cpu in test case
Author: arnolds Date: Wed Oct 12 15:30:24 2016 New Revision: 284048 URL: http://llvm.org/viewvc/llvm-project?rev=284048=rev Log: Specify a target cpu in test case Hopefully, this makes the bots happy Modified: cfe/trunk/test/CodeGen/windows-swiftcall.c Modified: cfe/trunk/test/CodeGen/windows-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/windows-swiftcall.c?rev=284048=284047=284048=diff == --- cfe/trunk/test/CodeGen/windows-swiftcall.c (original) +++ cfe/trunk/test/CodeGen/windows-swiftcall.c Wed Oct 12 15:30:24 2016 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -target-cpu core2 -o - %s | FileCheck %s #define SWIFTCALL __attribute__((swiftcall)) #define OUT __attribute__((swift_indirect_result)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284032 - Declare WinX86_64ABIInfo to satisfy SwiftABI info
Author: arnolds Date: Wed Oct 12 13:59:24 2016 New Revision: 284032 URL: http://llvm.org/viewvc/llvm-project?rev=284032=rev Log: Declare WinX86_64ABIInfo to satisfy SwiftABI info This is minimal support that allows swift's test cases on non windows platforms to pass. rdar://28738985 Added: cfe/trunk/test/CodeGen/windows-swiftcall.c Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/Sema/attr-swiftcall.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=284032=284031=284032=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Wed Oct 12 13:59:24 2016 @@ -4551,6 +4551,7 @@ public: case CC_X86VectorCall: case CC_IntelOclBicc: case CC_X86_64SysV: +case CC_Swift: return CCCR_OK; default: return CCCR_Warning; Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=284032=284031=284032=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Oct 12 13:59:24 2016 @@ -2003,10 +2003,10 @@ public: }; /// WinX86_64ABIInfo - The Windows X86_64 ABI information. -class WinX86_64ABIInfo : public ABIInfo { +class WinX86_64ABIInfo : public SwiftABIInfo { public: WinX86_64ABIInfo(CodeGen::CodeGenTypes ) - : ABIInfo(CGT), + : SwiftABIInfo(CGT), IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {} void computeInfo(CGFunctionInfo ) const override; @@ -2025,6 +2025,12 @@ public: return isX86VectorCallAggregateSmallEnough(NumMembers); } + bool shouldPassIndirectlyForSwift(CharUnits totalSize, +ArrayRef scalars, +bool asReturnValue) const override { +return occupiesMoreThan(CGT, scalars, /*total*/ 4); + } + private: ABIArgInfo classify(QualType Ty, unsigned , bool IsReturnType) const; Added: cfe/trunk/test/CodeGen/windows-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/windows-swiftcall.c?rev=284032=auto == --- cfe/trunk/test/CodeGen/windows-swiftcall.c (added) +++ cfe/trunk/test/CodeGen/windows-swiftcall.c Wed Oct 12 13:59:24 2016 @@ -0,0 +1,459 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -o - %s | FileCheck %s + +#define SWIFTCALL __attribute__((swiftcall)) +#define OUT __attribute__((swift_indirect_result)) +#define ERROR __attribute__((swift_error_result)) +#define CONTEXT __attribute__((swift_context)) + +// CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, float 0.00e+00, float 0.00e+00 } + +/*/ +/** PARAMETER ABIS ***/ +/*/ + +SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {} +// CHECK-LABEL: define {{.*}} void @indirect_result_1(i32* noalias sret align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +// TODO: maybe this shouldn't suppress sret. +SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } +// CHECK-LABEL: define {{.*}} i32 @indirect_result_2(i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +typedef struct { char array[1024]; } struct_reallybig; +SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } +// CHECK-LABEL: define {{.*}} void @indirect_result_3({{.*}}* noalias sret {{.*}}, i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) + +SWIFTCALL void context_1(CONTEXT void *self) {} +// CHECK-LABEL: define {{.*}} void @context_1(i8* swiftself + +SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {} +// CHECK-LABEL: define {{.*}} void @context_2(i8*{{.*}}, i8* swiftself + +SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {} +// CHECK-LABEL: define {{.*}} void @context_error_1(i32* swiftself{{.*}}, float** swifterror) +// CHECK: [[TEMP:%.*]] = alloca float*, align 8 +// CHECK: [[T0:%.*]] = load float*, float** [[ERRORARG:%.*]], align 8 +// CHECK: store float* [[T0]], float** [[TEMP]], align 8 +// CHECK: [[T0:%.*]] = load float*, float** [[TEMP]], align 8 +// CHECK: store float* [[T0]], float** [[ERRORARG]], align 8 +void test_context_error_1() { + int x; + float *error; + context_error_1(, );
r283932 - Pass the end of a component to SwiftAggLowering's enumerateComponents callback
Author: arnolds Date: Tue Oct 11 15:34:03 2016 New Revision: 283932 URL: http://llvm.org/viewvc/llvm-project?rev=283932=rev Log: Pass the end of a component to SwiftAggLowering's enumerateComponents callback This is usefull for determining whether components overlap. Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=283932=283931=283932=diff == --- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original) +++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Tue Oct 11 15:34:03 2016 @@ -90,7 +90,7 @@ public: bool shouldPassIndirectly(bool asReturnValue) const; using EnumerationCallback = -llvm::function_ref; +llvm::function_ref ; /// Enumerate the expanded components of this type. /// Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=283932=283931=283932=diff == --- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original) +++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Tue Oct 11 15:34:03 2016 @@ -506,7 +506,7 @@ void SwiftAggLowering::enumerateComponen assert(Finished && "haven't yet finished lowering"); for (auto : Entries) { -callback(entry.Begin, entry.Type); +callback(entry.Begin, entry.End, entry.Type); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r283933 - Swift Calling Convention: Parameters are allowed after the
Author: arnolds Date: Tue Oct 11 15:34:06 2016 New Revision: 283933 URL: http://llvm.org/viewvc/llvm-project?rev=283933=rev Log: Swift Calling Convention: Parameters are allowed after the swift_error/swift_context parameter We need to be able to decelare witness functions which append the self type and the self witness tables at the end of the parameter list. rdar://28720996 Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/Sema/attr-swiftcall.c cfe/trunk/test/SemaCXX/attr-swiftcall.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=283933=283932=283933=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Tue Oct 11 15:34:06 2016 @@ -2400,28 +2400,16 @@ static void checkExtParameterInfos(Sema } continue; -// swift_context parameters must be the last parameter except for -// a possible swift_error parameter. case ParameterABI::SwiftContext: checkForSwiftCC(paramIndex); - if (!(paramIndex == numParams - 1 || -(paramIndex == numParams - 2 && - EPI.ExtParameterInfos[numParams - 1].getABI() - == ParameterABI::SwiftErrorResult))) { -S.Diag(getParamLoc(paramIndex), - diag::err_swift_context_not_before_swift_error_result); - } continue; -// swift_error parameters must be the last parameter. +// swift_error parameters must be preceded by a swift_context parameter. case ParameterABI::SwiftErrorResult: checkForSwiftCC(paramIndex); - if (paramIndex != numParams - 1) { -S.Diag(getParamLoc(paramIndex), - diag::err_swift_error_result_not_last); - } else if (paramIndex == 0 || - EPI.ExtParameterInfos[paramIndex - 1].getABI() - != ParameterABI::SwiftContext) { + if (paramIndex == 0 || + EPI.ExtParameterInfos[paramIndex - 1].getABI() != + ParameterABI::SwiftContext) { S.Diag(getParamLoc(paramIndex), diag::err_swift_error_result_not_after_swift_context); } Modified: cfe/trunk/test/Sema/attr-swiftcall.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-swiftcall.c?rev=283933=283932=283933=diff == --- cfe/trunk/test/Sema/attr-swiftcall.c (original) +++ cfe/trunk/test/Sema/attr-swiftcall.c Tue Oct 11 15:34:06 2016 @@ -18,13 +18,13 @@ void indirect_result_single(INDIRECT_RES void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void *out2) SWIFTCALL; void error_result_nonswift(ERROR_RESULT void **error); // expected-error {{'swift_error_result' parameter can only be used with swiftcall calling convention}} expected-error{{'swift_error_result' parameter must follow 'swift_context' parameter}} -void error_result_bad_position(ERROR_RESULT void **error, int last) SWIFTCALL; // expected-error {{'swift_error_result' parameter must be last parameter of function}} void error_result_bad_position2(int first, ERROR_RESULT void **error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 'swift_context' parameter}} void error_result_bad_type(CONTEXT void *context, ERROR_RESULT int error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer to unqualified pointer type; type here is 'int'}} void error_result_bad_type2(CONTEXT void *context, ERROR_RESULT int *error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer to unqualified pointer type; type here is 'int *'}} void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void **error) SWIFTCALL; +void error_result_okay2(CONTEXT void *context, ERROR_RESULT void **error, void *selfType, char **selfWitnessTable) SWIFTCALL; void context_nonswift(CONTEXT void *context); // expected-error {{'swift_context' parameter can only be used with swiftcall calling convention}} -void context_bad_position(CONTEXT void *context, int x) SWIFTCALL; // expected-error {{'swift_context' parameter can only be followed by 'swift_error_result' parameter}} void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error {{'swift_context' parameter must have pointer type; type here is 'int'}} void context_okay(CONTEXT void *context) SWIFTCALL; +void context_okay2(CONTEXT void *context, void *selfType, char **selfWitnessTable) SWIFTCALL; Modified: cfe/trunk/test/SemaCXX/attr-swiftcall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-swiftcall.cpp?rev=283933=283932=283933=diff == --- cfe/trunk/test/SemaCXX/attr-swiftcall.cpp (original) +++ cfe/trunk/test/SemaCXX/attr-swiftcall.cpp Tue Oct 11 15:34:06 2016 @@ -17,16