From 04f1f071a854e18275ec5c9c341400e2ecff14eb Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 12 May 2014 17:32:27 +0000 Subject: Update Release Notes for 3.4.1 git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@208599 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ReleaseNotes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index b24bca9ce0..1908d666b4 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -27,6 +27,13 @@ Clang web page, this document applies to the *next* release, not the current one. To see the release notes for a specific release, please see the `releases page `_. +What's New in Clang 3.4.1? +========================== + +* Various bug fixes for AArch64, ARM, and PowerPC targets + +* C++11 fixes + What's New in Clang 3.4? ======================== -- cgit v1.2.3 From e0c3dac5c8c5e7789438380f2ad1341055a10360 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 12 May 2014 17:32:29 +0000 Subject: Merging r201729: ------------------------------------------------------------------------ r201729 | chandlerc | 2014-02-19 17:35:01 -0500 (Wed, 19 Feb 2014) | 21 lines Teach Clang to provide ::max_align_t in C11 and C++11 modes. This definition is not chosen idly. There is an unfortunate reality with max_align_t -- the specific nature of its definition leaks into the ABI almost immediately. Because it is part of C11 and C++11 it becomes essential for it to match with other systems on that ABI. There is an effort to discourage any further use of this construct as a consequence -- using max_align_t introduces an immediate ABI problem. We can never update it to have larger alignment even as the microarchitecture changes to necessitate higher alignment. =/ The particular definition here exactly matches the ABI of GCC's chosen ::max_align_t definition, for better or worse. This was written with the help of Richard Smith who was decoding the exact ABI implications of the selected definition in GCC. Notably, in-register arguments are impacted by the particular definition chosen. =/ No one is under the illusion that this is a "good" or "useful" definition of max_align_t, and we are working with the standards committee to specify a more useful interface to address this need. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@208600 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/stddef.h | 10 ++++++++++ test/Headers/c11.c | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/Headers/stddef.h b/lib/Headers/stddef.h index 6a64d6d32a..b6926942ef 100644 --- a/lib/Headers/stddef.h +++ b/lib/Headers/stddef.h @@ -84,6 +84,16 @@ using ::std::nullptr_t; #endif #endif +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +typedef struct { + long long __clang_max_align_nonce1 + __attribute__((__aligned__(__alignof__(long long)))); + long double __clang_max_align_nonce2 + __attribute__((__aligned__(__alignof__(long double)))); +} max_align_t; +#define __CLANG_MAX_ALIGN_T_DEFINED +#endif + #define offsetof(t, d) __builtin_offsetof(t, d) #endif /* __STDDEF_H */ diff --git a/test/Headers/c11.c b/test/Headers/c11.c index 11bec19544..e335d0cebc 100644 --- a/test/Headers/c11.c +++ b/test/Headers/c11.c @@ -22,6 +22,10 @@ _Static_assert(__alignof(c) == 4, ""); #define __STDC_WANT_LIB_EXT1__ 1 #include rsize_t x = 0; +_Static_assert(sizeof(max_align_t) >= sizeof(long long), ""); +_Static_assert(alignof(max_align_t) >= alignof(long long), ""); +_Static_assert(sizeof(max_align_t) >= sizeof(long double), ""); +_Static_assert(alignof(max_align_t) >= alignof(long double), ""); // If we are freestanding, then also check RSIZE_MAX (in a hosted implementation // we will use the host stdint.h, which may not yet have C11 support). -- cgit v1.2.3 From 074a8d3deaca2f135b98669c173bc3d97db670e4 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 12 May 2014 17:32:31 +0000 Subject: Merging r202911: ------------------------------------------------------------------------ r202911 | david.majnemer | 2014-03-04 18:43:48 -0500 (Tue, 04 Mar 2014) | 14 lines Headers: Provide an ABI compatible max_align_t when _MSC_VER is defined Summary: Our usual definition of max_align_t wouldn't match up with MSVC if it was used in a template argument. Reviewers: chandlerc, rsmith, rnk Reviewed By: chandlerc CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2924 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@208601 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/stddef.h | 4 ++++ test/Headers/c11.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/Headers/stddef.h b/lib/Headers/stddef.h index b6926942ef..97126ed152 100644 --- a/lib/Headers/stddef.h +++ b/lib/Headers/stddef.h @@ -85,12 +85,16 @@ using ::std::nullptr_t; #endif #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +#ifndef _MSC_VER typedef struct { long long __clang_max_align_nonce1 __attribute__((__aligned__(__alignof__(long long)))); long double __clang_max_align_nonce2 __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; +#else +typedef double max_align_t; +#endif #define __CLANG_MAX_ALIGN_T_DEFINED #endif diff --git a/test/Headers/c11.c b/test/Headers/c11.c index e335d0cebc..2debcae394 100644 --- a/test/Headers/c11.c +++ b/test/Headers/c11.c @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fmsc-version=1700 %s noreturn int f(); // expected-error 1+{{}} @@ -27,6 +28,10 @@ _Static_assert(alignof(max_align_t) >= alignof(long long), ""); _Static_assert(sizeof(max_align_t) >= sizeof(long double), ""); _Static_assert(alignof(max_align_t) >= alignof(long double), ""); +#ifdef _MSC_VER +_Static_assert(sizeof(max_align_t) == sizeof(double), ""); +#endif + // If we are freestanding, then also check RSIZE_MAX (in a hosted implementation // we will use the host stdint.h, which may not yet have C11 support). #ifndef __STDC_HOSTED__ -- cgit v1.2.3 From 9c7228e582d5c245ee67aeb2cfc646a0f5a1eaf9 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 16 May 2014 21:05:39 +0000 Subject: Merging r197036: ------------------------------------------------------------------------ r197036 | david.tweed | 2013-12-11 08:39:46 -0500 (Wed, 11 Dec 2013) | 8 lines Add front-end infrastructure now address space casts are in LLVM IR. With the introduction of explicit address space casts into LLVM, there's a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA and code to produce address space casts from those kinds when appropriate. Patch by Michele Scandale! ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@209029 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/OperationKinds.h | 5 ++++- lib/AST/Expr.cpp | 7 +++++++ lib/AST/ExprConstant.cpp | 2 ++ lib/CodeGen/CGExpr.cpp | 1 + lib/CodeGen/CGExprAgg.cpp | 1 + lib/CodeGen/CGExprComplex.cpp | 1 + lib/CodeGen/CGExprConstant.cpp | 7 +++++-- lib/CodeGen/CGExprScalar.cpp | 15 +++++++++++++-- lib/Edit/RewriteObjCFoundationAPI.cpp | 1 + lib/Sema/SemaExpr.cpp | 15 ++++++++++++--- lib/StaticAnalyzer/Core/ExprEngineC.cpp | 1 + 11 files changed, 48 insertions(+), 8 deletions(-) diff --git a/include/clang/AST/OperationKinds.h b/include/clang/AST/OperationKinds.h index 5e41d955cf..aba88d6c54 100644 --- a/include/clang/AST/OperationKinds.h +++ b/include/clang/AST/OperationKinds.h @@ -295,7 +295,10 @@ enum CastKind { CK_BuiltinFnToFnPtr, // Convert a zero value for OpenCL event_t initialization. - CK_ZeroToOCLEvent + CK_ZeroToOCLEvent, + + // Convert a pointer to a different address space. + CK_AddressSpaceConversion }; static const CastKind CK_Invalid = static_cast(-1); diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 9055ddac35..6307f4c0db 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1474,6 +1474,11 @@ void CastExpr::CheckCastConsistency() const { assert(getSubExpr()->getType()->isFunctionType()); goto CheckNoBasePath; + case CK_AddressSpaceConversion: + assert(getType()->isPointerType()); + assert(getSubExpr()->getType()->isPointerType()); + assert(getType()->getPointeeType().getAddressSpace() != + getSubExpr()->getType()->getPointeeType().getAddressSpace()); // These should not have an inheritance path. case CK_Dynamic: case CK_ToUnion: @@ -1636,6 +1641,8 @@ const char *CastExpr::getCastKindName() const { return "BuiltinFnToFnPtr"; case CK_ZeroToOCLEvent: return "ZeroToOCLEvent"; + case CK_AddressSpaceConversion: + return "AddressSpaceConversion"; } llvm_unreachable("Unhandled cast kind!"); diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 4cac4fab84..a0ae5b6f0d 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -7109,6 +7109,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) { case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: case CK_NonAtomicToAtomic: + case CK_AddressSpaceConversion: llvm_unreachable("invalid cast kind for integral value"); case CK_BitCast: @@ -7581,6 +7582,7 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) { case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: case CK_NonAtomicToAtomic: + case CK_AddressSpaceConversion: llvm_unreachable("invalid cast kind for complex value"); case CK_LValueToRValue: diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index cb990b243f..92966d0eb1 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2744,6 +2744,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { case CK_ARCReclaimReturnedObject: case CK_ARCExtendBlockObject: case CK_CopyAndAutoreleaseBlockObject: + case CK_AddressSpaceConversion: return EmitUnsupportedLValue(E, "unexpected cast lvalue"); case CK_Dependent: diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 9d0f3a9661..35e6988e46 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -713,6 +713,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: + case CK_AddressSpaceConversion: llvm_unreachable("cast kind invalid for aggregate types"); } } diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 73d5bcb13a..74a2579ed3 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -475,6 +475,7 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastExpr::CastKind CK, Expr *Op, case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: + case CK_AddressSpaceConversion: llvm_unreachable("invalid cast kind for complex value"); case CK_FloatingRealToComplex: diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index f4d6861c8b..ad3e1fcbef 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -633,6 +633,9 @@ public: return llvm::ConstantStruct::get(STy, Elts); } + case CK_AddressSpaceConversion: + return llvm::ConstantExpr::getAddrSpaceCast(C, destType); + case CK_LValueToRValue: case CK_AtomicToNonAtomic: case CK_NonAtomicToAtomic: @@ -1062,13 +1065,13 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, if (!Offset->isNullValue()) { llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Int8PtrTy); Casted = llvm::ConstantExpr::getGetElementPtr(Casted, Offset); - C = llvm::ConstantExpr::getBitCast(Casted, C->getType()); + C = llvm::ConstantExpr::getPointerCast(Casted, C->getType()); } // Convert to the appropriate type; this could be an lvalue for // an integer. if (isa(DestTy)) - return llvm::ConstantExpr::getBitCast(C, DestTy); + return llvm::ConstantExpr::getPointerCast(C, DestTy); return llvm::ConstantExpr::getPtrToInt(C, DestTy); } else { diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index f3a5387c58..26e327a41a 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -1299,7 +1299,18 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { case CK_AnyPointerToBlockPointerCast: case CK_BitCast: { Value *Src = Visit(const_cast(E)); - return Builder.CreateBitCast(Src, ConvertType(DestTy)); + llvm::Type *SrcTy = Src->getType(); + llvm::Type *DstTy = ConvertType(DestTy); + if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() && + SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace()) { + llvm::Type *MidTy = CGF.CGM.getDataLayout().getIntPtrType(SrcTy); + return Builder.CreateIntToPtr(Builder.CreatePtrToInt(Src, MidTy), DstTy); + } + return Builder.CreateBitCast(Src, DstTy); + } + case CK_AddressSpaceConversion: { + Value *Src = Visit(const_cast(E)); + return Builder.CreateAddrSpaceCast(Src, ConvertType(DestTy)); } case CK_AtomicToNonAtomic: case CK_NonAtomicToAtomic: @@ -1360,7 +1371,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { // Make sure the array decay ends up being the right type. This matters if // the array type was of an incomplete type. - return CGF.Builder.CreateBitCast(V, ConvertType(CE->getType())); + return CGF.Builder.CreatePointerCast(V, ConvertType(CE->getType())); } case CK_FunctionToPointerDecay: return EmitLValue(E).getAddress(); diff --git a/lib/Edit/RewriteObjCFoundationAPI.cpp b/lib/Edit/RewriteObjCFoundationAPI.cpp index f4206fbd8f..879c17aaab 100644 --- a/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -1033,6 +1033,7 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, case CK_IntegralComplexToReal: case CK_IntegralComplexToBoolean: case CK_AtomicToNonAtomic: + case CK_AddressSpaceConversion: needsCast = true; break; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index e1f65f4a4e..992e66ad29 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4876,8 +4876,13 @@ CastKind Sema::PrepareScalarCast(ExprResult &Src, QualType DestTy) { case Type::STK_BlockPointer: case Type::STK_ObjCObjectPointer: switch (DestTy->getScalarTypeKind()) { - case Type::STK_CPointer: + case Type::STK_CPointer: { + unsigned SrcAS = SrcTy->getPointeeType().getAddressSpace(); + unsigned DestAS = DestTy->getPointeeType().getAddressSpace(); + if (SrcAS != DestAS) + return CK_AddressSpaceConversion; return CK_BitCast; + } case Type::STK_BlockPointer: return (SrcKind == Type::STK_BlockPointer ? CK_BitCast : CK_AnyPointerToBlockPointerCast); @@ -7830,10 +7835,14 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS, /*isError*/false); } if (LCanPointeeTy != RCanPointeeTy) { + unsigned AddrSpaceL = LCanPointeeTy.getAddressSpace(); + unsigned AddrSpaceR = RCanPointeeTy.getAddressSpace(); + CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion + : CK_BitCast; if (LHSIsNull && !RHSIsNull) - LHS = ImpCastExprToType(LHS.take(), RHSType, CK_BitCast); + LHS = ImpCastExprToType(LHS.take(), RHSType, Kind); else - RHS = ImpCastExprToType(RHS.take(), LHSType, CK_BitCast); + RHS = ImpCastExprToType(RHS.take(), LHSType, Kind); } return ResultTy; } diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 983fda00a2..9ba086ce71 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -286,6 +286,7 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_Dependent: case CK_ArrayToPointerDecay: case CK_BitCast: + case CK_AddressSpaceConversion: case CK_IntegralCast: case CK_NullToPointer: case CK_IntegralToPointer: -- cgit v1.2.3 From adb6bc4cf0e09a5aca773ab7680bc4c7bf581909 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 16 May 2014 21:07:44 +0000 Subject: Update ReleaseNotes git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@209030 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ReleaseNotes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 1908d666b4..9cddcf0103 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -27,6 +27,13 @@ Clang web page, this document applies to the *next* release, not the current one. To see the release notes for a specific release, please see the `releases page `_. +What's New in Clang 3.4.2? +========================== + +* Build fix for gcc 4.9. + +* Added missing addrspacecast support. + What's New in Clang 3.4.1? ========================== -- cgit v1.2.3