r339026 - [Fixed Point Arithmetic] Fix for FixedPointValueToString
Author: leonardchan Date: Mon Aug 6 09:05:08 2018 New Revision: 339026 URL: http://llvm.org/viewvc/llvm-project?rev=339026&view=rev Log: [Fixed Point Arithmetic] Fix for FixedPointValueToString - Print negative numbers correctly - Handle APInts of different sizes - Add formal unit tests for FixedPointValueToString - Add tests for checking correct printing when padding is set - Restrict to printing in radix 10 since that's all we need for now Differential Revision: https://reviews.llvm.org/D49945 Added: cfe/trunk/test/Frontend/fixed_point_to_string.c cfe/trunk/unittests/Frontend/FixedPointString.cpp Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/unittests/Frontend/CMakeLists.txt Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=339026&r1=339025&r2=339026&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Mon Aug 6 09:05:08 2018 @@ -6604,9 +6604,8 @@ QualType DecayedType::getPointeeType() c // Get the decimal string representation of a fixed point type, represented // as a scaled integer. -void FixedPointValueToString(SmallVectorImpl &Str, - const llvm::APSInt &Val, - unsigned Scale, unsigned Radix); +void FixedPointValueToString(SmallVectorImpl &Str, llvm::APSInt Val, + unsigned Scale); } // namespace clang Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=339026&r1=339025&r2=339026&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Mon Aug 6 09:05:08 2018 @@ -785,7 +785,7 @@ std::string FixedPointLiteral::getValueA // which is 43 characters. SmallString<64> S; FixedPointValueToString( - S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale, Radix); + S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale); return S.str(); } Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=339026&r1=339025&r2=339026&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug 6 09:05:08 2018 @@ -9698,8 +9698,7 @@ bool FixedPointExprEvaluator::VisitUnary if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow()) { SmallString<64> S; FixedPointValueToString(S, Value, -Info.Ctx.getTypeInfo(E->getType()).Width, -/*Radix=*/10); +Info.Ctx.getTypeInfo(E->getType()).Width); Info.CCEDiag(E, diag::note_constexpr_overflow) << S << E->getType(); if (Info.noteUndefinedBehavior()) return false; } Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=339026&r1=339025&r2=339026&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Mon Aug 6 09:05:08 2018 @@ -4032,17 +4032,26 @@ CXXRecordDecl *MemberPointerType::getMos } void clang::FixedPointValueToString(SmallVectorImpl &Str, -const llvm::APSInt &Val, unsigned Scale, -unsigned Radix) { - llvm::APSInt ScaleVal = llvm::APSInt::getUnsigned(1ULL << Scale); - llvm::APSInt IntPart = Val / ScaleVal; - llvm::APSInt FractPart = Val % ScaleVal; - llvm::APSInt RadixInt = llvm::APSInt::getUnsigned(Radix); +llvm::APSInt Val, unsigned Scale) { + if (Val.isSigned() && Val.isNegative() && Val != -Val) { +Val = -Val; +Str.push_back('-'); + } - IntPart.toString(Str, Radix); + llvm::APSInt IntPart = Val >> Scale; + + // Add 4 digits to hold the value after multiplying 10 (the radix) + unsigned Width = Val.getBitWidth() + 4; + llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width); + llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width); + llvm::APInt RadixInt = llvm::APInt(Width, 10); + + IntPart.toString(Str, /*radix=*/10); Str.push_back('.'); do { -(FractPart * RadixInt / ScaleVal).toString(Str, Radix); -FractPart = (FractPart * RadixInt) % ScaleVal; - } while (FractPart.getExtValue()); +(FractPart * RadixInt) +.lshr(Scale) +.toString(Str, /*radix=*/10, Val.isSigned()); +FractPart = (FractPart * RadixInt) & FractPartMask; + } while (FractPart != 0); } Added:
r339028 - [Fixed Point Arithmetic] Fixed Point Constant
Author: leonardchan Date: Mon Aug 6 09:42:37 2018 New Revision: 339028 URL: http://llvm.org/viewvc/llvm-project?rev=339028&view=rev Log: [Fixed Point Arithmetic] Fixed Point Constant This patch proposes an abstract type that represents fixed point numbers, similar to APInt or APSInt that was discussed in https://reviews.llvm.org/D48456#inline-425585. This type holds a value, scale, and saturation and is meant to perform intermediate calculations on constant fixed point values. Currently this class is used as a way for handling the conversions between fixed point numbers with different sizes and radixes. For example, if I'm casting from a signed _Accum to a saturated unsigned short _Accum, I will need to check the value of the signed _Accum to see if it fits into the short _Accum which involves getting and comparing against the max/min values of the short _Accum. The FixedPointNumber class currently handles the radix shifting and extension when converting to a signed _Accum. Differential Revision: https://reviews.llvm.org/D48661 Added: cfe/trunk/include/clang/Basic/FixedPoint.h cfe/trunk/lib/Basic/FixedPoint.cpp cfe/trunk/unittests/Basic/FixedPointTest.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Basic/CMakeLists.txt cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Frontend/fixed_point_declarations.c cfe/trunk/unittests/Basic/CMakeLists.txt Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=339028&r1=339027&r2=339028&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 6 09:42:37 2018 @@ -79,6 +79,7 @@ struct fltSemantics; namespace clang { +class APFixedPoint; class APValue; class ASTMutationListener; class ASTRecordLayout; @@ -92,6 +93,7 @@ class CXXMethodDecl; class CXXRecordDecl; class DiagnosticsEngine; class Expr; +class FixedPointSemantics; class MangleContext; class MangleNumberingContext; class MaterializeTemporaryExpr; @@ -1961,6 +1963,9 @@ public: unsigned char getFixedPointScale(QualType Ty) const; unsigned char getFixedPointIBits(QualType Ty) const; + FixedPointSemantics getFixedPointSemantics(QualType Ty) const; + APFixedPoint getFixedPointMax(QualType Ty) const; + APFixedPoint getFixedPointMin(QualType Ty) const; DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; Added: cfe/trunk/include/clang/Basic/FixedPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=339028&view=auto == --- cfe/trunk/include/clang/Basic/FixedPoint.h (added) +++ cfe/trunk/include/clang/Basic/FixedPoint.h Mon Aug 6 09:42:37 2018 @@ -0,0 +1,138 @@ +//===- FixedPoint.h - Fixed point constant handling -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +/// \file +/// Defines the fixed point number interface. +/// This is a class for abstracting various operations performed on fixed point +/// types described in ISO/IEC JTC1 SC22 WG14 N1169 starting at clause 4. +// +//===--===// + +#ifndef LLVM_CLANG_BASIC_FIXEDPOINT_H +#define LLVM_CLANG_BASIC_FIXEDPOINT_H + +#include "llvm/ADT/APSInt.h" + +namespace clang { + +class ASTContext; +class QualType; + +/// The fixed point semantics work similarly to llvm::fltSemantics. The width +/// specifies the whole bit width of the underlying scaled integer (with padding +/// if any). The scale represents the number of fractional bits in this type. +/// When HasUnsignedPadding is true and this type is signed, the first bit +/// in the value this represents is treaded as padding. +class FixedPointSemantics { +public: + FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned, + bool IsSaturated, bool HasUnsignedPadding) + : Width(Width), Scale(Scale), IsSigned(IsSigned), +IsSaturated(IsSaturated), HasUnsignedPadding(HasUnsignedPadding) { +assert(Width >= Scale && "Not enough room for the scale"); + } + + unsigned getWidth() const { return Width; } + unsigned getScale() const { return Scale; } + bool isSigned() const { return IsSigned; } + bool isSaturated() const { return IsSaturated; } + bool hasUnsignedPadding() const { return HasUnsignedPadding; } + + void setSaturated(bool Saturated) { IsSaturated = Saturated; }
r339037 - Fix for failing test from sanitizer-x86_64-linux-fast where there was a
Author: leonardchan Date: Mon Aug 6 10:55:38 2018 New Revision: 339037 URL: http://llvm.org/viewvc/llvm-project?rev=339037&view=rev Log: Fix for failing test from sanitizer-x86_64-linux-fast where there was a left shift on a negative value. Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FixedPointTest.cpp?rev=339037&r1=339036&r2=339037&view=diff == --- cfe/trunk/unittests/Basic/FixedPointTest.cpp (original) +++ cfe/trunk/unittests/Basic/FixedPointTest.cpp Mon Aug 6 10:55:38 2018 @@ -364,12 +364,19 @@ TEST(FixedPoint, compare) { void CheckUnsaturatedConversion(FixedPointSemantics Src, FixedPointSemantics Dst, int64_t TestVal) { int64_t ScaledVal = TestVal; + bool IsNegative = ScaledVal < 0; + if (IsNegative) +ScaledVal = -ScaledVal; + if (Dst.getScale() > Src.getScale()) { ScaledVal <<= (Dst.getScale() - Src.getScale()); } else { ScaledVal >>= (Src.getScale() - Dst.getScale()); } + if (IsNegative) +ScaledVal = -ScaledVal; + APFixedPoint Fixed(TestVal, Src); APFixedPoint Expected(ScaledVal, Dst); ASSERT_EQ(Fixed.convert(Dst), Expected); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339038 - Removed the OverflowConversionsToFract tests for now. Will add them back
Author: leonardchan Date: Mon Aug 6 11:02:16 2018 New Revision: 339038 URL: http://llvm.org/viewvc/llvm-project?rev=339038&view=rev Log: Removed the OverflowConversionsToFract tests for now. Will add them back in once I figure out why this doesn't work on windows. Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FixedPointTest.cpp?rev=339038&r1=339037&r2=339038&view=diff == --- cfe/trunk/unittests/Basic/FixedPointTest.cpp (original) +++ cfe/trunk/unittests/Basic/FixedPointTest.cpp Mon Aug 6 11:02:16 2018 @@ -601,51 +601,6 @@ TEST(FixedPoint, SAccumConversionOverflo -549755813888); } -void CheckSaturatedConversionToFractMax(FixedPointSemantics Src, -int64_t OneVal) { - CheckSaturatedConversionMax(Src, Saturated(getSFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getLFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getUSFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getUFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getPadULFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getPadUSFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getPadUFractSema()), OneVal); - CheckSaturatedConversionMax(Src, Saturated(getPadULFractSema()), OneVal); -} - -void CheckSaturatedConversionToFractMin(FixedPointSemantics Src, -int64_t MinusOneVal) { - CheckSaturatedConversionMin(Src, Saturated(getSFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getLFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getUSFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getUFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getPadULFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getPadUSFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getPadUFractSema()), MinusOneVal); - CheckSaturatedConversionMin(Src, Saturated(getPadULFractSema()), MinusOneVal); -} - -TEST(FixedPoint, OverflowConversionsToFract) { - CheckSaturatedConversionToFractMax(getSAccumSema(), 128); - CheckSaturatedConversionToFractMin(getSAccumSema(), -128); - CheckSaturatedConversionToFractMax(getAccumSema(), 32768); - CheckSaturatedConversionToFractMin(getAccumSema(), -32768); - CheckSaturatedConversionToFractMax(getLAccumSema(), 2147483648); - CheckSaturatedConversionToFractMin(getLAccumSema(), -2147483648); - - // Unsigned - CheckSaturatedConversionToFractMax(getUSAccumSema(), 256); - CheckSaturatedConversionToFractMax(getUAccumSema(), 65536); - CheckSaturatedConversionToFractMax(getULAccumSema(), 4294967296); - - // Padded unsigned - CheckSaturatedConversionToFractMax(getPadUSAccumSema(), 128); - CheckSaturatedConversionToFractMax(getPadUAccumSema(), 32768); - CheckSaturatedConversionToFractMax(getPadULAccumSema(), 2147483648); -} - TEST(FixedPoint, GetValueSignAfterConversion) { APFixedPoint Fixed(255 << 7, getSAccumSema()); ASSERT_TRUE(Fixed.getValue().isSigned()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339044 - Fix for broken build on clang-hexagon-elf for ambiguous call to
Author: leonardchan Date: Mon Aug 6 12:31:00 2018 New Revision: 339044 URL: http://llvm.org/viewvc/llvm-project?rev=339044&view=rev Log: Fix for broken build on clang-hexagon-elf for ambiguous call to std::abs. Modified: cfe/trunk/lib/Basic/FixedPoint.cpp Modified: cfe/trunk/lib/Basic/FixedPoint.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FixedPoint.cpp?rev=339044&r1=339043&r2=339044&view=diff == --- cfe/trunk/lib/Basic/FixedPoint.cpp (original) +++ cfe/trunk/lib/Basic/FixedPoint.cpp Mon Aug 6 12:31:00 2018 @@ -59,7 +59,8 @@ int APFixedPoint::compare(const APFixedP unsigned CommonWidth = std::max(Val.getBitWidth(), OtherWidth); // Prevent overflow in the event the widths are the same but the scales differ - CommonWidth += std::abs(static_cast(getScale() - OtherScale)); + CommonWidth += getScale() >= OtherScale ? getScale() - OtherScale + : OtherScale - getScale(); ThisVal = ThisVal.extOrTrunc(CommonWidth); OtherVal = OtherVal.extOrTrunc(CommonWidth); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r339167 - [Sema] Fix for crash on conditional operation with address_space pointer
Author: leonardchan Date: Tue Aug 7 12:43:53 2018 New Revision: 339167 URL: http://llvm.org/viewvc/llvm-project?rev=339167&view=rev Log: [Sema] Fix for crash on conditional operation with address_space pointer Compiling the following causes clang to crash ``` char *cmp(__attribute__((address_space(1))) char *x, __attribute__((address_space(2))) char *y) { return x < y ? x : y; } ``` with the message: "wrong cast for pointers in different address spaces(must be an address space cast)!" This is because during IR emission, the source and dest type for a bitcast should not have differing address spaces. This fix prints an error since the code shouldn't compile in the first place. Differential Revision: https://reviews.llvm.org/D50278 Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Sema/address_spaces.c cfe/trunk/test/Sema/conditional-expr.c Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=339167&r1=339166&r2=339167&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 7 12:43:53 2018 @@ -6460,20 +6460,18 @@ static QualType checkConditionalPointerC LangAS ResultAddrSpace = LangAS::Default; LangAS LAddrSpace = lhQual.getAddressSpace(); LangAS RAddrSpace = rhQual.getAddressSpace(); - if (S.getLangOpts().OpenCL) { -// OpenCL v1.1 s6.5 - Conversion between pointers to distinct address -// spaces is disallowed. -if (lhQual.isAddressSpaceSupersetOf(rhQual)) - ResultAddrSpace = LAddrSpace; -else if (rhQual.isAddressSpaceSupersetOf(lhQual)) - ResultAddrSpace = RAddrSpace; -else { - S.Diag(Loc, - diag::err_typecheck_op_on_nonoverlapping_address_space_pointers) - << LHSTy << RHSTy << 2 << LHS.get()->getSourceRange() - << RHS.get()->getSourceRange(); - return QualType(); -} + + // OpenCL v1.1 s6.5 - Conversion between pointers to distinct address + // spaces is disallowed. + if (lhQual.isAddressSpaceSupersetOf(rhQual)) +ResultAddrSpace = LAddrSpace; + else if (rhQual.isAddressSpaceSupersetOf(lhQual)) +ResultAddrSpace = RAddrSpace; + else { +S.Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers) +<< LHSTy << RHSTy << 2 << LHS.get()->getSourceRange() +<< RHS.get()->getSourceRange(); +return QualType(); } unsigned MergedCVRQual = lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers(); @@ -6491,16 +6489,12 @@ static QualType checkConditionalPointerC // Thus for conditional operator we merge CVR and address space unqualified // pointees and if there is a composite type we return a pointer to it with // merged qualifiers. - if (S.getLangOpts().OpenCL) { -LHSCastKind = LAddrSpace == ResultAddrSpace - ? CK_BitCast - : CK_AddressSpaceConversion; -RHSCastKind = RAddrSpace == ResultAddrSpace - ? CK_BitCast - : CK_AddressSpaceConversion; -lhQual.removeAddressSpace(); -rhQual.removeAddressSpace(); - } + LHSCastKind = + LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion; + RHSCastKind = + RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion; + lhQual.removeAddressSpace(); + rhQual.removeAddressSpace(); lhptee = S.Context.getQualifiedType(lhptee.getUnqualifiedType(), lhQual); rhptee = S.Context.getQualifiedType(rhptee.getUnqualifiedType(), rhQual); @@ -6516,6 +6510,7 @@ static QualType checkConditionalPointerC S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpace)); LHS = S.ImpCastExprToType(LHS.get(), incompatTy, LHSCastKind); RHS = S.ImpCastExprToType(RHS.get(), incompatTy, RHSCastKind); + // FIXME: For OpenCL the warning emission and cast to void* leaves a room // for casts between types with incompatible address space qualifiers. // For the following code the compiler produces casts between global and @@ -6526,6 +6521,7 @@ static QualType checkConditionalPointerC S.Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers) << LHSTy << RHSTy << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); + return incompatTy; } Modified: cfe/trunk/test/Sema/address_spaces.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address_spaces.c?rev=339167&r1=339166&r2=339167&view=diff == --- cfe/trunk/test/Sema/address_spaces.c (original) +++ cfe/trunk/test/Sema/address_spaces.c Tue Aug 7 12:43:53 2018 @@ -71,5 +71,5 @@ __attribute__((address_space("12"))) int // Clang extension doesn't forbid operations on pointers to different address spaces. char* cmp(_AS1 char *x, _AS2 char *y) { - return x < y ? x : y; // expected-warnin
r340765 - [Sema/Attribute] Make types declared with address_space an AttributedType
Author: leonardchan Date: Mon Aug 27 10:57:29 2018 New Revision: 340765 URL: http://llvm.org/viewvc/llvm-project?rev=340765&view=rev Log: [Sema/Attribute] Make types declared with address_space an AttributedType Currently an address_space is stored in a qualifier. This makes any type declared with an address_space attribute in the form `__attribute__((address_space(1))) int 1;` be wrapped in an AttributedType. This is for a later patch where if `address_space` is declared in a macro, any diagnostics that would normally print the address space will instead dump the macro name. This will require saving any macro information in the AttributedType. Differential Revision: https://reviews.llvm.org/D51229 Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=340765&r1=340764&r2=340765&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Mon Aug 27 10:57:29 2018 @@ -564,8 +564,6 @@ def AddressSpace : TypeAttr { let Spellings = [Clang<"address_space">]; let Args = [IntArgument<"AddressSpace">]; let Documentation = [Undocumented]; - // Represented as a qualifier or DependentAddressSpaceType instead. - let ASTNode = 0; } def Alias : Attr { Modified: cfe/trunk/lib/AST/TypePrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=340765&r1=340764&r2=340765&view=diff == --- cfe/trunk/lib/AST/TypePrinter.cpp (original) +++ cfe/trunk/lib/AST/TypePrinter.cpp Mon Aug 27 10:57:29 2018 @@ -1427,6 +1427,12 @@ void TypePrinter::printAttributedAfter(c return; } + // The printing of the address_space attribute is handled by the qualifier + // since it is still stored in the qualifier. Return early to prevent printing + // this twice. + if (T->getAttrKind() == attr::AddressSpace) +return; + OS << " __attribute__(("; switch (T->getAttrKind()) { #define TYPE_ATTR(NAME) @@ -1456,6 +1462,7 @@ void TypePrinter::printAttributedAfter(c case attr::Ptr64: case attr::SPtr: case attr::UPtr: + case attr::AddressSpace: llvm_unreachable("This attribute should have been handled already"); case attr::NSReturnsRetained: Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=340765&r1=340764&r2=340765&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Mon Aug 27 10:57:29 2018 @@ -5597,12 +5597,6 @@ GetTypeSourceInfoForDeclarator(TypeProce } for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) { -if (DependentAddressSpaceTypeLoc DASTL = -CurrTL.getAs()) { - fillDependentAddressSpaceTypeLoc(DASTL, D.getTypeObject(i).getAttrs()); - CurrTL = DASTL.getPointeeTypeLoc().getUnqualifiedLoc(); -} - // An AtomicTypeLoc might be produced by an atomic qualifier in this // declarator chunk. if (AtomicTypeLoc ATL = CurrTL.getAs()) { @@ -5615,6 +5609,12 @@ GetTypeSourceInfoForDeclarator(TypeProce CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); } +while (DependentAddressSpaceTypeLoc TL = + CurrTL.getAs()) { + fillDependentAddressSpaceTypeLoc(TL, D.getTypeObject(i).getAttrs()); + CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc(); +} + // FIXME: Ordering here? while (AdjustedTypeLoc TL = CurrTL.getAs()) CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc(); @@ -5767,7 +5767,10 @@ QualType Sema::BuildAddressSpaceAttr(Qua /// specified type. The attribute contains 1 argument, the id of the address /// space for the type. static void HandleAddressSpaceTypeAttribute(QualType &Type, -const ParsedAttr &Attr, Sema &S) { +const ParsedAttr &Attr, +TypeProcessingState &State) { + Sema &S = State.getSema(); + // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be // qualified by an address-space qualifier." if (Type->isFunctionType()) { @@ -5809,10 +5812,15 @@ static void HandleAddressSpaceTypeAttrib // the type. QualType T = S.BuildAddressSpaceAttr(Type, ASArgExpr, Attr.getLoc()); -if (!T.isNull()) - Type = T; -else +if (!T.isNull()) { + ASTContext &Ctx = S.Context; + auto *ASAttr = ::new (Ctx) AddressSpaceAttr( + Attr.getRange(), Ctx, Attr.getAttributeSpellingListIndex(), + static_cast(T.getQualifiers().getAddressSpace())); + Type = State.getAttri
r333814 - This diff includes changes for supporting the following types.
Author: leonardchan Date: Fri Jun 1 19:58:51 2018 New Revision: 333814 URL: http://llvm.org/viewvc/llvm-project?rev=333814&view=rev Log: This diff includes changes for supporting the following types. ``` // Primary fixed point types signed short _Accum s_short_accum; signed _Accum s_accum; signed long _Accum s_long_accum; unsigned short _Accum u_short_accum; unsigned _Accum u_accum; unsigned long _Accum u_long_accum; // Aliased fixed point types short _Accum short_accum; _Accum accum; long _Accum long_accum; ``` This diff only allows for declaration of the fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. The saturated versions of these types and the equivalent `_Fract` types will also be added in future patches. The tests included are for asserting that we can declare these types. Differential Revision: https://reviews.llvm.org/D46084 Added: cfe/trunk/test/Frontend/fixed_point.c cfe/trunk/test/Frontend/fixed_point_bit_widths.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_errors.cpp cfe/trunk/test/Frontend/fixed_point_not_enabled.c Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333814&r1=333813&r2=333814&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Fri Jun 1 19:58:51 2018 @@ -3182,8 +3182,14 @@ enum CXTypeKind { CXType_Float128 = 30, CXType_Half = 31, CXType_Float16 = 32, + CXType_ShortAccum = 33, + CXType_Accum = 34, + CXType_LongAccum = 35, + CXType_UShortAccum = 36, + CXType_UAccum = 37, + CXType_ULongAccum = 38, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_Float16, + CXType_LastBuiltin = CXType_ULongAccum, CXType_Complex = 100, CXType_Pointer = 101, Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333814&r1=333813&r2=333814&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jun 1 19:58:51 2018 @@ -1007,6 +1007,9 @@ public: CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; CanQualType UnsignedLongLongTy, UnsignedInt128Ty; CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; + CanQualType ShortAccumTy, AccumTy, + LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension + CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=333814&r1=333813&r2=333814&view=diff == --- cfe/trunk/include/clang/AST/BuiltinTypes.def (original) +++ cfe/trunk/include/clang/AST/BuiltinTypes.def Fri Jun 1 19:58:51 2018 @@ -122,6 +122,26 @@ SIGNED_TYPE(LongLong, LongLongTy) // '__int128_t' SIGNED_TYPE(Int128, Int128Ty) +//===- Fixed point types --
r333815 - Revert "This diff includes changes for supporting the following types."
Author: leonardchan Date: Fri Jun 1 20:27:13 2018 New Revision: 333815 URL: http://llvm.org/viewvc/llvm-project?rev=333815&view=rev Log: Revert "This diff includes changes for supporting the following types." This reverts commit r333814, which fails for a test checking the bit width on ubuntu. Removed: cfe/trunk/test/Frontend/fixed_point.c cfe/trunk/test/Frontend/fixed_point_bit_widths.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_errors.cpp cfe/trunk/test/Frontend/fixed_point_not_enabled.c Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333815&r1=333814&r2=333815&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Fri Jun 1 20:27:13 2018 @@ -3182,14 +3182,8 @@ enum CXTypeKind { CXType_Float128 = 30, CXType_Half = 31, CXType_Float16 = 32, - CXType_ShortAccum = 33, - CXType_Accum = 34, - CXType_LongAccum = 35, - CXType_UShortAccum = 36, - CXType_UAccum = 37, - CXType_ULongAccum = 38, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_ULongAccum, + CXType_LastBuiltin = CXType_Float16, CXType_Complex = 100, CXType_Pointer = 101, Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333815&r1=333814&r2=333815&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jun 1 20:27:13 2018 @@ -1007,9 +1007,6 @@ public: CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; CanQualType UnsignedLongLongTy, UnsignedInt128Ty; CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; - CanQualType ShortAccumTy, AccumTy, - LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension - CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=333815&r1=333814&r2=333815&view=diff == --- cfe/trunk/include/clang/AST/BuiltinTypes.def (original) +++ cfe/trunk/include/clang/AST/BuiltinTypes.def Fri Jun 1 20:27:13 2018 @@ -122,26 +122,6 @@ SIGNED_TYPE(LongLong, LongLongTy) // '__int128_t' SIGNED_TYPE(Int128, Int128Ty) -//===- Fixed point types --===// - -// 'short _Accum' -SIGNED_TYPE(ShortAccum, ShortAccumTy) - -// '_Accum' -SIGNED_TYPE(Accum, AccumTy) - -// 'long _Accum' -SIGNED_TYPE(LongAccum, LongAccumTy) - -// 'unsigned short _Accum' -UNSIGNED_TYPE(UShortAccum, UnsignedShortAccumTy) - -// 'unsigned _Accum' -UNSIGNED_TYPE(UAccum, UnsignedAccumTy) - -// 'unsigned long _Accum' -UNSIGNED_TYPE(ULongAccum, UnsignedLongAccumTy) - //===- Floating point types ---===// // 'half' in OpenCL, '__fp16' in ARM NEON. Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticC
r333923 - This diff includes changes for supporting the following types.
Author: leonardchan Date: Mon Jun 4 09:07:52 2018 New Revision: 333923 URL: http://llvm.org/viewvc/llvm-project?rev=333923&view=rev Log: This diff includes changes for supporting the following types. // Primary fixed point types signed short _Accum s_short_accum; signed _Accum s_accum; signed long _Accum s_long_accum; unsigned short _Accum u_short_accum; unsigned _Accum u_accum; unsigned long _Accum u_long_accum; // Aliased fixed point types short _Accum short_accum; _Accum accum; long _Accum long_accum; This diff only allows for declaration of the fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. The saturated versions of these types and the equivalent _Fract types will also be added in future patches. The tests included are for asserting that we can declare these types. Fixed the test that was failing by not checking for dso_local on some targets. Differential Revision: https://reviews.llvm.org/D46084 Added: cfe/trunk/test/Frontend/fixed_point.c cfe/trunk/test/Frontend/fixed_point_bit_widths.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_errors.cpp cfe/trunk/test/Frontend/fixed_point_not_enabled.c Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923&r1=333922&r2=333923&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Mon Jun 4 09:07:52 2018 @@ -3182,8 +3182,14 @@ enum CXTypeKind { CXType_Float128 = 30, CXType_Half = 31, CXType_Float16 = 32, + CXType_ShortAccum = 33, + CXType_Accum = 34, + CXType_LongAccum = 35, + CXType_UShortAccum = 36, + CXType_UAccum = 37, + CXType_ULongAccum = 38, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_Float16, + CXType_LastBuiltin = CXType_ULongAccum, CXType_Complex = 100, CXType_Pointer = 101, Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=333923&r1=333922&r2=333923&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jun 4 09:07:52 2018 @@ -1007,6 +1007,9 @@ public: CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; CanQualType UnsignedLongLongTy, UnsignedInt128Ty; CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; + CanQualType ShortAccumTy, AccumTy, + LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension + CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=333923&r1=333922&r2=333923&view=diff == --- cfe/trunk/include/clang/AST/BuiltinTypes.def (original) +++ cfe/trunk/include/clang/AST/BuiltinTypes.def Mon Jun 4 09:07:52 2018 @@ -122,6 +122,26 @@ SIGNED_TYPE(LongLong, LongLongTy) // '__int128_t' SIGNED_TYPE(Int128
Re: r333923 - This diff includes changes for supporting the following types.
Sorry. I did not notice this. I will be sure to add the title from the phabricator review as the first line next time. On Mon, Jun 4, 2018 at 9:44 AM Roman Lebedev wrote: > > Did you use `arc patch` to get the commit description? > Please make sure that the first line of the commit is reasonable. > In this case it is not reasonable. > > On Mon, Jun 4, 2018 at 7:07 PM, Leonard Chan via cfe-commits > wrote: > > Author: leonardchan > > Date: Mon Jun 4 09:07:52 2018 > > New Revision: 333923 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=333923&view=rev > > Log: > > This diff includes changes for supporting the following types. > > > > // Primary fixed point types > > signed short _Accum s_short_accum; > > signed _Accum s_accum; > > signed long _Accum s_long_accum; > > unsigned short _Accum u_short_accum; > > unsigned _Accum u_accum; > > unsigned long _Accum u_long_accum; > > > > // Aliased fixed point types > > short _Accum short_accum; > > _Accum accum; > > long _Accum long_accum; > > This diff only allows for declaration of the fixed point types. Assignment > > and other operations done on fixed point types according to > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in > > future patches. The saturated versions of these types and the equivalent > > _Fract types will also be added in future patches. > > > > The tests included are for asserting that we can declare these types. > > > > Fixed the test that was failing by not checking for dso_local on some > > targets. > > > > Differential Revision: https://reviews.llvm.org/D46084 > > > > Added: > > cfe/trunk/test/Frontend/fixed_point.c > > cfe/trunk/test/Frontend/fixed_point_bit_widths.c > > cfe/trunk/test/Frontend/fixed_point_errors.c > > cfe/trunk/test/Frontend/fixed_point_errors.cpp > > cfe/trunk/test/Frontend/fixed_point_not_enabled.c > > Modified: > > cfe/trunk/include/clang-c/Index.h > > cfe/trunk/include/clang/AST/ASTContext.h > > cfe/trunk/include/clang/AST/BuiltinTypes.def > > cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td > > cfe/trunk/include/clang/Basic/LangOptions.def > > cfe/trunk/include/clang/Basic/Specifiers.h > > cfe/trunk/include/clang/Basic/TargetInfo.h > > cfe/trunk/include/clang/Basic/TokenKinds.def > > cfe/trunk/include/clang/Driver/Options.td > > cfe/trunk/include/clang/Sema/DeclSpec.h > > cfe/trunk/include/clang/Serialization/ASTBitCodes.h > > cfe/trunk/lib/AST/ASTContext.cpp > > cfe/trunk/lib/AST/ExprConstant.cpp > > cfe/trunk/lib/AST/ItaniumMangle.cpp > > cfe/trunk/lib/AST/MicrosoftMangle.cpp > > cfe/trunk/lib/AST/NSAPI.cpp > > cfe/trunk/lib/AST/Type.cpp > > cfe/trunk/lib/AST/TypeLoc.cpp > > cfe/trunk/lib/Analysis/PrintfFormatString.cpp > > cfe/trunk/lib/Basic/TargetInfo.cpp > > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > > cfe/trunk/lib/CodeGen/CodeGenTypes.cpp > > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > > cfe/trunk/lib/Driver/ToolChains/Clang.cpp > > cfe/trunk/lib/Frontend/CompilerInvocation.cpp > > cfe/trunk/lib/Index/USRGeneration.cpp > > cfe/trunk/lib/Parse/ParseDecl.cpp > > cfe/trunk/lib/Sema/DeclSpec.cpp > > cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp > > cfe/trunk/lib/Sema/SemaType.cpp > > cfe/trunk/lib/Serialization/ASTCommon.cpp > > cfe/trunk/lib/Serialization/ASTReader.cpp > > cfe/trunk/tools/libclang/CXType.cpp > > > > Modified: cfe/trunk/include/clang-c/Index.h > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=333923&r1=333922&r2=333923&view=diff > > == > > --- cfe/trunk/include/clang-c/Index.h (original) > > +++ cfe/trunk/include/clang-c/Index.h Mon Jun 4 09:07:52 2018 > > @@ -3182,8 +3182,14 @@ enum CXTypeKind { > >CXType_Float128 = 30, > >CXType_Half = 31, > >CXType_Float16 = 32, > > + CXType_ShortAccum = 33, > > + CXType_Accum = 34, > > + CXType_LongAccum = 35, > > + CXType_UShortAccum = 36, > > + CXType_UAccum = 37, > > + CXType_ULongAccum = 38, > >CXType_FirstBuiltin = CXType_Void, > > - CXType_LastBuiltin = CXType_Float16, > > + CXType_LastBuiltin = CXType_ULongAccum, > > > >CXType_Complex = 100, > >CXType_Pointer = 101, > > > > Modified: cfe/tr
r334718 - [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents
Author: leonardchan Date: Thu Jun 14 07:53:51 2018 New Revision: 334718 URL: http://llvm.org/viewvc/llvm-project?rev=334718&view=rev Log: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents This diff includes changes for the remaining _Fract and _Sat fixed point types. ``` signed short _Fract s_short_fract; signed _Fract s_fract; signed long _Fract s_long_fract; unsigned short _Fract u_short_fract; unsigned _Fract u_fract; unsigned long _Fract u_long_fract; // Aliased fixed point types short _Accum short_accum; _Accum accum; long _Accum long_accum; short _Fract short_fract; _Fract fract; long _Fract long_fract; // Saturated fixed point types _Sat signed short _Accum sat_s_short_accum; _Sat signed _Accum sat_s_accum; _Sat signed long _Accum sat_s_long_accum; _Sat unsigned short _Accum sat_u_short_accum; _Sat unsigned _Accum sat_u_accum; _Sat unsigned long _Accum sat_u_long_accum; _Sat signed short _Fract sat_s_short_fract; _Sat signed _Fract sat_s_fract; _Sat signed long _Fract sat_s_long_fract; _Sat unsigned short _Fract sat_u_short_fract; _Sat unsigned _Fract sat_u_fract; _Sat unsigned long _Fract sat_u_long_fract; // Aliased saturated fixed point types _Sat short _Accum sat_short_accum; _Sat _Accum sat_accum; _Sat long _Accum sat_long_accum; _Sat short _Fract sat_short_fract; _Sat _Fract sat_fract; _Sat long _Fract sat_long_fract; ``` This diff only allows for declaration of these fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. Differential Revision: https://reviews.llvm.org/D46911 Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Frontend/fixed_point.c cfe/trunk/test/Frontend/fixed_point_bit_widths.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_errors.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=334718&r1=334717&r2=334718&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jun 14 07:53:51 2018 @@ -1010,6 +1010,14 @@ public: CanQualType ShortAccumTy, AccumTy, LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; + CanQualType ShortFractTy, FractTy, LongFractTy; + CanQualType UnsignedShortFractTy, UnsignedFractTy, UnsignedLongFractTy; + CanQualType SatShortAccumTy, SatAccumTy, SatLongAccumTy; + CanQualType SatUnsignedShortAccumTy, SatUnsignedAccumTy, + SatUnsignedLongAccumTy; + CanQualType SatShortFractTy, SatFractTy, SatLongFractTy; + CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy, + SatUnsignedLongFractTy; CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; @@ -2543,8 +2551,15 @@ public: // Per C99 6.2.5p6, for every signed integer type, there is a corresponding // unsigned integer type. This method takes a signed type, and returns the // corresponding unsigned integer type. + // With the introduction of fixed point types in ISO N1169, this method also + // accepts fixed point types and returns the corresponding unsigned type for + // a given fixed point type. QualType getCorrespondingUnsignedType(QualType T) const; + // Per ISO N1169, this method accepts fixed point types and returns the + // corresponding saturated type for a given fixed point type. + QualType getCorrespondingSaturatedType(QualType Ty) const; +
r335148 - [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals
Author: leonardchan Date: Wed Jun 20 10:19:40 2018 New Revision: 335148 URL: http://llvm.org/viewvc/llvm-project?rev=335148&view=rev Log: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals This diff includes the logic for setting the precision bits for each primary fixed point type in the target info and logic for initializing a fixed point literal. Fixed point literals are declared using the suffixes ``` hr: short _Fract uhr: unsigned short _Fract r: _Fract ur: unsigned _Fract lr: long _Fract ulr: unsigned long _Fract hk: short _Accum uhk: unsigned short _Accum k: _Accum uk: unsigned _Accum ``` Errors are also thrown for illegal literal values ``` unsigned short _Accum u_short_accum = 256.0uhk; // expected-error{{the integral part of this literal is too large for this unsigned _Accum type}} ``` Differential Revision: https://reviews.llvm.org/D46915 Added: cfe/trunk/test/Frontend/fixed_point_declarations.c cfe/trunk/test/Frontend/fixed_point_same_fbits.c Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/StmtNodes.td cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Lex/LiteralSupport.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprClassification.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Frontend/fixed_point.c cfe/trunk/test/Frontend/fixed_point_bit_widths.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=335148&r1=335147&r2=335148&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jun 20 10:19:40 2018 @@ -2170,7 +2170,12 @@ enum CXCursorKind { */ CXCursor_ObjCAvailabilityCheckExpr = 148, - CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr, + /** + * Fixed point literal + */ + CXCursor_FixedPointLiteral = 149, + + CXCursor_LastExpr = CXCursor_FixedPointLiteral, /* Statements */ CXCursor_FirstStmt = 200, Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=335148&r1=335147&r2=335148&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jun 20 10:19:40 2018 @@ -1947,6 +1947,9 @@ public: return getQualifiedType(type.getUnqualifiedType(), Qs); } + unsigned char getFixedPointScale(QualType Ty) const; + unsigned char getFixedPointIBits(QualType Ty) const; + DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=335148&r1=335147&r2=335148&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Wed Jun 20 10:19:40 2018 @@ -1351,6 +1351,47 @@ public: } }; +class FixedPointLiteral : public Expr, public APIntStorage { + SourceLocation Loc; + unsigned Scale; + + /// \brief Construct an empty integer literal. + explicit FixedPointLiteral(EmptyShell Empty) + : Expr(FixedPointLiteralClass, Empty) {} + + public: + FixedPointLiteral(const ASTContext &C, const llvm::APInt &V, QualType type, +SourceLocation l, unsigned Scale); + + // Store the int as is without a
r335155 - Fixed test that failed when checking what variable a value was stored
Author: leonardchan Date: Wed Jun 20 11:48:05 2018 New Revision: 335155 URL: http://llvm.org/viewvc/llvm-project?rev=335155&view=rev Log: Fixed test that failed when checking what variable a value was stored in for fixed point types. Modified: cfe/trunk/test/Frontend/fixed_point_same_fbits.c Modified: cfe/trunk/test/Frontend/fixed_point_same_fbits.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/fixed_point_same_fbits.c?rev=335155&r1=335154&r2=335155&view=diff == --- cfe/trunk/test/Frontend/fixed_point_same_fbits.c (original) +++ cfe/trunk/test/Frontend/fixed_point_same_fbits.c Wed Jun 20 11:48:05 2018 @@ -12,17 +12,17 @@ void func() { unsigned _Fract u_fract = 0.5ur; unsigned long _Fract u_long_fract = 0.5ulr; -// DEFAULT: store i16 128, i16* %u_short_accum, align 2 -// DEFAULT: store i32 32768, i32* %u_accum, align 4 -// DEFAULT: store i64 2147483648, i64* %u_long_accum, align 8 -// DEFAULT: store i8 -128, i8* %u_short_fract, align 1 -// DEFAULT: store i16 -32768, i16* %u_fract, align 2 -// DEFAULT: store i32 -2147483648, i32* %u_long_fract, align 4 +// DEFAULT: store i16 128, i16* {{.*}}, align 2 +// DEFAULT: store i32 32768, i32* {{.*}}, align 4 +// DEFAULT: store i64 2147483648, i64* {{.*}}, align 8 +// DEFAULT: store i8 -128, i8* {{.*}}, align 1 +// DEFAULT: store i16 -32768, i16* {{.*}}, align 2 +// DEFAULT: store i32 -2147483648, i32* {{.*}}, align 4 -// SAME: store i16 64, i16* %u_short_accum, align 2 -// SAME: store i32 16384, i32* %u_accum, align 4 -// SAME: store i64 1073741824, i64* %u_long_accum, align 8 -// SAME: store i8 64, i8* %u_short_fract, align 1 -// SAME: store i16 16384, i16* %u_fract, align 2 -// SAME: store i32 1073741824, i32* %u_long_fract, align 4 +// SAME: store i16 64, i16* {{.*}}, align 2 +// SAME: store i32 16384, i32* {{.*}}, align 4 +// SAME: store i64 1073741824, i64* {{.*}}, align 8 +// SAME: store i8 64, i8* {{.*}}, align 1 +// SAME: store i16 16384, i16* {{.*}}, align 2 +// SAME: store i32 1073741824, i32* {{.*}}, align 4 } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335159 - Fixed test in prior build where FileCheck tried to match against
Author: leonardchan Date: Wed Jun 20 12:34:05 2018 New Revision: 335159 URL: http://llvm.org/viewvc/llvm-project?rev=335159&view=rev Log: Fixed test in prior build where FileCheck tried to match against `common` when declaring a global variable when we primarily care about the value assigned in the test. Modified: cfe/trunk/test/Frontend/fixed_point_declarations.c Modified: cfe/trunk/test/Frontend/fixed_point_declarations.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/fixed_point_declarations.c?rev=335159&r1=335158&r2=335159&view=diff == --- cfe/trunk/test/Frontend/fixed_point_declarations.c (original) +++ cfe/trunk/test/Frontend/fixed_point_declarations.c Wed Jun 20 12:34:05 2018 @@ -1,4 +1,4 @@ -// RUN: %clang -ffixed-point -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-linux | FileCheck %s // RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-scei-ps4-ubuntu-fast | FileCheck %s // Primary fixed point types ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r335159 - Fixed test in prior build where FileCheck tried to match against
For that particular test I wanted to check the store value on each declaration but tests failed on 4 different machines where for global variables. On these machines `dso_local` was not included in the IR output and x86_64-scei-ps4-ubuntu-fast was one of them. My quick fix to address this was using a regex to capture the `dso_local` and adding x86_64-scei-ps4-ubuntu-fast as a target to make sure the test passed for it. Today I ran into a similar issue with my tests where instead s390x added `common dso_local` which I couldn't easily catch with my current regex. The quick hack for this was just testing only on linux, but forgot to remove the x86_64-scei-ps4-ubuntu-fast run. I will remove this in a future patch since just forcing the first run to target linux fixes my initial problem. - Leo On Wed, Jun 20, 2018 at 12:55 PM wrote: > > (Using the right commits list this time...) > > See inline (same as previous). > > > -Original Message- > > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of > > Leonard Chan via cfe-commits > > Sent: Wednesday, June 20, 2018 3:34 PM > > To: cfe-commits@lists.llvm.org > > Subject: r335159 - Fixed test in prior build where FileCheck tried to > > match against > > > > Author: leonardchan > > Date: Wed Jun 20 12:34:05 2018 > > New Revision: 335159 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=335159&view=rev > > Log: > > Fixed test in prior build where FileCheck tried to match against > > `common` when declaring a global variable when we primarily care about > > the value assigned in the test. > > > > Modified: > > cfe/trunk/test/Frontend/fixed_point_declarations.c > > > > Modified: cfe/trunk/test/Frontend/fixed_point_declarations.c > > URL: http://llvm.org/viewvc/llvm- > > project/cfe/trunk/test/Frontend/fixed_point_declarations.c?rev=335159&r1=3 > > 35158&r2=335159&view=diff > > == > > > > --- cfe/trunk/test/Frontend/fixed_point_declarations.c (original) > > +++ cfe/trunk/test/Frontend/fixed_point_declarations.c Wed Jun 20 12:34:05 > > 2018 > > @@ -1,4 +1,4 @@ > > -// RUN: %clang -ffixed-point -S -emit-llvm %s -o - | FileCheck %s > > +// RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-linux > > | FileCheck %s > > // RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-scei- > > ps4-ubuntu-fast | FileCheck %s > > By the way, "x86_64-scei-ps4-ubuntu-fast" is not a real triple. The PS4 > triple is "x86_64-scei-ps4" (although there is an ubuntu-fast bot, which > might be where the confusion arises). > > Is there any particular reason to want to use the PS4 triple in addition > to Linux? I haven't really been watching the fixed-point stuff. > Thanks, > --paulr > PS4 code owner > > > > > // Primary fixed point types > > > > > > ___ > > 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
r344530 - [Fixed Point Arithmetic] FixedPointCast
Author: leonardchan Date: Mon Oct 15 09:07:02 2018 New Revision: 344530 URL: http://llvm.org/viewvc/llvm-project?rev=344530&view=rev Log: [Fixed Point Arithmetic] FixedPointCast This patch is a part of https://reviews.llvm.org/D48456 in an attempt to split them up. This contains the code for casting between fixed point types and other fixed point types. The method for converting between fixed point types is based off the convert() method in APFixedPoint. Differential Revision: https://reviews.llvm.org/D50616 Added: cfe/trunk/test/Frontend/fixed_point_conversions.c cfe/trunk/test/Frontend/fixed_point_unknown_conversions.c Modified: cfe/trunk/include/clang/AST/OperationKinds.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Modified: cfe/trunk/include/clang/AST/OperationKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=344530&r1=344529&r2=344530&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.def (original) +++ cfe/trunk/include/clang/AST/OperationKinds.def Mon Oct 15 09:07:02 2018 @@ -197,6 +197,10 @@ CAST_OPERATION(IntegralToBoolean) ///float f = i; CAST_OPERATION(IntegralToFloating) +/// CK_FixedPointCast - Fixed point to fixed point. +///(_Accum) 0.5r +CAST_OPERATION(FixedPointCast) + /// CK_FloatingToIntegral - Floating point to integral. Rounds /// towards zero, discarding any fractional component. ///(int) f Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=344530&r1=344529&r2=344530&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Mon Oct 15 09:07:02 2018 @@ -2066,7 +2066,8 @@ public: STK_Integral, STK_Floating, STK_IntegralComplex, -STK_FloatingComplex +STK_FloatingComplex, +STK_FixedPoint }; /// Given that this is a scalar type, classify it. Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=344530&r1=344529&r2=344530&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Mon Oct 15 09:07:02 2018 @@ -172,6 +172,8 @@ def err_too_large_for_fixed_point : Erro "this value is too large for this fixed point type">; def err_fixed_point_not_enabled : Error<"compile with " "'-ffixed-point' to enable fixed point types">; +def err_unimplemented_conversion_with_fixed_point_type : Error< + "conversion between fixed point and %0 is not yet supported">; // SEH def err_seh_expected_handler : Error< Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=344530&r1=344529&r2=344530&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Mon Oct 15 09:07:02 2018 @@ -1644,6 +1644,7 @@ bool CastExpr::CastConsistency() const { case CK_ZeroToOCLEvent: case CK_ZeroToOCLQueue: case CK_IntToOCLSampler: + case CK_FixedPointCast: assert(!getType()->isBooleanType() && "unheralded conversion to bool"); goto CheckNoBasePath; Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=344530&r1=344529&r2=344530&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Oct 15 09:07:02 2018 @@ -9556,6 +9556,7 @@ bool IntExprEvaluator::VisitCastExpr(con case CK_NonAtomicToAtomic: case CK_AddressSpaceConversion: case CK_IntToOCLSampler: + case CK_FixedPointCast: llvm_unreachable("invalid cast kind for integral value"); case CK_BitCast: @@ -10090,6 +10091,7 @@ bool ComplexExprEvaluator::VisitCastExpr case CK_NonAtomicToAtomic: case CK_AddressSpaceConversion: case CK_IntToOCLSampler: + case CK_FixedPointCast: llvm_unreachable("invalid cast kind for complex value"); case CK_LValueToRValue: Modified: cfe/tr
[clang-tools-extra] r344548 - added fix
Author: leonardchan Date: Mon Oct 15 12:59:52 2018 New Revision: 344548 URL: http://llvm.org/viewvc/llvm-project?rev=344548&view=rev Log: added fix Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=344548&r1=344547&r2=344548&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Mon Oct 15 12:59:52 2018 @@ -60,6 +60,47 @@ static StringRef getValueOfValueInit(con case Type::STK_IntegralComplex: return getValueOfValueInit( InitType->getAs()->getElementType()); + case Type::STK_FixedPoint: +switch (InitType->getAs()->getKind()) { + case BuiltinType::ShortAccum: + case BuiltinType::SatShortAccum: +return "0.0hk"; + case BuiltinType::Accum: + case BuiltinType::SatAccum: +return "0.0k"; + case BuiltinType::LongAccum: + case BuiltinType::SatLongAccum: +return "0.0lk"; + case BuiltinType::UShortAccum: + case BuiltinType::SatUShortAccum: +return "0.0uhk"; + case BuiltinType::UAccum: + case BuiltinType::SatUAccum: +return "0.0uk"; + case BuiltinType::ULongAccum: + case BuiltinType::SatULongAccum: +return "0.0ulk"; + case BuiltinType::ShortFract: + case BuiltinType::SatShortFract: +return "0.0hr"; + case BuiltinType::Fract: + case BuiltinType::SatFract: +return "0.0r"; + case BuiltinType::LongFract: + case BuiltinType::SatLongFract: +return "0.0lr"; + case BuiltinType::UShortFract: + case BuiltinType::SatUShortFract: +return "0.0uhr"; + case BuiltinType::UFract: + case BuiltinType::SatUFract: +return "0.0ur"; + case BuiltinType::ULongFract: + case BuiltinType::SatULongFract: +return "0.0ulr"; + default: +llvm_unreachable("Unhandled fixed point BuiltinType"); +} } llvm_unreachable("Invalid scalar type kind"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344549 - [Fixed Point Arithmetic] Fix for clang-tools-extra warning
Author: leonardchan Date: Mon Oct 15 13:00:03 2018 New Revision: 344549 URL: http://llvm.org/viewvc/llvm-project?rev=344549&view=rev Log: [Fixed Point Arithmetic] Fix for clang-tools-extra warning Fix for warnings generated on unhandled enum value `STK_FixedPoint`. Differential Revision: https://reviews.llvm.org/D53299 Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=344549&r1=344548&r2=344549&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Mon Oct 15 13:00:03 2018 @@ -60,46 +60,47 @@ static StringRef getValueOfValueInit(con case Type::STK_IntegralComplex: return getValueOfValueInit( InitType->getAs()->getElementType()); + case Type::STK_FixedPoint: switch (InitType->getAs()->getKind()) { - case BuiltinType::ShortAccum: - case BuiltinType::SatShortAccum: -return "0.0hk"; - case BuiltinType::Accum: - case BuiltinType::SatAccum: -return "0.0k"; - case BuiltinType::LongAccum: - case BuiltinType::SatLongAccum: -return "0.0lk"; - case BuiltinType::UShortAccum: - case BuiltinType::SatUShortAccum: -return "0.0uhk"; - case BuiltinType::UAccum: - case BuiltinType::SatUAccum: -return "0.0uk"; - case BuiltinType::ULongAccum: - case BuiltinType::SatULongAccum: -return "0.0ulk"; - case BuiltinType::ShortFract: - case BuiltinType::SatShortFract: -return "0.0hr"; - case BuiltinType::Fract: - case BuiltinType::SatFract: -return "0.0r"; - case BuiltinType::LongFract: - case BuiltinType::SatLongFract: -return "0.0lr"; - case BuiltinType::UShortFract: - case BuiltinType::SatUShortFract: -return "0.0uhr"; - case BuiltinType::UFract: - case BuiltinType::SatUFract: -return "0.0ur"; - case BuiltinType::ULongFract: - case BuiltinType::SatULongFract: -return "0.0ulr"; - default: -llvm_unreachable("Unhandled fixed point BuiltinType"); +case BuiltinType::ShortAccum: +case BuiltinType::SatShortAccum: + return "0.0hk"; +case BuiltinType::Accum: +case BuiltinType::SatAccum: + return "0.0k"; +case BuiltinType::LongAccum: +case BuiltinType::SatLongAccum: + return "0.0lk"; +case BuiltinType::UShortAccum: +case BuiltinType::SatUShortAccum: + return "0.0uhk"; +case BuiltinType::UAccum: +case BuiltinType::SatUAccum: + return "0.0uk"; +case BuiltinType::ULongAccum: +case BuiltinType::SatULongAccum: + return "0.0ulk"; +case BuiltinType::ShortFract: +case BuiltinType::SatShortFract: + return "0.0hr"; +case BuiltinType::Fract: +case BuiltinType::SatFract: + return "0.0r"; +case BuiltinType::LongFract: +case BuiltinType::SatLongFract: + return "0.0lr"; +case BuiltinType::UShortFract: +case BuiltinType::SatUShortFract: + return "0.0uhr"; +case BuiltinType::UFract: +case BuiltinType::SatUFract: + return "0.0ur"; +case BuiltinType::ULongFract: +case BuiltinType::SatULongFract: + return "0.0ulr"; +default: + llvm_unreachable("Unhandled fixed point BuiltinType"); } } llvm_unreachable("Invalid scalar type kind"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344699 - [PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address
Author: leonardchan Date: Wed Oct 17 08:38:22 2018 New Revision: 344699 URL: http://llvm.org/viewvc/llvm-project?rev=344699&view=rev Log: [PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address Enable usage of `AddressSanitizer` and `AddressModuleSanitizer` ported from the legacy to the new PassManager. This patch depends on https://reviews.llvm.org/D52739. Differential Revision: https://reviews.llvm.org/D52814 Added: cfe/trunk/test/CodeGen/asan-new-pm.ll Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=344699&r1=344698&r2=344699&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Oct 17 08:38:22 2018 @@ -52,6 +52,7 @@ #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/InstCombine/InstCombine.h" #include "llvm/Transforms/Instrumentation.h" +#include "llvm/Transforms/Instrumentation/AddressSanitizerPass.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" #include "llvm/Transforms/Instrumentation/GCOVProfiler.h" #include "llvm/Transforms/ObjCARC.h" @@ -1022,6 +1023,16 @@ void EmitAssemblyHelper::EmitAssemblyWit CodeGenOpts.DebugPassManager); } } + +if (LangOpts.Sanitize.has(SanitizerKind::Address)) { + bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address); + MPM.addPass(createModuleToFunctionPassAdaptor( + AddressSanitizerPass(/*CompileKernel=*/false, Recover, + CodeGenOpts.SanitizeAddressUseAfterScope))); + bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts); + MPM.addPass(AddressSanitizerPass(/*CompileKernel=*/false, Recover, + ModuleUseAfterScope)); +} } // FIXME: We still use the legacy pass manager to do code generation. We Added: cfe/trunk/test/CodeGen/asan-new-pm.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=344699&view=auto == --- cfe/trunk/test/CodeGen/asan-new-pm.ll (added) +++ cfe/trunk/test/CodeGen/asan-new-pm.ll Wed Oct 17 08:38:22 2018 @@ -0,0 +1,31 @@ +; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s + +; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor + +define i32 @test_load(i32* %a) sanitize_address { +entry: +; CHECK: %0 = ptrtoint i32* %a to i64 +; CHECK: %1 = lshr i64 %0, 3 +; CHECK: %2 = add i64 %1, 2147450880 +; CHECK: %3 = inttoptr i64 %2 to i8* +; CHECK: %4 = load i8, i8* %3 +; CHECK: %5 = icmp ne i8 %4, 0 +; CHECK: br i1 %5, label %6, label %12, !prof !0 + +; CHECK:; :6: ; preds = %entry +; CHECK: %7 = and i64 %0, 7 +; CHECK: %8 = add i64 %7, 3 +; CHECK: %9 = trunc i64 %8 to i8 +; CHECK: %10 = icmp sge i8 %9, %4 +; CHECK: br i1 %10, label %11, label %12 + +; CHECK:; :11: ; preds = %6 +; CHECK: call void @__asan_report_load4(i64 %0) +; CHECK: call void asm sideeffect "", ""() +; CHECK: unreachable + +; CHECK:; :12: ; preds = %6, %entry + + %tmp1 = load i32, i32* %a, align 4 + ret i32 %tmp1 +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344701 - Fix for failing unit tests on some bots after r344696.
Author: leonardchan Date: Wed Oct 17 09:21:19 2018 New Revision: 344701 URL: http://llvm.org/viewvc/llvm-project?rev=344701&view=rev Log: Fix for failing unit tests on some bots after r344696. Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=344701&r1=344700&r2=344701&view=diff == --- cfe/trunk/test/CodeGen/asan-new-pm.ll (original) +++ cfe/trunk/test/CodeGen/asan-new-pm.ll Wed Oct 17 09:21:19 2018 @@ -1,31 +1,10 @@ -; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s +; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address -triple=x86_64-linux %s | FileCheck %s ; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor +; CHECK: declare void @__asan_loadN define i32 @test_load(i32* %a) sanitize_address { entry: -; CHECK: %0 = ptrtoint i32* %a to i64 -; CHECK: %1 = lshr i64 %0, 3 -; CHECK: %2 = add i64 %1, 2147450880 -; CHECK: %3 = inttoptr i64 %2 to i8* -; CHECK: %4 = load i8, i8* %3 -; CHECK: %5 = icmp ne i8 %4, 0 -; CHECK: br i1 %5, label %6, label %12, !prof !0 - -; CHECK:; :6: ; preds = %entry -; CHECK: %7 = and i64 %0, 7 -; CHECK: %8 = add i64 %7, 3 -; CHECK: %9 = trunc i64 %8 to i8 -; CHECK: %10 = icmp sge i8 %9, %4 -; CHECK: br i1 %10, label %11, label %12 - -; CHECK:; :11: ; preds = %6 -; CHECK: call void @__asan_report_load4(i64 %0) -; CHECK: call void asm sideeffect "", ""() -; CHECK: unreachable - -; CHECK:; :12: ; preds = %6, %entry - %tmp1 = load i32, i32* %a, align 4 ret i32 %tmp1 } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344702 - Fix for arm bots afternew PM pass port. Prevent cross compiling on arm.
Author: leonardchan Date: Wed Oct 17 11:12:18 2018 New Revision: 344702 URL: http://llvm.org/viewvc/llvm-project?rev=344702&view=rev Log: Fix for arm bots afternew PM pass port. Prevent cross compiling on arm. Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=344702&r1=344701&r2=344702&view=diff == --- cfe/trunk/test/CodeGen/asan-new-pm.ll (original) +++ cfe/trunk/test/CodeGen/asan-new-pm.ll Wed Oct 17 11:12:18 2018 @@ -1,4 +1,4 @@ -; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address -triple=x86_64-linux %s | FileCheck %s +; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s ; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor ; CHECK: declare void @__asan_loadN ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r345063 - [Fixed Point Arithmetic] Fixed Point to Boolean Cast
Author: leonardchan Date: Tue Oct 23 10:55:35 2018 New Revision: 345063 URL: http://llvm.org/viewvc/llvm-project?rev=345063&view=rev Log: [Fixed Point Arithmetic] Fixed Point to Boolean Cast This patch is a part of https://reviews.llvm.org/D48456 in an attempt to split the casting logic up into smaller patches. This contains the code for casting from fixed point types to boolean types. Differential Revision: https://reviews.llvm.org/D53308 Added: cfe/trunk/test/Frontend/fixed_point_to_bool.c Modified: cfe/trunk/include/clang/AST/OperationKinds.def cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp cfe/trunk/test/Frontend/fixed_point_unknown_conversions.c Modified: cfe/trunk/include/clang/AST/OperationKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=345063&r1=345062&r2=345063&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.def (original) +++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Oct 23 10:55:35 2018 @@ -201,6 +201,10 @@ CAST_OPERATION(IntegralToFloating) ///(_Accum) 0.5r CAST_OPERATION(FixedPointCast) +/// CK_FixedPointToBoolean - Fixed point to boolean. +///(bool) 0.5r +CAST_OPERATION(FixedPointToBoolean) + /// CK_FloatingToIntegral - Floating point to integral. Rounds /// towards zero, discarding any fractional component. ///(int) f Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=345063&r1=345062&r2=345063&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Oct 23 10:55:35 2018 @@ -1661,6 +1661,7 @@ bool CastExpr::CastConsistency() const { case CK_LValueBitCast:// -> bool& case CK_UserDefinedConversion:// operator bool() case CK_BuiltinFnToFnPtr: + case CK_FixedPointToBoolean: CheckNoBasePath: assert(path_empty() && "Cast kind should not have a base path!"); break; Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=345063&r1=345062&r2=345063&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Oct 23 10:55:35 2018 @@ -9590,6 +9590,14 @@ bool IntExprEvaluator::VisitCastExpr(con return Success(IntResult, E); } + case CK_FixedPointToBoolean: { +// Unsigned padding does not affect this. +APValue Val; +if (!Evaluate(Val, Info, SubExpr)) + return false; +return Success(Val.getInt().getBoolValue(), E); + } + case CK_IntegralCast: { if (!Visit(SubExpr)) return false; @@ -10090,6 +10098,7 @@ bool ComplexExprEvaluator::VisitCastExpr case CK_AddressSpaceConversion: case CK_IntToOCLSampler: case CK_FixedPointCast: + case CK_FixedPointToBoolean: llvm_unreachable("invalid cast kind for complex value"); case CK_LValueToRValue: Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=345063&r1=345062&r2=345063&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 23 10:55:35 2018 @@ -4154,6 +4154,7 @@ LValue CodeGenFunction::EmitCastLValue(c case CK_AddressSpaceConversion: case CK_IntToOCLSampler: case CK_FixedPointCast: + case CK_FixedPointToBoolean: return EmitUnsupportedLValue(E, "unexpected cast lvalue"); case CK_Dependent: Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=345063&r1=345062&r2=345063&view=diff == --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Tue Oct 23 10:55:35 2018 @@ -851,6 +851,7 @@ void AggExprEmitter::VisitCastExpr(CastE case CK_AddressSpaceConversion: case CK_IntToOCLSampler: case CK_FixedPointCast: + case CK_FixedPointToBoolean: llvm_unreachable("cast kind invalid for aggregate types"); } } Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=345063&r1=345062&r2=345063&view=diff ===
r345433 - Revert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address"
Author: leonardchan Date: Fri Oct 26 15:51:51 2018 New Revision: 345433 URL: http://llvm.org/viewvc/llvm-project?rev=345433&view=rev Log: Revert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address" This reverts commit 8d6af840396f2da2e4ed6aab669214ae25443204 and commit b78d19c287b6e4a9abc9fb0545de9a3106d38d3d which causes slower build times by initializing the AddressSanitizer on every function run. The corresponding revisions are https://reviews.llvm.org/D52814 and https://reviews.llvm.org/D52739. Removed: cfe/trunk/test/CodeGen/asan-new-pm.ll Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=345433&r1=345432&r2=345433&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Oct 26 15:51:51 2018 @@ -52,7 +52,6 @@ #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/InstCombine/InstCombine.h" #include "llvm/Transforms/Instrumentation.h" -#include "llvm/Transforms/Instrumentation/AddressSanitizerPass.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" #include "llvm/Transforms/Instrumentation/GCOVProfiler.h" #include "llvm/Transforms/ObjCARC.h" @@ -1023,16 +1022,6 @@ void EmitAssemblyHelper::EmitAssemblyWit CodeGenOpts.DebugPassManager); } } - -if (LangOpts.Sanitize.has(SanitizerKind::Address)) { - bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address); - MPM.addPass(createModuleToFunctionPassAdaptor( - AddressSanitizerPass(/*CompileKernel=*/false, Recover, - CodeGenOpts.SanitizeAddressUseAfterScope))); - bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts); - MPM.addPass(AddressSanitizerPass(/*CompileKernel=*/false, Recover, - ModuleUseAfterScope)); -} } // FIXME: We still use the legacy pass manager to do code generation. We Removed: cfe/trunk/test/CodeGen/asan-new-pm.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=345432&view=auto == --- cfe/trunk/test/CodeGen/asan-new-pm.ll (original) +++ cfe/trunk/test/CodeGen/asan-new-pm.ll (removed) @@ -1,10 +0,0 @@ -; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=address %s | FileCheck %s - -; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor -; CHECK: declare void @__asan_loadN - -define i32 @test_load(i32* %a) sanitize_address { -entry: - %tmp1 = load i32, i32* %a, align 4 - ret i32 %tmp1 -} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r351364 - [Fixed Point Arithmetic] Fixed Point Addition
Author: leonardchan Date: Wed Jan 16 10:13:59 2019 New Revision: 351364 URL: http://llvm.org/viewvc/llvm-project?rev=351364&view=rev Log: [Fixed Point Arithmetic] Fixed Point Addition This patch covers addition between fixed point types and other fixed point types or integers, using the conversion rules described in 4.1.4 of N1169. Usual arithmetic rules do not apply to binary operations when one of the operands is a fixed point type, and the result of the operation must be calculated with the full precision of the operands, so we should not perform any casting to a common type. This patch does not include constant expression evaluation for addition of fixed point types. That will be addressed in another patch since I think this one is already big enough. Differential Revision: https://reviews.llvm.org/D53738 Added: cfe/trunk/test/Frontend/fixed_point_add.c Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/FixedPoint.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Basic/FixedPoint.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Frontend/fixed_point_conversions.c Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=351364&r1=351363&r2=351364&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jan 16 10:13:59 2019 @@ -2624,6 +2624,12 @@ public: // corresponding saturated type for a given fixed point type. QualType getCorrespondingSaturatedType(QualType Ty) const; + // This method accepts fixed point types and returns the corresponding signed + // type. Unlike getCorrespondingUnsignedType(), this only accepts unsigned + // fixed point types because there are unsigned integer types like bool and + // char8_t that don't have signed equivalents. + QualType getCorrespondingSignedFixedPointType(QualType Ty) const; + //======// //Integer Values //======// Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351364&r1=351363&r2=351364&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Wed Jan 16 10:13:59 2019 @@ -2269,6 +2269,9 @@ public: /// ISO/IEC JTC1 SC22 WG14 N1169. bool isFixedPointType() const; + /// Return true if this is a fixed point or integer type. + bool isFixedPointOrIntegerType() const; + /// Return true if this is a saturated fixed point type according to /// ISO/IEC JTC1 SC22 WG14 N1169. This type can be signed or unsigned. bool isSaturatedFixedPointType() const; @@ -6596,6 +6599,10 @@ inline bool Type::isFixedPointType() con return false; } +inline bool Type::isFixedPointOrIntegerType() const { + return isFixedPointType() || isIntegerType(); +} + inline bool Type::isSaturatedFixedPointType() const { if (const auto *BT = dyn_cast(CanonicalType)) { return BT->getKind() >= BuiltinType::SatShortAccum && Modified: cfe/trunk/include/clang/Basic/FixedPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=351364&r1=351363&r2=351364&view=diff == --- cfe/trunk/include/clang/Basic/FixedPoint.h (original) +++ cfe/trunk/include/clang/Basic/FixedPoint.h Wed Jan 16 10:13:59 2019 @@ -18,6 +18,7 @@ #define LLVM_CLANG_BASIC_FIXEDPOINT_H #include "llvm/ADT/APSInt.h" +#include "llvm/Support/raw_ostream.h" namespace clang { @@ -36,6 +37,8 @@ public: : Width(Width), Scale(Scale), IsSigned(IsSigned), IsSaturated(IsSaturated), HasUnsignedPadding(HasUnsignedPadding) { assert(Width >= Scale && "Not enough room for the scale"); +assert(!(IsSigned && HasUnsignedPadding) && + "Cannot have unsigned padding on a signed type."); } unsigned getWidth() const { return Width; } @@ -46,6 +49,9 @@ public: void setSaturated(bool Saturated) { IsSaturated = Saturated; } + /// Return the number of integral bits represented by these semantics. These + /// are separate from the fractional bits and do not include the sign or + /// padding bit. unsigned getIntegralBits() const { if (IsSigned || (!IsSigned && HasUnsignedPadding)) return Width - Scale - 1; @@ -53,6 +59,21 @@ public: return Width - Scale; } + /// Return the FixedPointSemantics that allows for calculating the full + /// precision semantic that can precisely represent the precision and ranges +
r351368 - [Fixed Point Arithmetic] Add APFixedPoint to APValue
Author: leonardchan Date: Wed Jan 16 10:53:05 2019 New Revision: 351368 URL: http://llvm.org/viewvc/llvm-project?rev=351368&view=rev Log: [Fixed Point Arithmetic] Add APFixedPoint to APValue This adds APFixedPoint to the union of values that can be represented with an APValue. Differential Revision: https://reviews.llvm.org/D56746 Modified: cfe/trunk/include/clang/AST/APValue.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/FixedPoint.h cfe/trunk/lib/AST/APValue.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Basic/FixedPoint.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp Modified: cfe/trunk/include/clang/AST/APValue.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=351368&r1=351367&r2=351368&view=diff == --- cfe/trunk/include/clang/AST/APValue.h (original) +++ cfe/trunk/include/clang/AST/APValue.h Wed Jan 16 10:53:05 2019 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_APVALUE_H #define LLVM_CLANG_AST_APVALUE_H +#include "clang/Basic/FixedPoint.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APSInt.h" @@ -43,6 +44,7 @@ public: Uninitialized, Int, Float, +FixedPoint, ComplexInt, ComplexFloat, LValue, @@ -175,6 +177,9 @@ public: explicit APValue(APFloat F) : Kind(Uninitialized) { MakeFloat(); setFloat(std::move(F)); } + explicit APValue(APFixedPoint FX) : Kind(Uninitialized) { +MakeFixedPoint(std::move(FX)); + } explicit APValue(const APValue *E, unsigned N) : Kind(Uninitialized) { MakeVector(); setVector(E, N); } @@ -233,6 +238,7 @@ public: bool isUninit() const { return Kind == Uninitialized; } bool isInt() const { return Kind == Int; } bool isFloat() const { return Kind == Float; } + bool isFixedPoint() const { return Kind == FixedPoint; } bool isComplexInt() const { return Kind == ComplexInt; } bool isComplexFloat() const { return Kind == ComplexFloat; } bool isLValue() const { return Kind == LValue; } @@ -265,6 +271,14 @@ public: return const_cast(this)->getFloat(); } + APFixedPoint &getFixedPoint() { +assert(isFixedPoint() && "Invalid accessor"); +return *(APFixedPoint *)(char *)Data.buffer; + } + const APFixedPoint &getFixedPoint() const { +return const_cast(this)->getFixedPoint(); + } + APSInt &getComplexIntReal() { assert(isComplexInt() && "Invalid accessor"); return ((ComplexAPSInt*)(char*)Data.buffer)->Real; @@ -406,6 +420,10 @@ public: assert(isFloat() && "Invalid accessor"); *(APFloat *)(char *)Data.buffer = std::move(F); } + void setFixedPoint(APFixedPoint FX) { +assert(isFixedPoint() && "Invalid accessor"); +*(APFixedPoint *)(char *)Data.buffer = std::move(FX); + } void setVector(const APValue *E, unsigned N) { assert(isVector() && "Invalid accessor"); ((Vec*)(char*)Data.buffer)->Elts = new APValue[N]; @@ -465,6 +483,11 @@ private: new ((void*)(char*)Data.buffer) APFloat(0.0); Kind = Float; } + void MakeFixedPoint(APFixedPoint &&FX) { +assert(isUninit() && "Bad state change"); +new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX)); +Kind = FixedPoint; + } void MakeVector() { assert(isUninit() && "Bad state change"); new ((void*)(char*)Data.buffer) Vec(); Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351368&r1=351367&r2=351368&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Wed Jan 16 10:53:05 2019 @@ -6848,6 +6848,8 @@ QualType DecayedType::getPointeeType() c // Get the decimal string representation of a fixed point type, represented // as a scaled integer. +// TODO: At some point, we should change the arguments to instead just accept an +// APFixedPoint instead of APSInt and scale. void FixedPointValueToString(SmallVectorImpl &Str, llvm::APSInt Val, unsigned Scale); Modified: cfe/trunk/include/clang/Basic/FixedPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=351368&r1=351367&r2=351368&view=diff == --- cfe/trunk/include/clang/Basic/FixedPoint.h (original) +++ cfe/trunk/include/clang/Basic/FixedPoint.h Wed Jan 16 10:53:05 2019 @@ -18,6 +18,7 @@ #define LLVM_CLANG_BASIC_FIXEDPOINT_H #include "llvm/ADT/APSInt.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" namespace clang { @@ -104,19 +105,25 @@ class APFixedPoint { : APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()), Sema) {} +
r351371 - [Fixed Point Arithmetic] Fixed Point Subtraction
Author: leonardchan Date: Wed Jan 16 11:53:50 2019 New Revision: 351371 URL: http://llvm.org/viewvc/llvm-project?rev=351371&view=rev Log: [Fixed Point Arithmetic] Fixed Point Subtraction This patch covers subtraction between fixed point types and other fixed point types or integers, using the conversion rules described in 4.1.4 of N1169. Differential Revision: https://reviews.llvm.org/D55844 Added: cfe/trunk/test/Frontend/fixed_point_sub.c Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=351371&r1=351370&r2=351371&view=diff == --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Jan 16 11:53:50 2019 @@ -740,7 +740,7 @@ public: } // Helper functions for fixed point binary operations. - Value *EmitFixedPointAdd(const BinOpInfo &Ops); + Value *EmitFixedPointBinOp(const BinOpInfo &Ops); BinOpInfo EmitBinOps(const BinaryOperator *E); LValue EmitCompoundAssignLValue(const CompoundAssignOperator *E, @@ -3360,19 +3360,20 @@ Value *ScalarExprEmitter::EmitAdd(const } if (op.isFixedPointBinOp()) -return EmitFixedPointAdd(op); +return EmitFixedPointBinOp(op); return Builder.CreateAdd(op.LHS, op.RHS, "add"); } /// The resulting value must be calculated with exact precision, so the operands /// may not be the same type. -Value *ScalarExprEmitter::EmitFixedPointAdd(const BinOpInfo &op) { +Value *ScalarExprEmitter::EmitFixedPointBinOp(const BinOpInfo &op) { using llvm::APSInt; using llvm::ConstantInt; const auto *BinOp = cast(op.E); - assert(BinOp->getOpcode() == BO_Add && "Expected operation to be addition"); + assert((BinOp->getOpcode() == BO_Add || BinOp->getOpcode() == BO_Sub) && + "Expected operation to be addition or subtraction"); // The result is a fixed point type and at least one of the operands is fixed // point while the other is either fixed point or an int. This resulting type @@ -3397,13 +3398,62 @@ Value *ScalarExprEmitter::EmitFixedPoint // Perform the actual addition. Value *Result; - if (ResultFixedSema.isSaturated()) { -llvm::Intrinsic::ID IID = ResultFixedSema.isSigned() - ? llvm::Intrinsic::sadd_sat - : llvm::Intrinsic::uadd_sat; -Result = Builder.CreateBinaryIntrinsic(IID, FullLHS, FullRHS); - } else { -Result = Builder.CreateAdd(FullLHS, FullRHS); + switch (BinOp->getOpcode()) { + case BO_Add: { +if (ResultFixedSema.isSaturated()) { + llvm::Intrinsic::ID IID = ResultFixedSema.isSigned() +? llvm::Intrinsic::sadd_sat +: llvm::Intrinsic::uadd_sat; + Result = Builder.CreateBinaryIntrinsic(IID, FullLHS, FullRHS); +} else { + Result = Builder.CreateAdd(FullLHS, FullRHS); +} +break; + } + case BO_Sub: { +if (ResultFixedSema.isSaturated()) { + llvm::Intrinsic::ID IID = ResultFixedSema.isSigned() +? llvm::Intrinsic::ssub_sat +: llvm::Intrinsic::usub_sat; + Result = Builder.CreateBinaryIntrinsic(IID, FullLHS, FullRHS); +} else { + Result = Builder.CreateSub(FullLHS, FullRHS); +} +break; + } + case BO_Mul: + case BO_Div: + case BO_Shl: + case BO_Shr: + case BO_Cmp: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: + case BO_NE: + case BO_LAnd: + case BO_LOr: + case BO_MulAssign: + case BO_DivAssign: + case BO_AddAssign: + case BO_SubAssign: + case BO_ShlAssign: + case BO_ShrAssign: +llvm_unreachable("Found unimplemented fixed point binary operation"); + case BO_PtrMemD: + case BO_PtrMemI: + case BO_Rem: + case BO_Xor: + case BO_And: + case BO_Or: + case BO_Assign: + case BO_RemAssign: + case BO_AndAssign: + case BO_XorAssign: + case BO_OrAssign: + case BO_Comma: +llvm_unreachable("Found unsupported binary operation for fixed point types."); } // Convert to the result type. @@ -3442,6 +3492,9 @@ Value *ScalarExprEmitter::EmitSub(const return propagateFMFlags(V, op); } +if (op.isFixedPointBinOp()) + return EmitFixedPointBinOp(op); + return Builder.CreateSub(op.LHS, op.RHS, "sub"); } Added: cfe/trunk/test/Frontend/fixed_point_sub.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/fixed_point_sub.c?rev=351371&view=auto == --- cfe/trunk/test/Frontend/fixed_point_sub.c (added) +++ cfe/trunk/test/Frontend/fixed_point_sub.c Wed Jan 16 11:53:50 2019 @@ -0,0 +1,390 @@ +// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED +// RUN: %clang_cc1 -ffixed-
r351593 - [Fixed Point Arithmetic] Fixed Point Addition Constant Expression Evaluation
Author: leonardchan Date: Fri Jan 18 13:04:25 2019 New Revision: 351593 URL: http://llvm.org/viewvc/llvm-project?rev=351593&view=rev Log: [Fixed Point Arithmetic] Fixed Point Addition Constant Expression Evaluation This patch includes logic for constant expression evaluation of fixed point additions. Differential Revision: https://reviews.llvm.org/D55868 Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/FixedPoint.h cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Basic/FixedPoint.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/Frontend/fixed_point_add.c cfe/trunk/test/Frontend/fixed_point_conversions.c cfe/trunk/test/Frontend/fixed_point_errors.c Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=351593&r1=351592&r2=351593&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Fri Jan 18 13:04:25 2019 @@ -23,6 +23,7 @@ #include "clang/AST/TemplateBase.h" #include "clang/AST/Type.h" #include "clang/Basic/CharInfo.h" +#include "clang/Basic/FixedPoint.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SyncScope.h" #include "clang/Basic/TypeTraits.h" @@ -611,6 +612,12 @@ public: EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects = SE_NoSideEffects) const; + /// EvaluateAsFloat - Return true if this is a constant which we can fold and + /// convert to a fixed point value. + bool EvaluateAsFixedPoint( + EvalResult &Result, const ASTContext &Ctx, + SideEffectsKind AllowSideEffects = SE_NoSideEffects) const; + /// isEvaluatable - Call EvaluateAsRValue to see if this expression can be /// constant folded without side-effects, but discard the result. bool isEvaluatable(const ASTContext &Ctx, Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=351593&r1=351592&r2=351593&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 18 13:04:25 2019 @@ -61,6 +61,7 @@ def IntConversion : DiagGroup<"int-conve def EnumConversion : DiagGroup<"enum-conversion">; def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">; def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">; +def ImplicitFixedPointConversion : DiagGroup<"implicit-fixed-point-conversion">; def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">; def FloatZeroConversion : DiagGroup<"float-zero-conversion">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351593&r1=351592&r2=351593&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 18 13:04:25 2019 @@ -3190,6 +3190,10 @@ def warn_impcast_bitfield_precision_cons "implicit truncation from %2 to bit-field changes value from %0 to %1">, InGroup; +def warn_impcast_fixed_point_range : Warning< + "implicit conversion from %0 cannot fit within the range of values for %1">, + InGroup; + def warn_impcast_literal_float_to_integer : Warning< "implicit conversion from %0 to %1 changes value from %2 to %3">, InGroup; Modified: cfe/trunk/include/clang/Basic/FixedPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=351593&r1=351592&r2=351593&view=diff == --- cfe/trunk/include/clang/Basic/FixedPoint.h (original) +++ cfe/trunk/include/clang/Basic/FixedPoint.h Fri Jan 18 13:04:25 2019 @@ -118,8 +118,21 @@ class APFixedPoint { bool getBoolValue() const { return Val.getBoolValue(); } - // Convert this number to match the semantics provided. - APFixedPoint convert(const FixedPointSemantics &DstSema) const; + // Convert this number to match the semantics provided. If the overflow + // parameter is provided, set this value to true or false to indicate if this + // operation results in an overflow. + APFixedPoint convert(const FixedPointSemantics &DstSema, +bool *Overflow = nullptr) const; + + // Perform binary operations on a fixed point type. The resulting fixed point + // value will be in the common, full precision semantics that can represent + // the precision and ranges os both input valu
r351997 - [Sema] Fix Modified Type in address_space AttributedType
Author: leonardchan Date: Wed Jan 23 16:11:35 2019 New Revision: 351997 URL: http://llvm.org/viewvc/llvm-project?rev=351997&view=rev Log: [Sema] Fix Modified Type in address_space AttributedType This is a fix for https://reviews.llvm.org/D51229 where we pass the address_space qualified type as the modified type of an AttributedType. This change now instead wraps the AttributedType with either the address_space qualifier or a DependentAddressSpaceType. Differential Revision: https://reviews.llvm.org/D55447 Added: cfe/trunk/test/AST/address_space_attribute.cpp Modified: cfe/trunk/docs/ReleaseNotes.rst cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/Index/print-type.m cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=351997&r1=351996&r2=351997&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Wed Jan 23 16:11:35 2019 @@ -162,7 +162,11 @@ clang-format libclang -... +- When `CINDEXTEST_INCLUDE_ATTRIBUTED_TYPES` is not provided when making a + CXType, the equivalent type of the AttributedType is returned instead of the + modified type if the user does not want attribute sugar. The equivalent type + represents the minimally-desugared type which the AttributedType is + canonically equivalent to. Static Analyzer Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=351997&r1=351996&r2=351997&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 23 16:11:35 2019 @@ -1411,6 +1411,10 @@ public: QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc); QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc); + QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, + SourceLocation AttrLoc); + + /// Same as above, but constructs the AddressSpace index if not provided. QualType BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace, SourceLocation AttrLoc); Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=351997&r1=351996&r2=351997&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Wed Jan 23 16:11:35 2019 @@ -3205,6 +3205,7 @@ bool AttributedType::isQualifier() const case attr::TypeNullable: case attr::TypeNullUnspecified: case attr::LifetimeBound: + case attr::AddressSpace: return true; // All other type attributes aren't qualifiers; they rewrite the modified Modified: cfe/trunk/lib/AST/TypePrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=351997&r1=351996&r2=351997&view=diff == --- cfe/trunk/lib/AST/TypePrinter.cpp (original) +++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Jan 23 16:11:35 2019 @@ -257,11 +257,17 @@ bool TypePrinter::canPrefixQualifiers(co case Type::FunctionProto: case Type::FunctionNoProto: case Type::Paren: -case Type::Attributed: case Type::PackExpansion: case Type::SubstTemplateTypeParm: CanPrefixQualifiers = false; break; + +case Type::Attributed: { + // We still want to print the address_space before the type if it is an + // address_space attribute. + const auto *AttrTy = cast(T); + CanPrefixQualifiers = AttrTy->getAttrKind() == attr::AddressSpace; +} } return CanPrefixQualifiers; @@ -1377,7 +1383,10 @@ void TypePrinter::printAttributedBefore( if (T->getAttrKind() == attr::ObjCKindOf) OS << "__kindof "; - printBefore(T->getModifiedType(), OS); + if (T->getAttrKind() == attr::AddressSpace) +printBefore(T->getEquivalentType(), OS); + else +printBefore(T->getModifiedType(), OS); if (T->isMSTypeSpec()) { switch (T->getAttrKind()) { Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=351997&r1=351996&r2=351997&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jan 23 16:11:35 2019 @@ -5787,28 +5787,27 @@ ParsedType Sema::ActOnObjCInstanceType(S // Type Attribute Processing //===--===/
r348434 - [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions
Author: leonardchan Date: Wed Dec 5 16:10:36 2018 New Revision: 348434 URL: http://llvm.org/viewvc/llvm-project?rev=348434&view=rev Log: [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions This patch creates a new context for every function definition we enter. Currently we do not push and pop on these, usually working off of the global context record added in the Sema constructor, which never gets popped. Differential Revision: https://reviews.llvm.org/D54014 Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=348434&r1=348433&r2=348434&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 5 16:10:36 2018 @@ -12828,6 +12828,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop // Parsing the function declaration failed in some way. Push on a fake scope // anyway so we can try to parse the function body. PushFunctionScope(); +PushExpressionEvaluationContext(ExprEvalContexts.back().Context); return D; } @@ -12838,6 +12839,11 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop else FD = cast(D); + // Do not push if it is a lambda because one is already pushed when building + // the lambda in ActOnStartOfLambdaDefinition(). + if (!isLambdaCallOperator(FD)) +PushExpressionEvaluationContext(ExprEvalContexts.back().Context); + // Check for defining attributes before the check for redefinition. if (const auto *Attr = FD->getAttr()) { Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0; @@ -13046,6 +13052,21 @@ Decl *Sema::ActOnFinishFunctionBody(Decl return ActOnFinishFunctionBody(D, BodyArg, false); } +/// RAII object that pops an ExpressionEvaluationContext when exiting a function +/// body. +class ExitFunctionBodyRAII { +public: + ExitFunctionBodyRAII(Sema &S, bool IsLambda) : S(S), IsLambda(IsLambda) {} + ~ExitFunctionBodyRAII() { +if (!IsLambda) + S.PopExpressionEvaluationContext(); + } + +private: + Sema &S; + bool IsLambda = false; +}; + Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, bool IsInstantiation) { FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr; @@ -13056,6 +13077,11 @@ Decl *Sema::ActOnFinishFunctionBody(Decl if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine()) CheckCompletedCoroutineBody(FD, Body); + // Do not call PopExpressionEvaluationContext() if it is a lambda because one + // is already popped when finishing the lambda in BuildLambdaExpr(). This is + // meant to pop the context added in ActOnStartOfFunctionDef(). + ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD)); + if (FD) { FD->setBody(Body); FD->setWillHaveBody(false); Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=348434&r1=348433&r2=348434&view=diff == --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Dec 5 16:10:36 2018 @@ -363,6 +363,8 @@ void Sema::ActOnStartOfObjCMethodDef(Sco assert((getCurMethodDecl() == nullptr) && "Methodparsing confused"); ObjCMethodDecl *MDecl = dyn_cast_or_null(D); + PushExpressionEvaluationContext(ExprEvalContexts.back().Context); + // If we don't have a valid method decl, simply return. if (!MDecl) return; Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=348434&r1=348433&r2=348434&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 5 16:10:36 2018 @@ -14414,11 +14414,8 @@ void Sema::PopExpressionEvaluationContex // Pop the current expression evaluation context off the stack. ExprEvalContexts.pop_back(); - if (!ExprEvalContexts.empty()) -ExprEvalContexts.back().NumTypos += NumTypos; - else -assert(NumTypos == 0 && "There are outstanding typos after popping the " -"last ExpressionEvaluationContextRecord"); + // The global expression evaluation context record is never popped. + ExprEvalContexts.back().NumTypos += NumTypos; } void Sema::DiscardCleanupsInEvaluationContext() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r348442 - [Sema/Attribute] Check for noderef attribute
Author: leonardchan Date: Wed Dec 5 17:05:54 2018 New Revision: 348442 URL: http://llvm.org/viewvc/llvm-project?rev=348442&view=rev Log: [Sema/Attribute] Check for noderef attribute This patch adds the noderef attribute in clang and checks for dereferences of types that have this attribute. This attribute is currently used by sparse and would like to be ported to clang. Differential Revision: https://reviews.llvm.org/D49511 Added: cfe/trunk/test/Frontend/noderef.c cfe/trunk/test/Frontend/noderef.cpp cfe/trunk/test/Frontend/noderef_on_non_pointers.m cfe/trunk/test/Frontend/noderef_templates.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=348442&r1=348441&r2=348442&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec 5 17:05:54 2018 @@ -1822,6 +1822,11 @@ def Regparm : TypeAttr { let ASTNode = 0; } +def NoDeref : TypeAttr { + let Spellings = [Clang<"noderef">]; + let Documentation = [NoDerefDocs]; +} + def ReqdWorkGroupSize : InheritableAttr { // Does not have a [[]] spelling because it is an OpenCL-related attribute. let Spellings = [GNU<"reqd_work_group_size">]; Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=348442&r1=348441&r2=348442&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Dec 5 17:05:54 2018 @@ -3593,6 +3593,63 @@ corresponding line within the inlined ca }]; } +def NoDerefDocs : Documentation { + let Category = DocCatType; + let Content = [{ +The ``noderef`` attribute causes clang to diagnose dereferences of annotated pointer types. +This is ideally used with pointers that point to special memory which cannot be read +from or written to, but allowing for the pointer to be used in pointer arithmetic. +The following are examples of valid expressions where dereferences are diagnosed: + +.. code-block:: c + + int __attribute__((noderef)) *p; + int x = *p; // warning + + int __attribute__((noderef)) **p2; + x = **p2; // warning + + int * __attribute__((noderef)) *p3; + p = *p3; // warning + + struct S { +int a; + }; + struct S __attribute__((noderef)) *s; + x = s->a;// warning + x = (*s).a; // warning + +Not all dereferences may diagnose a warning if the value directed by the pointer may not be +accessed. The following are examples of valid expressions where may not be diagnosed: + +.. code-block:: c + + int *q; + int __attribute__((noderef)) *p; + q = &*p; + q = *&p; + + struct S { +int a; + }; + struct S __attribute__((noderef)) *s; + p = &s->a; + p = &(*s).a; + +``noderef`` is currently only supported for pointers and arrays and not usable for +references or Objective-C object pointers. + +.. code-block: c++ + + int x = 2; + int __attribute__((noderef)) &y = x; // warning: 'noderef' can only be used on an array or pointer type + +.. code-block: objc + + id __attribute__((noderef)) obj = [NSObject new]; // warning: 'noderef' can only be used on an array or pointer type +}]; +} + def ReinitializesDocs : Documentation { let Category = DocCatFunction; let Content = [{ Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=348442&r1=348441&r2=348442&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Dec 5 17:05:54 2018 @@ -1039,3 +1039,5 @@ def ExperimentalISel : DiagGroup<"experi // A warning group specifically for warnings related to function // multiversioning. def FunctionMultiVersioning : DiagGroup<"function-multiversion">; + +def NoDeref : DiagGroup<"noderef">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348442&r1=348441&r2=348442&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticS
r355462 - [Fixed Point Arithmetic] Fixed Point and Integer Conversions
Author: leonardchan Date: Tue Mar 5 16:28:43 2019 New Revision: 355462 URL: http://llvm.org/viewvc/llvm-project?rev=355462&view=rev Log: [Fixed Point Arithmetic] Fixed Point and Integer Conversions This patch includes the necessary code for converting between a fixed point type and integer. This also includes constant expression evaluation for conversions with these types. Differential Revision: https://reviews.llvm.org/D56900 Modified: cfe/trunk/include/clang/AST/OperationKinds.def cfe/trunk/include/clang/Basic/FixedPoint.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Basic/FixedPoint.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp cfe/trunk/test/Frontend/fixed_point_conversions.c cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_unknown_conversions.c Modified: cfe/trunk/include/clang/AST/OperationKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=355462&r1=355461&r2=355462&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.def (original) +++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Mar 5 16:28:43 2019 @@ -200,6 +200,14 @@ CAST_OPERATION(IntegralToFloating) ///(_Accum) 0.5r CAST_OPERATION(FixedPointCast) +/// CK_FixedPointToIntegral - Fixed point to integral. +///(int) 2.0k +CAST_OPERATION(FixedPointToIntegral) + +/// CK_IntegralToFixedPoint - Integral to a fixed point. +///(_Accum) 2 +CAST_OPERATION(IntegralToFixedPoint) + /// CK_FixedPointToBoolean - Fixed point to boolean. ///(bool) 0.5r CAST_OPERATION(FixedPointToBoolean) Modified: cfe/trunk/include/clang/Basic/FixedPoint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=355462&r1=355461&r2=355462&view=diff == --- cfe/trunk/include/clang/Basic/FixedPoint.h (original) +++ cfe/trunk/include/clang/Basic/FixedPoint.h Tue Mar 5 16:28:43 2019 @@ -141,6 +141,8 @@ class APFixedPoint { return APFixedPoint(Val << Amt, Sema); } + /// Return the integral part of this fixed point number, rounded towards + /// zero. (-2.5k -> -2) llvm::APSInt getIntPart() const { if (Val < 0 && Val != -Val) // Cover the case when we have the min val return -(-Val >> getScale()); @@ -148,6 +150,17 @@ class APFixedPoint { return Val >> getScale(); } + /// Return the integral part of this fixed point number, rounded towards + /// zero. The value is stored into an APSInt with the provided width and sign. + /// If the overflow parameter is provided, and the integral value is not able + /// to be fully stored in the provided width and sign, the overflow parameter + /// is set to true. + /// + /// If the overflow parameter is provided, set this value to true or false to + /// indicate if this operation results in an overflow. + llvm::APSInt convertToInt(unsigned DstWidth, bool DstSign, +bool *Overflow = nullptr) const; + void toString(llvm::SmallVectorImpl &Str) const; std::string toString() const { llvm::SmallString<40> S; @@ -175,6 +188,14 @@ class APFixedPoint { static APFixedPoint getMax(const FixedPointSemantics &Sema); static APFixedPoint getMin(const FixedPointSemantics &Sema); + /// Create an APFixedPoint with a value equal to that of the provided integer, + /// and in the same semantics as the provided target semantics. If the value + /// is not able to fit in the specified fixed point semantics, and the + /// overflow parameter is provided, it is set to true. + static APFixedPoint getFromIntValue(const llvm::APSInt &Value, + const FixedPointSemantics &DstFXSema, + bool *Overflow = nullptr); + private: llvm::APSInt Val; FixedPointSemantics Sema; Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=355462&r1=355461&r2=355462&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Mar 5 16:28:43 2019 @@ -1718,6 +1718,8 @@ bool CastExpr::CastConsistency() const { case CK_ZeroToOCLOpaqueType: case CK_IntToOCLSampler: case CK_FixedPointCast: + case CK_FixedPointToIntegral: + case CK_IntegralToFixedPoint: assert(!getType()->isBooleanType() && "unheralded conversion to bool"); goto CheckNoBasePat
r358538 - [NFC] Remove unused function (Sema::pushExternalDeclIntoScope)
Author: leonardchan Date: Tue Apr 16 15:59:39 2019 New Revision: 358538 URL: http://llvm.org/viewvc/llvm-project?rev=358538&view=rev Log: [NFC] Remove unused function (Sema::pushExternalDeclIntoScope) Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=358538&r1=358537&r2=358538&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Apr 16 15:59:39 2019 @@ -2487,14 +2487,6 @@ public: /// Add this decl to the scope shadowed decl chains. void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true); - /// Make the given externally-produced declaration visible at the - /// top level scope. - /// - /// \param D The externally-produced declaration to push. - /// - /// \param Name The name of the externally-produced declaration. - void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name); - /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns /// true if 'D' belongs to the given declaration context. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=358538&r1=358537&r2=358538&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 16 15:59:39 2019 @@ -1404,11 +1404,6 @@ void Sema::PushOnScopeChains(NamedDecl * } } -void Sema::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) { - if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope) -TUScope->AddDecl(D); -} - bool Sema::isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S, bool AllowInlineNamespace) { return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r359826 - [Attribute/Diagnostics] Print macro if definition is an attribute declaration
Author: leonardchan Date: Thu May 2 13:38:14 2019 New Revision: 359826 URL: http://llvm.org/viewvc/llvm-project?rev=359826&view=rev Log: [Attribute/Diagnostics] Print macro if definition is an attribute declaration If an address_space attribute is defined in a macro, print the macro instead when diagnosing a warning or error for incompatible pointers with different address_spaces. We allow this for all attributes (not just address_space), and for multiple attributes declared in the same macro. Differential Revision: https://reviews.llvm.org/D51329 Added: cfe/trunk/test/Frontend/macro_defined_type.cpp cfe/trunk/test/Sema/address_space_print_macro.c Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/AST/TypeLoc.h cfe/trunk/include/clang/AST/TypeNodes.def cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/ParsedAttr.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTDiagnostic.cpp cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/Sema/address_spaces.c cfe/trunk/test/SemaObjC/externally-retained.m cfe/trunk/test/SemaObjC/gc-attributes.m cfe/trunk/test/SemaObjC/mrc-weak.m cfe/trunk/test/SemaObjCXX/gc-attributes.mm cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=359826&r1=359825&r2=359826&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Thu May 2 13:38:14 2019 @@ -1441,6 +1441,9 @@ public: QualType getParenType(QualType NamedType) const; + QualType getMacroQualifiedType(QualType UnderlyingTy, + const IdentifierInfo *MacroII) const; + QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl = nullptr) const; Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=359826&r1=359825&r2=359826&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu May 2 13:38:14 2019 @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType, DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); }) +DEF_TRAVERSE_TYPE(MacroQualifiedType, + { TRY_TO(TraverseType(T->getUnderlyingType())); }) + DEF_TRAVERSE_TYPE(ElaboratedType, { if (T->getQualifier()) { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); @@ -1308,6 +1311,9 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) +DEF_TRAVERSE_TYPELOC(MacroQualifiedType, + { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) + DEF_TRAVERSE_TYPELOC(AttributedType, { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); }) Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=359826&r1=359825&r2=359826&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu May 2 13:38:14 2019 @@ -4184,6 +4184,41 @@ public: static bool classof(const Type *T) { return T->getTypeClass() == Typedef; } }; +/// Sugar type that represents a type that was qualified by a qualifier written +/// as a macro invocation. +class MacroQualifiedType : public Type { + friend class ASTContext; // ASTContext creates these. + + QualType UnderlyingTy; + const IdentifierInfo *MacroII; + + MacroQualifiedType(QualType UnderlyingTy, QualType CanonTy, + const IdentifierInfo *MacroII) + : Type(MacroQualified, CanonTy, UnderlyingTy->isDependentType(), + UnderlyingTy->isInstantiationDependentType(), + UnderlyingTy->isVariab
r359859 - Revert "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Author: leonardchan Date: Thu May 2 20:28:06 2019 New Revision: 359859 URL: http://llvm.org/viewvc/llvm-project?rev=359859&view=rev Log: Revert "[Attribute/Diagnostics] Print macro if definition is an attribute declaration" This reverts commit fc40cbd9d8c63e65eed3590ba925321afe782e1d. Removed: cfe/trunk/test/Frontend/macro_defined_type.cpp cfe/trunk/test/Sema/address_space_print_macro.c Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/AST/TypeLoc.h cfe/trunk/include/clang/AST/TypeNodes.def cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/ParsedAttr.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTDiagnostic.cpp cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/Sema/address_spaces.c cfe/trunk/test/SemaObjC/externally-retained.m cfe/trunk/test/SemaObjC/gc-attributes.m cfe/trunk/test/SemaObjC/mrc-weak.m cfe/trunk/test/SemaObjCXX/gc-attributes.mm cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=359859&r1=359858&r2=359859&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Thu May 2 20:28:06 2019 @@ -1441,9 +1441,6 @@ public: QualType getParenType(QualType NamedType) const; - QualType getMacroQualifiedType(QualType UnderlyingTy, - const IdentifierInfo *MacroII) const; - QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl = nullptr) const; Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=359859&r1=359858&r2=359859&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu May 2 20:28:06 2019 @@ -1065,9 +1065,6 @@ DEF_TRAVERSE_TYPE(AttributedType, DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); }) -DEF_TRAVERSE_TYPE(MacroQualifiedType, - { TRY_TO(TraverseType(T->getUnderlyingType())); }) - DEF_TRAVERSE_TYPE(ElaboratedType, { if (T->getQualifier()) { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); @@ -1311,9 +1308,6 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) -DEF_TRAVERSE_TYPELOC(MacroQualifiedType, - { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) - DEF_TRAVERSE_TYPELOC(AttributedType, { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); }) Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=359859&r1=359858&r2=359859&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu May 2 20:28:06 2019 @@ -4184,41 +4184,6 @@ public: static bool classof(const Type *T) { return T->getTypeClass() == Typedef; } }; -/// Sugar type that represents a type that was qualified by a qualifier written -/// as a macro invocation. -class MacroQualifiedType : public Type { - friend class ASTContext; // ASTContext creates these. - - QualType UnderlyingTy; - const IdentifierInfo *MacroII; - - MacroQualifiedType(QualType UnderlyingTy, QualType CanonTy, - const IdentifierInfo *MacroII) - : Type(MacroQualified, CanonTy, UnderlyingTy->isDependentType(), - UnderlyingTy->isInstantiationDependentType(), - UnderlyingTy->isVariablyModifiedType(), - UnderlyingTy->containsUnexpandedParameterPack()), -UnderlyingTy(UnderlyingTy), MacroII(MacroII) { -assert(isa(UnderlyingTy) && - "Expected a macro qualified type to only wrap attributed types."); - } - -public: -
r360089 - [Sema] Fix for P41774 where `ExpectNoDerefChunk` is assigned twice
Author: leonardchan Date: Mon May 6 15:09:12 2019 New Revision: 360089 URL: http://llvm.org/viewvc/llvm-project?rev=360089&view=rev Log: [Sema] Fix for P41774 where `ExpectNoDerefChunk` is assigned twice Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360089&r1=360088&r2=360089&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 6 15:09:12 2019 @@ -4979,11 +4979,8 @@ static TypeSourceInfo *GetFullTypeForDec processTypeAttrs(state, T, TAL_DeclChunk, DeclType.getAttrs()); if (DeclType.Kind != DeclaratorChunk::Paren) { - if (ExpectNoDerefChunk) { -if (!IsNoDerefableChunk(DeclType)) - S.Diag(DeclType.Loc, diag::warn_noderef_on_non_pointer_or_array); -ExpectNoDerefChunk = false; - } + if (ExpectNoDerefChunk && !IsNoDerefableChunk(DeclType)) +S.Diag(DeclType.Loc, diag::warn_noderef_on_non_pointer_or_array); ExpectNoDerefChunk = state.didParseNoDeref(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Author: leonardchan Date: Mon May 6 20:20:17 2019 New Revision: 360109 URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev Log: Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration" Updated with fix for read of uninitialized memory. Added: cfe/trunk/test/Frontend/macro_defined_type.cpp cfe/trunk/test/Sema/address_space_print_macro.c Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/AST/TypeLoc.h cfe/trunk/include/clang/AST/TypeNodes.def cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/ParsedAttr.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTDiagnostic.cpp cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/Sema/address_spaces.c cfe/trunk/test/SemaObjC/externally-retained.m cfe/trunk/test/SemaObjC/gc-attributes.m cfe/trunk/test/SemaObjC/mrc-weak.m cfe/trunk/test/SemaObjCXX/gc-attributes.mm cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May 6 20:20:17 2019 @@ -1441,6 +1441,9 @@ public: QualType getParenType(QualType NamedType) const; + QualType getMacroQualifiedType(QualType UnderlyingTy, + const IdentifierInfo *MacroII) const; + QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl = nullptr) const; Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109&r1=360108&r2=360109&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May 6 20:20:17 2019 @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType, DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); }) +DEF_TRAVERSE_TYPE(MacroQualifiedType, + { TRY_TO(TraverseType(T->getUnderlyingType())); }) + DEF_TRAVERSE_TYPE(ElaboratedType, { if (T->getQualifier()) { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); @@ -1308,6 +1311,9 @@ DEF_TRAVERSE_TYPELOC(InjectedClassNameTy DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) +DEF_TRAVERSE_TYPELOC(MacroQualifiedType, + { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); }) + DEF_TRAVERSE_TYPELOC(AttributedType, { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); }) Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=360109&r1=360108&r2=360109&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Mon May 6 20:20:17 2019 @@ -4184,6 +4184,41 @@ public: static bool classof(const Type *T) { return T->getTypeClass() == Typedef; } }; +/// Sugar type that represents a type that was qualified by a qualifier written +/// as a macro invocation. +class MacroQualifiedType : public Type { + friend class ASTContext; // ASTContext creates these. + + QualType UnderlyingTy; + const IdentifierInfo *MacroII; + + MacroQualifiedType(QualType UnderlyingTy, QualType CanonTy, + const IdentifierInfo *MacroII) + : Type(MacroQualified, CanonTy, UnderlyingTy->isDependentType(), + UnderlyingTy->isInstantiationDependentType(), + UnderlyingTy->isVariablyModifiedType(), + UnderlyingTy->containsUnexpandedParameterPack()), +UnderlyingTy(UnderlyingTy), MacroII(MacroII) { +assert(isa(UnderlyingTy) && + "Expected a macro qualified type to only wrap attributed types."); + } + +public: + c
r360120 - [Sema] Add missing VisitMacroQualifiedTypeLoc to TypeSpecLocFiller
Author: leonardchan Date: Tue May 7 01:12:28 2019 New Revision: 360120 URL: http://llvm.org/viewvc/llvm-project?rev=360120&view=rev Log: [Sema] Add missing VisitMacroQualifiedTypeLoc to TypeSpecLocFiller To hopefully fix greenbot failures Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360120&r1=360119&r2=360120&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Tue May 7 01:12:28 2019 @@ -5388,6 +5388,11 @@ namespace { Visit(TL.getModifiedLoc()); fillAttributedTypeLoc(TL, State); } +void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) { + Visit(TL.getInnerLoc()); + TL.setExpansionLoc( + State.getExpansionLocForMacroQualifiedType(TL.getTypePtr())); +} void VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { Visit(TL.getUnqualifiedLoc()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Yup, sorry for the delay. I submitted it overnight thinking it would be fixed this time. I have one more way that I think should fix it, but before trying it out, do you know any tips on how I can try to reproduce this locally? I see that you're running these on an x64 mac, but I can't seem to trigger this on our own mac builders. Also as a side question, do you what RA stands for in "Clang Stage 1: cmake, incremental RA, using system compiler <http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"? It seems that I'm only breaking the non-incremental RA jobs, bit the incremental one still works fine with my change. Thanks, Leonard On Tue, May 7, 2019, 09:26 Jonas Devlieghere wrote: > Hi Leonard, > > It appears that your patch is still triggering an assertion on > GreenDragon: > http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c > > Can you please have a look? > > Thanks, > Jonas > > > On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: leonardchan >> Date: Mon May 6 20:20:17 2019 >> New Revision: 360109 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev >> Log: >> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an >> attribute declaration" >> >> Updated with fix for read of uninitialized memory. >> >> Added: >> cfe/trunk/test/Frontend/macro_defined_type.cpp >> cfe/trunk/test/Sema/address_space_print_macro.c >> Modified: >> cfe/trunk/include/clang/AST/ASTContext.h >> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h >> cfe/trunk/include/clang/AST/Type.h >> cfe/trunk/include/clang/AST/TypeLoc.h >> cfe/trunk/include/clang/AST/TypeNodes.def >> cfe/trunk/include/clang/Parse/Parser.h >> cfe/trunk/include/clang/Sema/ParsedAttr.h >> cfe/trunk/include/clang/Sema/Sema.h >> cfe/trunk/include/clang/Serialization/ASTBitCodes.h >> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp >> cfe/trunk/lib/AST/ASTContext.cpp >> cfe/trunk/lib/AST/ASTDiagnostic.cpp >> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp >> cfe/trunk/lib/AST/ItaniumMangle.cpp >> cfe/trunk/lib/AST/Type.cpp >> cfe/trunk/lib/AST/TypePrinter.cpp >> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp >> cfe/trunk/lib/Parse/ParseDecl.cpp >> cfe/trunk/lib/Sema/SemaExpr.cpp >> cfe/trunk/lib/Sema/SemaStmt.cpp >> cfe/trunk/lib/Sema/SemaType.cpp >> cfe/trunk/lib/Sema/TreeTransform.h >> cfe/trunk/lib/Serialization/ASTReader.cpp >> cfe/trunk/lib/Serialization/ASTWriter.cpp >> cfe/trunk/test/Sema/address_spaces.c >> cfe/trunk/test/SemaObjC/externally-retained.m >> cfe/trunk/test/SemaObjC/gc-attributes.m >> cfe/trunk/test/SemaObjC/mrc-weak.m >> cfe/trunk/test/SemaObjCXX/gc-attributes.mm >> cfe/trunk/tools/libclang/CIndex.cpp >> >> Modified: cfe/trunk/include/clang/AST/ASTContext.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff >> >> == >> --- cfe/trunk/include/clang/AST/ASTContext.h (original) >> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May 6 20:20:17 2019 >> @@ -1441,6 +1441,9 @@ public: >> >>QualType getParenType(QualType NamedType) const; >> >> + QualType getMacroQualifiedType(QualType UnderlyingTy, >> + const IdentifierInfo *MacroII) const; >> + >>QualType getElaboratedType(ElaboratedTypeKeyword Keyword, >> NestedNameSpecifier *NNS, QualType >> NamedType, >> TagDecl *OwnedTagDecl = nullptr) const; >> >> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=360109&r1=360108&r2=360109&view=diff >> >> == >> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) >> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon May 6 20:20:17 >> 2019 >> @@ -1065,6 +1065,9 @@ DEF_TRAVERSE_TYPE(AttributedType, >> >> DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType()));
Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Thanks! It turns out that we weren't running debuginfo-tests. Trying to find a mac I can ssh into to reproduce this. Another side question: is there usually an etiquette for how long a greendragon bot is allowed to stay broken? I don't want to leave it that way for too long while working on my fix if it bothers others too much. Thanks, Leonard On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere wrote: > Hi Leonard, > > The test that is asserting is part of the debuginfo test. ( > https://github.com/llvm-project/debuginfo-tests) > The reason that it's only failing on the non-incremental bot is because > the incremental one isn't running those, I believe. > > RA stands for Release/Asserts. > > Hope that helps! > > Cheers, > Jonas > > On Tue, May 7, 2019 at 9:44 AM Leonard Chan > wrote: > >> Yup, sorry for the delay. I submitted it overnight thinking it would be >> fixed this time. I have one more way that I think should fix it, but before >> trying it out, do you know any tips on how I can try to reproduce this >> locally? I see that you're running these on an x64 mac, but I can't seem to >> trigger this on our own mac builders. Also as a side question, do you what >> RA stands for in "Clang Stage 1: cmake, incremental RA, using system >> compiler >> <http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"? >> It seems that I'm only breaking the non-incremental RA jobs, bit the >> incremental one still works fine with my change. >> >> Thanks, >> Leonard >> >> On Tue, May 7, 2019, 09:26 Jonas Devlieghere >> wrote: >> >>> Hi Leonard, >>> >>> It appears that your patch is still triggering an assertion on >>> GreenDragon: >>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c >>> >>> Can you please have a look? >>> >>> Thanks, >>> Jonas >>> >>> >>> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> >>>> Author: leonardchan >>>> Date: Mon May 6 20:20:17 2019 >>>> New Revision: 360109 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev >>>> Log: >>>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is >>>> an attribute declaration" >>>> >>>> Updated with fix for read of uninitialized memory. >>>> >>>> Added: >>>> cfe/trunk/test/Frontend/macro_defined_type.cpp >>>> cfe/trunk/test/Sema/address_space_print_macro.c >>>> Modified: >>>> cfe/trunk/include/clang/AST/ASTContext.h >>>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h >>>> cfe/trunk/include/clang/AST/Type.h >>>> cfe/trunk/include/clang/AST/TypeLoc.h >>>> cfe/trunk/include/clang/AST/TypeNodes.def >>>> cfe/trunk/include/clang/Parse/Parser.h >>>> cfe/trunk/include/clang/Sema/ParsedAttr.h >>>> cfe/trunk/include/clang/Sema/Sema.h >>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h >>>> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp >>>> cfe/trunk/lib/AST/ASTContext.cpp >>>> cfe/trunk/lib/AST/ASTDiagnostic.cpp >>>> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp >>>> cfe/trunk/lib/AST/ItaniumMangle.cpp >>>> cfe/trunk/lib/AST/Type.cpp >>>> cfe/trunk/lib/AST/TypePrinter.cpp >>>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >>>> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp >>>> cfe/trunk/lib/Parse/ParseDecl.cpp >>>> cfe/trunk/lib/Sema/SemaExpr.cpp >>>> cfe/trunk/lib/Sema/SemaStmt.cpp >>>> cfe/trunk/lib/Sema/SemaType.cpp >>>> cfe/trunk/lib/Sema/TreeTransform.h >>>> cfe/trunk/lib/Serialization/ASTReader.cpp >>>> cfe/trunk/lib/Serialization/ASTWriter.cpp >>>> cfe/trunk/test/Sema/address_spaces.c >>>> cfe/trunk/test/SemaObjC/externally-retained.m >>>> cfe/trunk/test/SemaObjC/gc-attributes.m >>>> cfe/trunk/test/SemaObjC/mrc-weak.m >>>> cfe/trunk/test/SemaObjCXX/gc-attributes.mm >>>> cfe/trunk/tools/libclang/CIndex.cpp >>>> >>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h >>>> URL: >>>> http://llvm.org/viewvc/llvm-p
r360225 - Fix for the greendragon bots.
Author: leonardchan Date: Tue May 7 22:59:25 2019 New Revision: 360225 URL: http://llvm.org/viewvc/llvm-project?rev=360225&view=rev Log: Fix for the greendragon bots. Adds extra checks for ObjC GC and Ownership. Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaObjC/mrc-weak.m Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360225&r1=360224&r2=360225&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Tue May 7 22:59:25 2019 @@ -7612,7 +7612,9 @@ static void processTypeAttrs(TypeProcess // applied to ObjC builtin attributes. if (isa(type) && attr.hasMacroIdentifier() && !type.getQualifiers().hasObjCLifetime() && -!type.getQualifiers().hasObjCGCAttr()) { +!type.getQualifiers().hasObjCGCAttr() && +attr.getKind() != ParsedAttr::AT_ObjCGC && +attr.getKind() != ParsedAttr::AT_ObjCOwnership) { const IdentifierInfo *MacroII = attr.getMacroIdentifier(); type = state.getSema().Context.getMacroQualifiedType(type, MacroII); state.setExpansionLocForMacroQualifiedType( Modified: cfe/trunk/test/SemaObjC/mrc-weak.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/mrc-weak.m?rev=360225&r1=360224&r2=360225&view=diff == --- cfe/trunk/test/SemaObjC/mrc-weak.m (original) +++ cfe/trunk/test/SemaObjC/mrc-weak.m Tue May 7 22:59:25 2019 @@ -62,6 +62,6 @@ void test_unsafe_unretained_cast(id *val void test_cast_qualifier_inference(__weak id *value) { __weak id *a = (id*) value; - __unsafe_unretained id *b = (id *)value; // expected-error {{initializing '__unsafe_unretained id *' with an expression of type '__weak id *' changes retain/release properties of pointer}} + __unsafe_unretained id *b = (id *)value; // expected-error {{initializing 'id *' with an expression of type '__weak id *' changes retain/release properties of pointer}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Just wanted to update. My latest revision (r360225) seems to have fixed the bots. 🎉 On Tue, May 7, 2019 at 3:50 PM Jonas Devlieghere wrote: > Hi Leonard, > > My personal rule of thumb is that if I can fix it in something like 30 > minutes or less, I'll leave the bot red and commit a fix. Otherwise I'll > revert my change. The problem with leaving the bot red is that if something > else breaks, that person doesn't get a signal, and issue start to pile up. > > When I see a bot is red and it's blocking me, I will usually send an > e-mail and wait about the same time for a reply, before reverting the > change myself. > > Cheers, > Jonas > > On Tue, May 7, 2019 at 11:20 AM Leonard Chan > wrote: > >> Thanks! It turns out that we weren't running debuginfo-tests. Trying to >> find a mac I can ssh into to reproduce this. >> >> Another side question: is there usually an etiquette for how long a >> greendragon bot is allowed to stay broken? I don't want to leave it that >> way for too long while working on my fix if it bothers others too much. >> >> Thanks, >> Leonard >> >> On Tue, May 7, 2019 at 10:13 AM Jonas Devlieghere >> wrote: >> >>> Hi Leonard, >>> >>> The test that is asserting is part of the debuginfo test. ( >>> https://github.com/llvm-project/debuginfo-tests) >>> The reason that it's only failing on the non-incremental bot is because >>> the incremental one isn't running those, I believe. >>> >>> RA stands for Release/Asserts. >>> >>> Hope that helps! >>> >>> Cheers, >>> Jonas >>> >>> On Tue, May 7, 2019 at 9:44 AM Leonard Chan >>> wrote: >>> >>>> Yup, sorry for the delay. I submitted it overnight thinking it would be >>>> fixed this time. I have one more way that I think should fix it, but before >>>> trying it out, do you know any tips on how I can try to reproduce this >>>> locally? I see that you're running these on an x64 mac, but I can't seem to >>>> trigger this on our own mac builders. Also as a side question, do you what >>>> RA stands for in "Clang Stage 1: cmake, incremental RA, using system >>>> compiler >>>> <http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/>"? >>>> It seems that I'm only breaking the non-incremental RA jobs, bit the >>>> incremental one still works fine with my change. >>>> >>>> Thanks, >>>> Leonard >>>> >>>> On Tue, May 7, 2019, 09:26 Jonas Devlieghere >>>> wrote: >>>> >>>>> Hi Leonard, >>>>> >>>>> It appears that your patch is still triggering an assertion on >>>>> GreenDragon: >>>>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/56255/consoleFull#312501878d489585b-5106-414a-ac11-3ff90657619c >>>>> >>>>> Can you please have a look? >>>>> >>>>> Thanks, >>>>> Jonas >>>>> >>>>> >>>>> On Mon, May 6, 2019 at 8:17 PM Leonard Chan via cfe-commits < >>>>> cfe-commits@lists.llvm.org> wrote: >>>>> >>>>>> Author: leonardchan >>>>>> Date: Mon May 6 20:20:17 2019 >>>>>> New Revision: 360109 >>>>>> >>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev >>>>>> Log: >>>>>> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition >>>>>> is an attribute declaration" >>>>>> >>>>>> Updated with fix for read of uninitialized memory. >>>>>> >>>>>> Added: >>>>>> cfe/trunk/test/Frontend/macro_defined_type.cpp >>>>>> cfe/trunk/test/Sema/address_space_print_macro.c >>>>>> Modified: >>>>>> cfe/trunk/include/clang/AST/ASTContext.h >>>>>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h >>>>>> cfe/trunk/include/clang/AST/Type.h >>>>>> cfe/trunk/include/clang/AST/TypeLoc.h >>>>>> cfe/trunk/include/clang/AST/TypeNodes.def >>>>>> cfe/trunk/include/clang/Parse/Parser.h >>>>>> cfe/trunk/include/clang/Sema/ParsedAttr.h >>>>>> cfe/trunk/include/clang/Sema/Sema.h >>>>>> cfe/trunk/
r342793 - [Lexer] Add udefined_behavior_sanitizer feature
Author: leonardchan Date: Fri Sep 21 18:03:16 2018 New Revision: 342793 URL: http://llvm.org/viewvc/llvm-project?rev=342793&view=rev Log: [Lexer] Add udefined_behavior_sanitizer feature This can be used to detect whether the code is being built with UBSan using the __has_feature(undefined_behavior_sanitizer) predicate. Differential Revision: https://reviews.llvm.org/D52386 Added: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp Modified: cfe/trunk/include/clang/Basic/Features.def Modified: cfe/trunk/include/clang/Basic/Features.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=342793&r1=342792&r2=342793&view=diff == --- cfe/trunk/include/clang/Basic/Features.def (original) +++ cfe/trunk/include/clang/Basic/Features.def Fri Sep 21 18:03:16 2018 @@ -38,6 +38,8 @@ FEATURE(hwaddress_sanitizer, LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress)) FEATURE(xray_instrument, LangOpts.XRayInstrument) +FEATURE(undefined_behavior_sanitizer, +LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined)) FEATURE(assume_nonnull, true) FEATURE(attribute_analyzer_noreturn, true) FEATURE(attribute_availability, true) Added: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp?rev=342793&view=auto == --- cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp (added) +++ cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp Fri Sep 21 18:03:16 2018 @@ -0,0 +1,13 @@ +// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s +// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck --check-prefix=CHECK-ALIGNMENT %s +// RUN: %clang -E %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s + +#if __has_feature(undefined_behavior_sanitizer) +int UBSanEnabled(); +#else +int UBSanDisabled(); +#endif + +// CHECK-UBSAN: UBSanEnabled +// CHECK-ALIGNMENT: UBSanEnabled +// CHECK-NO-UBSAN: UBSanDisabled ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r342793 - [Lexer] Add udefined_behavior_sanitizer feature
My bad. I saw that Vitaly accepted it and thought it would be ok since I got 2 LGTMs. On Fri, Sep 21, 2018 at 6:21 PM Aaron Ballman wrote: > > The reviewer asked you to wait a day so that others might have a > chance to review it, so this commit seems premature. I have no > technical concerns with the patch, but the sanitizer owners should > have had a chance to weigh in. That said, I don't see value in > reverting and recommitting later, so if there are concerns, they can > be dealt with post commit. > > ~Aaron > > On Fri, Sep 21, 2018 at 9:03 PM, Leonard Chan via cfe-commits > wrote: > > Author: leonardchan > > Date: Fri Sep 21 18:03:16 2018 > > New Revision: 342793 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=342793&view=rev > > Log: > > [Lexer] Add udefined_behavior_sanitizer feature > > > > This can be used to detect whether the code is being built with UBSan using > > the __has_feature(undefined_behavior_sanitizer) predicate. > > > > Differential Revision: https://reviews.llvm.org/D52386 > > > > Added: > > cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp > > Modified: > > cfe/trunk/include/clang/Basic/Features.def > > > > Modified: cfe/trunk/include/clang/Basic/Features.def > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=342793&r1=342792&r2=342793&view=diff > > == > > --- cfe/trunk/include/clang/Basic/Features.def (original) > > +++ cfe/trunk/include/clang/Basic/Features.def Fri Sep 21 18:03:16 2018 > > @@ -38,6 +38,8 @@ FEATURE(hwaddress_sanitizer, > > LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress | > > SanitizerKind::KernelHWAddress)) > > FEATURE(xray_instrument, LangOpts.XRayInstrument) > > +FEATURE(undefined_behavior_sanitizer, > > +LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined)) > > FEATURE(assume_nonnull, true) > > FEATURE(attribute_analyzer_noreturn, true) > > FEATURE(attribute_availability, true) > > > > Added: cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp?rev=342793&view=auto > > == > > --- cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp > > (added) > > +++ cfe/trunk/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp Fri > > Sep 21 18:03:16 2018 > > @@ -0,0 +1,13 @@ > > +// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck > > --check-prefix=CHECK-UBSAN %s > > +// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck > > --check-prefix=CHECK-ALIGNMENT %s > > +// RUN: %clang -E %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s > > + > > +#if __has_feature(undefined_behavior_sanitizer) > > +int UBSanEnabled(); > > +#else > > +int UBSanDisabled(); > > +#endif > > + > > +// CHECK-UBSAN: UBSanEnabled > > +// CHECK-ALIGNMENT: UBSanEnabled > > +// CHECK-NO-UBSAN: UBSanDisabled > > > > > > ___ > > 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
r353985 - [NewPM] Second attempt at porting ASan
Author: leonardchan Date: Wed Feb 13 14:22:48 2019 New Revision: 353985 URL: http://llvm.org/viewvc/llvm-project?rev=353985&view=rev Log: [NewPM] Second attempt at porting ASan This is the second attempt to port ASan to new PM after D52739. This takes the initialization requried by ASan from the Module by moving it into a separate class with it's own analysis that the new PM ASan can use. Changes: - Split AddressSanitizer into 2 passes: 1 for the instrumentation on the function, and 1 for the pass itself which creates an instance of the first during it's run. The same is done for AddressSanitizerModule. - Add new PM AddressSanitizer and AddressSanitizerModule. - Add legacy and new PM analyses for reading data needed to initialize ASan with. - Removed DominatorTree dependency from ASan since it was unused. - Move GlobalsMetadata and ShadowMapping out of anonymous namespace since the new PM analysis holds these 2 classes and will need to expose them. Differential Revision: https://reviews.llvm.org/D56470 Added: cfe/trunk/test/CodeGen/asan-new-pm.ll Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=353985&r1=353984&r2=353985&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Feb 13 14:22:48 2019 @@ -53,6 +53,7 @@ #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/InstCombine/InstCombine.h" #include "llvm/Transforms/Instrumentation.h" +#include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" #include "llvm/Transforms/Instrumentation/GCOVProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" @@ -243,15 +244,15 @@ static void addAddressSanitizerPasses(co bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts); PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover, UseAfterScope)); - PM.add(createAddressSanitizerModulePass(/*CompileKernel*/ false, Recover, - UseGlobalsGC, UseOdrIndicator)); + PM.add(createModuleAddressSanitizerLegacyPassPass( + /*CompileKernel*/ false, Recover, UseGlobalsGC, UseOdrIndicator)); } static void addKernelAddressSanitizerPasses(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { PM.add(createAddressSanitizerFunctionPass( /*CompileKernel*/ true, /*Recover*/ true, /*UseAfterScope*/ false)); - PM.add(createAddressSanitizerModulePass( + PM.add(createModuleAddressSanitizerLegacyPassPass( /*CompileKernel*/ true, /*Recover*/ true, /*UseGlobalsGC*/ true, /*UseOdrIndicator*/ false)); } @@ -917,6 +918,22 @@ static PassBuilder::OptimizationLevel ma } } +void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple, + const LangOptions &LangOpts, + const CodeGenOptions &CodeGenOpts) { + if (LangOpts.Sanitize.has(SanitizerKind::Address)) { +MPM.addPass(RequireAnalysisPass()); +bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address); +MPM.addPass(createModuleToFunctionPassAdaptor( +AddressSanitizerPass(/*CompileKernel=*/false, Recover, + CodeGenOpts.SanitizeAddressUseAfterScope))); +bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts); +MPM.addPass(ModuleAddressSanitizerPass( +/*CompileKernel=*/false, Recover, ModuleUseAfterScope, +CodeGenOpts.SanitizeAddressUseOdrIndicator)); + } +} + /// A clean version of `EmitAssembly` that uses the new pass manager. /// /// Not all features are currently supported in this system, but where @@ -1043,6 +1060,26 @@ void EmitAssemblyHelper::EmitAssemblyWit [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { FPM.addPass(ThreadSanitizerPass()); }); + if (LangOpts.Sanitize.has(SanitizerKind::Address)) { +PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) { + MPM.addPass( + RequireAnalysisPass()); +}); +bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address); +PB.registerOptimizerLastEPCallback( +[&](FunctionPassManager &FPM, +PassBuilder::OptimizationLevel Level) { + FPM.addPass(AddressSanitizerPass( + /*CompileKernel=*/false, Recover, + CodeGenOpts.SanitizeAddressUseAfterScope)); +}); +bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts); +PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) { + MPM.addPass(ModuleAddressSa
r353999 - Fix for asan bots
Author: leonardchan Date: Wed Feb 13 17:07:47 2019 New Revision: 353999 URL: http://llvm.org/viewvc/llvm-project?rev=353999&view=rev Log: Fix for asan bots Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=353999&r1=353998&r2=353999&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Feb 13 17:07:47 2019 @@ -1066,19 +1066,22 @@ void EmitAssemblyHelper::EmitAssemblyWit RequireAnalysisPass()); }); bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address); +bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope; PB.registerOptimizerLastEPCallback( -[&](FunctionPassManager &FPM, -PassBuilder::OptimizationLevel Level) { +[Recover, UseAfterScope](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { FPM.addPass(AddressSanitizerPass( - /*CompileKernel=*/false, Recover, - CodeGenOpts.SanitizeAddressUseAfterScope)); + /*CompileKernel=*/false, Recover, UseAfterScope)); }); bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts); -PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) { - MPM.addPass(ModuleAddressSanitizerPass( - /*CompileKernel=*/false, Recover, ModuleUseAfterScope, - CodeGenOpts.SanitizeAddressUseOdrIndicator)); -}); +bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator; +PB.registerPipelineStartEPCallback( +[Recover, ModuleUseAfterScope, + UseOdrIndicator](ModulePassManager &MPM) { + MPM.addPass(ModuleAddressSanitizerPass( + /*CompileKernel=*/false, Recover, ModuleUseAfterScope, + UseOdrIndicator)); +}); } if (Optional Options = getGCOVOptions(CodeGenOpts)) PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354431 - [NewPM] Add other sanitizers at O0
Author: leonardchan Date: Tue Feb 19 19:50:11 2019 New Revision: 354431 URL: http://llvm.org/viewvc/llvm-project?rev=354431&view=rev Log: [NewPM] Add other sanitizers at O0 This allows for MSan and TSan to be used without optimizations required. Differential Revision: https://reviews.llvm.org/D58424 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/Driver/msan.c cfe/trunk/test/Driver/tsan.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=354431&r1=354430&r2=354431&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Feb 19 19:50:11 2019 @@ -932,6 +932,14 @@ void addSanitizersAtO0(ModulePassManager /*CompileKernel=*/false, Recover, ModuleUseAfterScope, CodeGenOpts.SanitizeAddressUseOdrIndicator)); } + + if (LangOpts.Sanitize.has(SanitizerKind::Memory)) { +MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({}))); + } + + if (LangOpts.Sanitize.has(SanitizerKind::Thread)) { +MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); + } } /// A clean version of `EmitAssembly` that uses the new pass manager. Modified: cfe/trunk/test/Driver/msan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msan.c?rev=354431&r1=354430&r2=354431&view=diff == --- cfe/trunk/test/Driver/msan.c (original) +++ cfe/trunk/test/Driver/msan.c Tue Feb 19 19:50:11 2019 @@ -15,6 +15,18 @@ // Verify that -fsanitize=memory and -fsanitize=kernel-memory invoke MSan/KMSAN instrumentation. +// Also check that this works with the new pass manager with and without +// optimization +// RUN: %clang -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -O1 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -O2 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -O3 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN + +// RUN: %clang -fexperimental-new-pass-manager -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -fexperimental-new-pass-manager -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -fexperimental-new-pass-manager -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN +// RUN: %clang -fexperimental-new-pass-manager -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN + int foo(int *a) { return *a; } // CHECK-MSAN: __msan_init // CHECK-KMSAN: __msan_get_context_state Modified: cfe/trunk/test/Driver/tsan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/tsan.c?rev=354431&r1=354430&r2=354431&view=diff == --- cfe/trunk/test/Driver/tsan.c (original) +++ cfe/trunk/test/Driver/tsan.c Tue Feb 19 19:50:11 2019 @@ -5,5 +5,13 @@ // RUN: %clang -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // Verify that -fsanitize=thread invokes tsan instrumentation. +// Also check that this works with the new pass manager with and without +// optimization +// RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -O1 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s + int foo(int *a) { return *a; } // CHECK: __tsan_init ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354432 - Remove test on incompatible mpis target.
Author: leonardchan Date: Tue Feb 19 20:35:28 2019 New Revision: 354432 URL: http://llvm.org/viewvc/llvm-project?rev=354432&view=rev Log: Remove test on incompatible mpis target. Modified: cfe/trunk/test/Driver/msan.c Modified: cfe/trunk/test/Driver/msan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msan.c?rev=354432&r1=354431&r2=354432&view=diff == --- cfe/trunk/test/Driver/msan.c (original) +++ cfe/trunk/test/Driver/msan.c Tue Feb 19 20:35:28 2019 @@ -22,8 +22,6 @@ // RUN: %clang -O2 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -O3 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN -// RUN: %clang -fexperimental-new-pass-manager -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN -// RUN: %clang -fexperimental-new-pass-manager -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -fexperimental-new-pass-manager -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -fexperimental-new-pass-manager -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354435 - Limit new PM tests to X86 registered targets.
Author: leonardchan Date: Tue Feb 19 21:07:14 2019 New Revision: 354435 URL: http://llvm.org/viewvc/llvm-project?rev=354435&view=rev Log: Limit new PM tests to X86 registered targets. Modified: cfe/trunk/test/Driver/msan.c cfe/trunk/test/Driver/tsan.c Modified: cfe/trunk/test/Driver/msan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msan.c?rev=354435&r1=354434&r2=354435&view=diff == --- cfe/trunk/test/Driver/msan.c (original) +++ cfe/trunk/test/Driver/msan.c Tue Feb 19 21:07:14 2019 @@ -1,3 +1,5 @@ +// REQUIRES: x86-registered-target + // RUN: %clang -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -O1 -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -O2 -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN @@ -22,9 +24,6 @@ // RUN: %clang -O2 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN // RUN: %clang -O3 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN -// RUN: %clang -fexperimental-new-pass-manager -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN -// RUN: %clang -fexperimental-new-pass-manager -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN - int foo(int *a) { return *a; } // CHECK-MSAN: __msan_init // CHECK-KMSAN: __msan_get_context_state Modified: cfe/trunk/test/Driver/tsan.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/tsan.c?rev=354435&r1=354434&r2=354435&view=diff == --- cfe/trunk/test/Driver/tsan.c (original) +++ cfe/trunk/test/Driver/tsan.c Tue Feb 19 21:07:14 2019 @@ -1,3 +1,5 @@ +// REQUIRES: x86-registered-target + // RUN: %clang -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O1 -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s // RUN: %clang -O2 -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354621 - [Fixed Point Arithmetic] Fixed Point Comparisons
Author: leonardchan Date: Thu Feb 21 12:50:09 2019 New Revision: 354621 URL: http://llvm.org/viewvc/llvm-project?rev=354621&view=rev Log: [Fixed Point Arithmetic] Fixed Point Comparisons This patch implements fixed point comparisons with other fixed point types and integers. This also provides constant expression evaluation for them. Differential Revision: https://reviews.llvm.org/D57219 Added: cfe/trunk/test/Frontend/fixed_point_comparisons.c Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=354621&r1=354620&r2=354621&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Feb 21 12:50:09 2019 @@ -9144,6 +9144,22 @@ EvaluateComparisonBinaryOperator(EvalInf return Success(CCR::Equal, E); } + if (LHSTy->isFixedPointType() || RHSTy->isFixedPointType()) { +APFixedPoint LHSFX(Info.Ctx.getFixedPointSemantics(LHSTy)); +APFixedPoint RHSFX(Info.Ctx.getFixedPointSemantics(RHSTy)); + +bool LHSOK = EvaluateFixedPointOrInteger(E->getLHS(), LHSFX, Info); +if (!LHSOK && !Info.noteFailure()) + return false; +if (!EvaluateFixedPointOrInteger(E->getRHS(), RHSFX, Info) || !LHSOK) + return false; +if (LHSFX < RHSFX) + return Success(CCR::Less, E); +if (LHSFX > RHSFX) + return Success(CCR::Greater, E); +return Success(CCR::Equal, E); + } + if (LHSTy->isAnyComplexType() || RHSTy->isAnyComplexType()) { ComplexValue LHS, RHS; bool LHSOK; Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=354621&r1=354620&r2=354621&view=diff == --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Feb 21 12:50:09 2019 @@ -125,11 +125,19 @@ struct BinOpInfo { return true; } - /// Check if either operand is a fixed point type, in which case, this + /// Check if either operand is a fixed point type or integer type, with at + /// least one being a fixed point type. In any case, this /// operation did not follow usual arithmetic conversion and both operands may /// not be the same. bool isFixedPointBinOp() const { -return isa(E) && Ty->isFixedPointType(); +// We cannot simply check the result type since comparison operations return +// an int. +if (const auto *BinOp = dyn_cast(E)) { + QualType LHSType = BinOp->getLHS()->getType(); + QualType RHSType = BinOp->getRHS()->getType(); + return LHSType->isFixedPointType() || RHSType->isFixedPointType(); +} +return false; } }; @@ -3372,8 +3380,6 @@ Value *ScalarExprEmitter::EmitFixedPoint using llvm::ConstantInt; const auto *BinOp = cast(op.E); - assert((BinOp->getOpcode() == BO_Add || BinOp->getOpcode() == BO_Sub) && - "Expected operation to be addition or subtraction"); // The result is a fixed point type and at least one of the operands is fixed // point while the other is either fixed point or an int. This resulting type @@ -3421,17 +3427,30 @@ Value *ScalarExprEmitter::EmitFixedPoint } break; } - case BO_Mul: - case BO_Div: - case BO_Shl: - case BO_Shr: - case BO_Cmp: case BO_LT: +return CommonFixedSema.isSigned() ? Builder.CreateICmpSLT(FullLHS, FullRHS) + : Builder.CreateICmpULT(FullLHS, FullRHS); case BO_GT: +return CommonFixedSema.isSigned() ? Builder.CreateICmpSGT(FullLHS, FullRHS) + : Builder.CreateICmpUGT(FullLHS, FullRHS); case BO_LE: +return CommonFixedSema.isSigned() ? Builder.CreateICmpSLE(FullLHS, FullRHS) + : Builder.CreateICmpULE(FullLHS, FullRHS); case BO_GE: +return CommonFixedSema.isSigned() ? Builder.CreateICmpSGE(FullLHS, FullRHS) + : Builder.CreateICmpUGE(FullLHS, FullRHS); case BO_EQ: +// For equality operations, we assume any padding bits on unsigned types are +// zero'd out. They could be overwritten through non-saturating operations +// that cause overflow, but this leads to undefined behavior. +return Builder.CreateICmpEQ(FullLHS, FullRHS); case BO_NE: +return Builder.CreateICmpNE(FullLHS, FullRHS); + case BO_Mul: + case BO_Div: + case BO_Shl: + case BO_Shr: + case BO_Cmp: case BO_LAnd: case BO_LOr: case BO_MulAssign: @@ -3714,8 +3733,9 @@ Value *ScalarExprEmitter::EmitCompare(co Result = CGF.CGM.getCXXABI().EmitMemberPointerComparison( CGF, LHS, RHS, MPT, E->getOpcode() == BO_NE); } else if (!LHSTy->isAnyComplexType() && !RHSTy->isAnyComplexType())
r363277 - [clang][NewPM] Fix broken -O0 test from the AlwaysInliner
Author: leonardchan Date: Thu Jun 13 09:45:29 2019 New Revision: 363277 URL: http://llvm.org/viewvc/llvm-project?rev=363277&view=rev Log: [clang][NewPM] Fix broken -O0 test from the AlwaysInliner This contains the part of D62225 which prevents insertion of lifetime intrinsics when creating the AlwaysInliner. This fixes the following tests when the new PM is enabled by default: Clang :: CodeGen/aarch64-neon-across.c Clang :: CodeGen/aarch64-neon-fcvt-intrinsics.c Clang :: CodeGen/aarch64-neon-fma.c Clang :: CodeGen/aarch64-neon-perm.c Clang :: CodeGen/aarch64-neon-tbl.c Clang :: CodeGen/aarch64-poly128.c Clang :: CodeGen/aarch64-v8.2a-neon-intrinsics.c Clang :: CodeGen/arm-neon-fma.c Clang :: CodeGen/arm-neon-numeric-maxmin.c Clang :: CodeGen/arm-neon-vcvtX.c Clang :: CodeGen/avx-builtins.c Clang :: CodeGen/builtins-ppc-p9vector.c Clang :: CodeGen/builtins-ppc-vsx.c Clang :: CodeGen/lifetime.c Clang :: CodeGen/sse-builtins.c Clang :: CodeGen/sse2-builtins.c Differential Revision: https://reviews.llvm.org/D63153 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/lifetime.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363277&r1=363276&r2=363277&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 09:45:29 2019 @@ -,8 +,10 @@ void EmitAssemblyHelper::EmitAssemblyWit MPM.addPass(InstrProfiling(*Options, false)); // Build a minimal pipeline based on the semantics required by Clang, - // which is just that always inlining occurs. - MPM.addPass(AlwaysInlinerPass()); + // which is just that always inlining occurs. Further, disable generating + // lifetime intrinsics to avoid enabling further optimizations during + // code generation. + MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/false)); // At -O0 we directly run necessary sanitizer passes. if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) Modified: cfe/trunk/test/CodeGen/lifetime.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lifetime.c?rev=363277&r1=363276&r2=363277&view=diff == --- cfe/trunk/test/CodeGen/lifetime.c (original) +++ cfe/trunk/test/CodeGen/lifetime.c Thu Jun 13 09:45:29 2019 @@ -1,7 +1,8 @@ -// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0 +// RUN: %clang -S -emit-llvm -o - -O0 -fno-experimental-new-pass-manager %s | FileCheck %s -check-prefix=O0 // RUN: %clang -S -emit-llvm -o - -O1 -fno-experimental-new-pass-manager %s | FileCheck %s -check-prefix=O1 // RUN: %clang -S -emit-llvm -o - -O2 -fno-experimental-new-pass-manager %s | FileCheck %s -check-prefix=O2 // RUN: %clang -S -emit-llvm -o - -O3 -fno-experimental-new-pass-manager %s | FileCheck %s -check-prefix=O3 +// RUN: %clang -S -emit-llvm -o - -O0 -fexperimental-new-pass-manager %s | FileCheck %s -check-prefix=O0 extern void use(char *a); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r363278 - [clang][NewPM] Fix broken profile test
Author: leonardchan Date: Thu Jun 13 10:25:36 2019 New Revision: 363278 URL: http://llvm.org/viewvc/llvm-project?rev=363278&view=rev Log: [clang][NewPM] Fix broken profile test This contains the part of D62225 which fixes Profile/gcc-flag-compatibility.c by adding the pass that allows default profile generation to work under the new PM. It seems that ./default.profraw was not being generated with new PM enabled. Differential Revision: https://reviews.llvm.org/D63155 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/Profile/gcc-flag-compatibility.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363278&r1=363277&r2=363278&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 10:25:36 2019 @@ -60,6 +60,7 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" +#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" @@ -1216,6 +1217,11 @@ void EmitAssemblyHelper::EmitAssemblyWit if (CodeGenOpts.OptimizationLevel == 0) addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); + +if (CodeGenOpts.hasProfileIRInstr()) { + // This file is stored as the ProfileFile. + MPM.addPass(PGOInstrumentationGenCreateVar(PGOOpt->ProfileFile)); +} } // FIXME: We still use the legacy pass manager to do code generation. We Modified: cfe/trunk/test/Profile/gcc-flag-compatibility.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/gcc-flag-compatibility.c?rev=363278&r1=363277&r2=363278&view=diff == --- cfe/trunk/test/Profile/gcc-flag-compatibility.c (original) +++ cfe/trunk/test/Profile/gcc-flag-compatibility.c Thu Jun 13 10:25:36 2019 @@ -7,25 +7,29 @@ // -fprofile-use=Uses the profile file /default.profdata // -fprofile-use=/file Uses the profile file /file -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s // PROFILE-GEN: __llvm_profile_filename // Check that -fprofile-generate=/path/to generates /path/to/default.profraw -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00" // Check that -fprofile-use=some/path reads some/path/default.profdata // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-2 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-2 %s // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2} // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-3 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-3 %s // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2} int X = 0; ___
r363281 - [clang][NewPM] Fix split debug test
Author: leonardchan Date: Thu Jun 13 10:40:03 2019 New Revision: 363281 URL: http://llvm.org/viewvc/llvm-project?rev=363281&view=rev Log: [clang][NewPM] Fix split debug test This contains the part of D62225 which fixes CodeGen/split-debug-single-file.c by not placing .dwo sections when using -enable-split-dwarf=split. Differential Revision: https://reviews.llvm.org/D63168 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/split-debug-single-file.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363281&r1=363280&r2=363281&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 13 10:40:03 2019 @@ -1275,7 +1275,8 @@ void EmitAssemblyHelper::EmitAssemblyWit NeedCodeGen = true; CodeGenPasses.add( createTargetTransformInfoWrapperPass(getTargetIRAnalysis())); -if (!CodeGenOpts.SplitDwarfFile.empty()) { +if (!CodeGenOpts.SplitDwarfFile.empty() && +CodeGenOpts.getSplitDwarfMode() == CodeGenOptions::SplitFileFission) { DwoOS = openOutputFile(CodeGenOpts.SplitDwarfFile); if (!DwoOS) return; Modified: cfe/trunk/test/CodeGen/split-debug-single-file.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-single-file.c?rev=363281&r1=363280&r2=363281&view=diff == --- cfe/trunk/test/CodeGen/split-debug-single-file.c (original) +++ cfe/trunk/test/CodeGen/split-debug-single-file.c Thu Jun 13 10:40:03 2019 @@ -2,13 +2,19 @@ // Testing to ensure -enable-split-dwarf=single allows to place .dwo sections into regular output object. // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ -// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s +// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s -fno-experimental-new-pass-manager +// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ +// RUN: -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o %s -fexperimental-new-pass-manager // RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s // MODE-SINGLE: .dwo // Testing to ensure -enable-split-dwarf=split does not place .dwo sections into regular output object. // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ -// RUN: -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o %s +// RUN: -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o %s -fno-experimental-new-pass-manager +// RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \ +// RUN: -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o %s -fexperimental-new-pass-manager // RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s // MODE-SPLIT-NOT: .dwo ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r363287 - [clang][NewPM] Fix broken -O0 test from missing assumptions
Author: leonardchan Date: Thu Jun 13 11:18:40 2019 New Revision: 363287 URL: http://llvm.org/viewvc/llvm-project?rev=363287&view=rev Log: [clang][NewPM] Fix broken -O0 test from missing assumptions Add an AssumptionCache callback to the InlineFuntionInfo used for the AlwaysInlinerPass to match codegen of the AlwaysInlinerLegacyPass to generate llvm.assume. This fixes CodeGen/builtin-movdir.c when new PM is enabled by default. Differential Revision: https://reviews.llvm.org/D63170 Modified: cfe/trunk/test/CodeGen/builtin-movdir.c cfe/trunk/test/CodeGen/lto-newpm-pipeline.c Modified: cfe/trunk/test/CodeGen/builtin-movdir.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-movdir.c?rev=363287&r1=363286&r2=363287&view=diff == --- cfe/trunk/test/CodeGen/builtin-movdir.c (original) +++ cfe/trunk/test/CodeGen/builtin-movdir.c Thu Jun 13 11:18:40 2019 @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK -// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -fno-experimental-new-pass-manager -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -fexperimental-new-pass-manager -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86 --check-prefix=CHECK #include #include Modified: cfe/trunk/test/CodeGen/lto-newpm-pipeline.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lto-newpm-pipeline.c?rev=363287&r1=363286&r2=363287&view=diff == --- cfe/trunk/test/CodeGen/lto-newpm-pipeline.c (original) +++ cfe/trunk/test/CodeGen/lto-newpm-pipeline.c Thu Jun 13 11:18:40 2019 @@ -27,6 +27,7 @@ // CHECK-FULL-O0: Starting llvm::Module pass manager run. // CHECK-FULL-O0: Running pass: AlwaysInlinerPass +// CHECK-FULL-O0-NEXT: Running analysis: InnerAnalysisManagerProxy // CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass @@ -34,6 +35,7 @@ // CHECK-THIN-O0: Starting llvm::Module pass manager run. // CHECK-THIN-O0: Running pass: AlwaysInlinerPass +// CHECK-THIN-O0-NEXT: Running analysis: InnerAnalysisManagerProxy // CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r363846 - [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM
Author: leonardchan Date: Wed Jun 19 10:41:30 2019 New Revision: 363846 URL: http://llvm.org/viewvc/llvm-project?rev=363846&view=rev Log: [clang][NewPM] Fixing remaining -O0 tests that are broken under new PM - CodeGen/flatten.c will fail under new PM becausec the new PM AlwaysInliner seems to intentionally inline functions but not call sites marked with alwaysinline (D23299) - Tests that check remarks happen to check them for the inliner which is not turned on at O0. These tests just check that remarks work, but we can make separate tests for the new PM with -O1 so we can turn on the inliner and check the remarks with minimal changes. Differential Revision: https://reviews.llvm.org/D62225 Added: cfe/trunk/test/Frontend/optimization-remark-new-pm.c cfe/trunk/test/Frontend/optimization-remark-with-hotness-new-pm.c Modified: cfe/trunk/test/CMakeLists.txt cfe/trunk/test/CodeGen/flatten.c cfe/trunk/test/CodeGenCXX/flatten.cpp cfe/trunk/test/Frontend/optimization-remark-line-directive.c cfe/trunk/test/Frontend/optimization-remark-with-hotness.c cfe/trunk/test/Frontend/optimization-remark.c cfe/trunk/test/lit.cfg.py cfe/trunk/test/lit.site.cfg.py.in Modified: cfe/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=363846&r1=363845&r2=363846&view=diff == --- cfe/trunk/test/CMakeLists.txt (original) +++ cfe/trunk/test/CMakeLists.txt Wed Jun 19 10:41:30 2019 @@ -23,6 +23,7 @@ llvm_canonicalize_cmake_booleans( CLANG_ENABLE_ARCMT CLANG_ENABLE_STATIC_ANALYZER ENABLE_BACKTRACES + ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER HAVE_LIBZ LLVM_ENABLE_PER_TARGET_RUNTIME_DIR LLVM_ENABLE_PLUGINS) Modified: cfe/trunk/test/CodeGen/flatten.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/flatten.c?rev=363846&r1=363845&r2=363846&view=diff == --- cfe/trunk/test/CodeGen/flatten.c (original) +++ cfe/trunk/test/CodeGen/flatten.c Wed Jun 19 10:41:30 2019 @@ -1,3 +1,9 @@ +// UNSUPPORTED: experimental-new-pass-manager +// Currently, different code seems to be intentionally generated under the new +// PM since we alwaysinline functions and not callsites under new PM. +// Under new PM, f() will not be inlined from g() since f is not marked as +// alwaysinline. + // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s void f(void) {} Modified: cfe/trunk/test/CodeGenCXX/flatten.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/flatten.cpp?rev=363846&r1=363845&r2=363846&view=diff == --- cfe/trunk/test/CodeGenCXX/flatten.cpp (original) +++ cfe/trunk/test/CodeGenCXX/flatten.cpp Wed Jun 19 10:41:30 2019 @@ -1,3 +1,7 @@ +// UNSUPPORTED: experimental-new-pass-manager +// See the comment for CodeGen/flatten.c on why this is unsupported with the new +// PM. + // RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | FileCheck %s void f(void) {} Modified: cfe/trunk/test/Frontend/optimization-remark-line-directive.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-line-directive.c?rev=363846&r1=363845&r2=363846&view=diff == --- cfe/trunk/test/Frontend/optimization-remark-line-directive.c (original) +++ cfe/trunk/test/Frontend/optimization-remark-line-directive.c Wed Jun 19 10:41:30 2019 @@ -2,7 +2,11 @@ // directives. We cannot map #line directives back to // a SourceLocation. -// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify +// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify -fno-experimental-new-pass-manager + +// The new PM inliner is not added to the default pipeline at O0, so we add +// some optimizations to trigger it. +// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify int foo(int x, int y) __attribute__((always_inline)); int foo(int x, int y) { return x + y; } Added: cfe/trunk/test/Frontend/optimization-remark-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-new-pm.c?rev=363846&view=auto == --- cfe/trunk/test/Frontend/optimization-remark-new-pm.c (added) +++ cfe/trunk/test/Frontend/optimization-remark-new-pm.c Wed Jun 19 10:41:30 2019 @@ -0,0 +1,20 @@ +// Verify that remarks for the inliner appear. The remarks under the new PM will +// be slightly different than those emitted by the legacy PM. The new PM inliner +// also doesnot appear to be added
r363969 - [clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline
Author: leonardchan Date: Thu Jun 20 12:35:25 2019 New Revision: 363969 URL: http://llvm.org/viewvc/llvm-project?rev=363969&view=rev Log: [clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline This fixes CodeGen/x86_64-instrument-functions.c when running under the new pass manager. The pass should go before any other pass to prevent `__cyg_profile_func_enter/exit()` from not being emitted by inlined functions. Differential Revision: https://reviews.llvm.org/D63577 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363969&r1=363968&r2=363969&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 20 12:35:25 2019 @@ -67,6 +67,7 @@ #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/CanonicalizeAliases.h" +#include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Transforms/Utils/NameAnonGlobals.h" #include "llvm/Transforms/Utils/SymbolRewriter.h" #include @@ -1131,6 +1132,11 @@ void EmitAssemblyHelper::EmitAssemblyWit // configure the pipeline. PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts); + PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) { +MPM.addPass(createModuleToFunctionPassAdaptor( +EntryExitInstrumenterPass(/*PostInlining=*/false))); + }); + // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out Modified: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-instrument-functions.c?rev=363969&r1=363968&r2=363969&view=diff == --- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c (original) +++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Thu Jun 20 12:35:25 2019 @@ -1,6 +1,9 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s + +// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s // It's not so nice having asm tests in Clang, but we need to check that we set // up the pipeline correctly in order to have the instrumentation inserted. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r363971 - [clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs
Author: leonardchan Date: Thu Jun 20 12:44:51 2019 New Revision: 363971 URL: http://llvm.org/viewvc/llvm-project?rev=363971&view=rev Log: [clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs This fixes CodeGen/available-externally-suppress.c when the new pass manager is turned on by default. available_externally was not emitted during -O2 -flto runs when it should still be retained for link time inlining purposes. This can be fixed by checking that we aren't LTOPrelinking when adding the EliminateAvailableExternallyPass. Differential Revision: https://reviews.llvm.org/D63580 Modified: cfe/trunk/test/CodeGen/available-externally-suppress.c Modified: cfe/trunk/test/CodeGen/available-externally-suppress.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/available-externally-suppress.c?rev=363971&r1=363970&r2=363971&view=diff == --- cfe/trunk/test/CodeGen/available-externally-suppress.c (original) +++ cfe/trunk/test/CodeGen/available-externally-suppress.c Thu Jun 20 12:44:51 2019 @@ -1,6 +1,9 @@ -// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -// RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -// RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO +// RUN: %clang_cc1 -fexperimental-new-pass-manager -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// RUN: %clang_cc1 -fexperimental-new-pass-manager -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -O2 -fno-inline -emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO // Ensure that we don't emit available_externally functions at -O0. // Also should not emit them at -O2, unless -flto is present in which case ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r365838 - [NewPM] Port Sancov
Author: leonardchan Date: Thu Jul 11 15:35:40 2019 New Revision: 365838 URL: http://llvm.org/viewvc/llvm-project?rev=365838&view=rev Log: [NewPM] Port Sancov This patch contains a port of SanitizerCoverage to the new pass manager. This one's a bit hefty. Changes: - Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over functions and ModuleSanitizerCoverage for passing over modules. - ModuleSanitizerCoverage exists for adding 2 module level calls to initialization functions but only if there's a function that was instrumented by sancov. - Added legacy and new PM wrapper classes that own instances of the 2 new classes. - Update llvm tests and add clang tests. Differential Revision: https://reviews.llvm.org/D62888 Added: cfe/trunk/test/CodeGen/sancov-new-pm.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=365838&r1=365837&r2=365838&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 11 15:35:40 2019 @@ -60,6 +60,7 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" +#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" @@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const PM.add(createBoundsCheckingLegacyPass()); } -static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM) { - const PassManagerBuilderWrapper &BuilderWrapper = - static_cast(Builder); - const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); +static SanitizerCoverageOptions +getSancovOptsFromCGOpts(const CodeGenOptions &CGOpts) { SanitizerCoverageOptions Opts; Opts.CoverageType = static_cast(CGOpts.SanitizeCoverageType); @@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters; Opts.PCTable = CGOpts.SanitizeCoveragePCTable; Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth; - PM.add(createSanitizerCoverageModulePass(Opts)); + return Opts; +} + +static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, + legacy::PassManagerBase &PM) { + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); + auto Opts = getSancovOptsFromCGOpts(CGOpts); + PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts)); + PM.add(createSanitizerCoverageLegacyPassPass(Opts)); } // Check if ASan should use GC-friendly instrumentation for globals. @@ -1135,6 +1143,21 @@ void EmitAssemblyHelper::EmitAssemblyWit EntryExitInstrumenterPass(/*PostInlining=*/false))); }); + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { +auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); +PB.registerPipelineStartEPCallback( +[SancovOpts](ModulePassManager &MPM) { + MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); +}); +PB.registerOptimizerLastEPCallback( +[SancovOpts](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { + FPM.addPass(SanitizerCoveragePass(SancovOpts)); +}); + } + // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1219,8 +1242,18 @@ void EmitAssemblyHelper::EmitAssemblyWit } } -if (CodeGenOpts.OptimizationLevel == 0) +if (CodeGenOpts.OptimizationLevel == 0) { + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { +auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); +MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); +MPM.addPass(createModuleToFunctionPassAdaptor( +SanitizerCoveragePass(SancovOpts))); + } + addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); +} } // FIXME: We still use the legacy pass manager to do code generation. We Added: cfe/trunk/test/CodeGen/sancov-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=365838&view=auto ==
r366153 - Revert "[NewPM] Port Sancov"
Author: leonardchan Date: Mon Jul 15 16:18:31 2019 New Revision: 366153 URL: http://llvm.org/viewvc/llvm-project?rev=366153&view=rev Log: Revert "[NewPM] Port Sancov" This reverts commit 5652f35817f07b16f8b3856d594cc42f4d7ee29c. Removed: cfe/trunk/test/CodeGen/sancov-new-pm.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366153&r1=366152&r2=366153&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jul 15 16:18:31 2019 @@ -60,7 +60,6 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" -#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" @@ -196,8 +195,11 @@ static void addBoundsCheckingPass(const PM.add(createBoundsCheckingLegacyPass()); } -static SanitizerCoverageOptions -getSancovOptsFromCGOpts(const CodeGenOptions &CGOpts) { +static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, + legacy::PassManagerBase &PM) { + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); SanitizerCoverageOptions Opts; Opts.CoverageType = static_cast(CGOpts.SanitizeCoverageType); @@ -213,17 +215,7 @@ getSancovOptsFromCGOpts(const CodeGenOpt Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters; Opts.PCTable = CGOpts.SanitizeCoveragePCTable; Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth; - return Opts; -} - -static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM) { - const PassManagerBuilderWrapper &BuilderWrapper = - static_cast(Builder); - const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); - auto Opts = getSancovOptsFromCGOpts(CGOpts); - PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts)); - PM.add(createSanitizerCoverageLegacyPassPass(Opts)); + PM.add(createSanitizerCoverageModulePass(Opts)); } // Check if ASan should use GC-friendly instrumentation for globals. @@ -1143,21 +1135,6 @@ void EmitAssemblyHelper::EmitAssemblyWit EntryExitInstrumenterPass(/*PostInlining=*/false))); }); - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); -PB.registerPipelineStartEPCallback( -[SancovOpts](ModulePassManager &MPM) { - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); -}); -PB.registerOptimizerLastEPCallback( -[SancovOpts](FunctionPassManager &FPM, - PassBuilder::OptimizationLevel Level) { - FPM.addPass(SanitizerCoveragePass(SancovOpts)); -}); - } - // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1242,18 +1219,8 @@ void EmitAssemblyHelper::EmitAssemblyWit } } -if (CodeGenOpts.OptimizationLevel == 0) { - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); -MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); -MPM.addPass(createModuleToFunctionPassAdaptor( -SanitizerCoveragePass(SancovOpts))); - } - +if (CodeGenOpts.OptimizationLevel == 0) addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); -} } // FIXME: We still use the legacy pass manager to do code generation. We Removed: cfe/trunk/test/CodeGen/sancov-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=366152&view=auto == --- cfe/trunk/test/CodeGen/sancov-new-pm.c (original) +++ cfe/trunk/test/CodeGen/sancov-new-pm.c (removed) @@ -1,41 +0,0 @@ -// Test that SanitizerCoverage works under the new pass manager. -// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0 -// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,C
r367053 - Reland the "[NewPM] Port Sancov" patch from rL365838. No functional
Author: leonardchan Date: Thu Jul 25 13:53:15 2019 New Revision: 367053 URL: http://llvm.org/viewvc/llvm-project?rev=367053&view=rev Log: Reland the "[NewPM] Port Sancov" patch from rL365838. No functional changes were made to the patch since then. [NewPM] Port Sancov This patch contains a port of SanitizerCoverage to the new pass manager. This one's a bit hefty. Changes: - Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over functions and ModuleSanitizerCoverage for passing over modules. - ModuleSanitizerCoverage exists for adding 2 module level calls to initialization functions but only if there's a function that was instrumented by sancov. - Added legacy and new PM wrapper classes that own instances of the 2 new classes. - Update llvm tests and add clang tests. Added: cfe/trunk/test/CodeGen/sancov-new-pm.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=367053&r1=367052&r2=367053&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 25 13:53:15 2019 @@ -60,6 +60,7 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" +#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" @@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const PM.add(createBoundsCheckingLegacyPass()); } -static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, - legacy::PassManagerBase &PM) { - const PassManagerBuilderWrapper &BuilderWrapper = - static_cast(Builder); - const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); +static SanitizerCoverageOptions +getSancovOptsFromCGOpts(const CodeGenOptions &CGOpts) { SanitizerCoverageOptions Opts; Opts.CoverageType = static_cast(CGOpts.SanitizeCoverageType); @@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters; Opts.PCTable = CGOpts.SanitizeCoveragePCTable; Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth; - PM.add(createSanitizerCoverageModulePass(Opts)); + return Opts; +} + +static void addSanitizerCoveragePass(const PassManagerBuilder &Builder, + legacy::PassManagerBase &PM) { + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); + auto Opts = getSancovOptsFromCGOpts(CGOpts); + PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts)); + PM.add(createSanitizerCoverageLegacyPassPass(Opts)); } // Check if ASan should use GC-friendly instrumentation for globals. @@ -1128,6 +1136,21 @@ void EmitAssemblyHelper::EmitAssemblyWit EntryExitInstrumenterPass(/*PostInlining=*/false))); }); + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { +auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); +PB.registerPipelineStartEPCallback( +[SancovOpts](ModulePassManager &MPM) { + MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); +}); +PB.registerOptimizerLastEPCallback( +[SancovOpts](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { + FPM.addPass(SanitizerCoveragePass(SancovOpts)); +}); + } + // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1205,8 +1228,18 @@ void EmitAssemblyHelper::EmitAssemblyWit /*CompileKernel=*/true, /*Recover=*/true)); } -if (CodeGenOpts.OptimizationLevel == 0) +if (CodeGenOpts.OptimizationLevel == 0) { + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { +auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); +MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); +MPM.addPass(createModuleToFunctionPassAdaptor( +SanitizerCoveragePass(SancovOpts))); + } + addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); +} } // FIXME: We still use the legacy pass manager to do code generation. We Added: cfe/trunk/test/CodeGen/sancov-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen
r367157 - [NewPM] Run avx*-builtins.c tests under the new pass manager only
Author: leonardchan Date: Fri Jul 26 14:19:37 2019 New Revision: 367157 URL: http://llvm.org/viewvc/llvm-project?rev=367157&view=rev Log: [NewPM] Run avx*-builtins.c tests under the new pass manager only This patch changes the following tests to run under the new pass manager only: ``` Clang :: CodeGen/avx512-reduceMinMaxIntrin.c (1 of 4) Clang :: CodeGen/avx512vl-builtins.c (2 of 4) Clang :: CodeGen/avx512vlbw-builtins.c (3 of 4) Clang :: CodeGen/avx512f-builtins.c (4 of 4) ``` The new PM added extra bitcasts that weren't checked before. For reduceMinMaxIntrin.c, the issue was mostly the alloca's being in a different order. Other changes involved extra bitcasts, and differently ordered loads and stores, but the logic should still be the same. Differential revision: https://reviews.llvm.org/D65110 Modified: cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c Modified: cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c?rev=367157&r1=367156&r2=367157&view=diff == --- cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c (original) +++ cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c Fri Jul 26 14:19:37 2019 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s +// RUN: %clang_cc1 -fexperimental-new-pass-manager -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s #include @@ -27,10 +27,10 @@ // CHECK-NEXT:store <8 x i64> [[SHUFFLE_I]], <8 x i64>* [[__T1_I]], align 64 // CHECK-NEXT:[[TMP3:%.*]] = load <8 x i64>, <8 x i64>* [[__V_ADDR_I]], align 64 // CHECK-NEXT:[[TMP4:%.*]] = load <8 x i64>, <8 x i64>* [[__T1_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP3]], <8 x i64>* [[__A_ADDR_I_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP4]], <8 x i64>* [[__B_ADDR_I_I]], align 64 -// CHECK-NEXT:[[TMP5:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I_I]], align 64 -// CHECK-NEXT:[[TMP6:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP3]], <8 x i64>* [[__A_ADDR_I7_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP4]], <8 x i64>* [[__B_ADDR_I8_I]], align 64 +// CHECK-NEXT:[[TMP5:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I7_I]], align 64 +// CHECK-NEXT:[[TMP6:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I8_I]], align 64 // CHECK-NEXT:[[TMP7:%.*]] = icmp sgt <8 x i64> [[TMP5]], [[TMP6]] // CHECK-NEXT:[[TMP8:%.*]] = select <8 x i1> [[TMP7]], <8 x i64> [[TMP5]], <8 x i64> [[TMP6]] // CHECK-NEXT:store <8 x i64> [[TMP8]], <8 x i64>* [[__T2_I]], align 64 @@ -40,10 +40,10 @@ // CHECK-NEXT:store <8 x i64> [[SHUFFLE1_I]], <8 x i64>* [[__T3_I]], align 64 // CHECK-NEXT:[[TMP11:%.*]] = load <8 x i64>, <8 x i64>* [[__T2_I]], align 64 // CHECK-NEXT:[[TMP12:%.*]] = load <8 x i64>, <8 x i64>* [[__T3_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP11]], <8 x i64>* [[__A_ADDR_I7_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP12]], <8 x i64>* [[__B_ADDR_I8_I]], align 64 -// CHECK-NEXT:[[TMP13:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I7_I]], align 64 -// CHECK-NEXT:[[TMP14:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I8_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP11]], <8 x i64>* [[__A_ADDR_I5_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP12]], <8 x i64>* [[__B_ADDR_I6_I]], align 64 +// CHECK-NEXT:[[TMP13:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I5_I]], align 64 +// CHECK-NEXT:[[TMP14:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I6_I]], align 64 // CHECK-NEXT:[[TMP15:%.*]] = icmp sgt <8 x i64> [[TMP13]], [[TMP14]] // CHECK-NEXT:[[TMP16:%.*]] = select <8 x i1> [[TMP15]], <8 x i64> [[TMP13]], <8 x i64> [[TMP14]] // CHECK-NEXT:store <8 x i64> [[TMP16]], <8 x i64>* [[__T4_I]], align 64 @@ -53,10 +53,10 @@ // CHECK-NEXT:store <8 x i64> [[SHUFFLE3_I]], <8 x i64>* [[__T5_I]], align 64 // CHECK-NEXT:[[TMP19:%.*]] = load <8 x i64>, <8 x i64>* [[__T4_I]], align 64 // CHECK-NEXT:[[TMP20:%.*]] = load <8 x i64>, <8 x i64>* [[__T5_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP19]], <8 x i64>* [[__A_ADDR_I5_I]], align 64 -// CHECK-NEXT:store <8 x i64> [[TMP20]], <8 x i64>* [[__B_ADDR_I6_I]], align 64 -// CHECK-NEXT:[[TMP21:%.*]] = load <8 x i64>, <8 x i64>* [[__A_ADDR_I5_I]], align 64 -// CHECK-NEXT:[[TMP22:%.*]] = load <8 x i64>, <8 x i64>* [[__B_ADDR_I6_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP19]], <8 x i64>* [[__A_ADDR_I_I]], align 64 +// CHECK-NEXT:store <8 x i64> [[TMP
Re: r369281 - Implement P1668R1
Not sure if this was caught by upstream bots already, but we're seeing a failing test ob our x64 bots: ``` FAIL: Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp (9574 of 15387) TEST 'Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp' FAILED Script: -- : 'RUN: at line 1'; /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 -internal-isystem /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp -fcxx-exceptions : 'RUN: at line 2'; /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 -internal-isystem /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include -nostdsysteminc -std=c++2a -verify -fsyntax-only -fblocks /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp -fcxx-exceptions : 'RUN: at line 3'; /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 -internal-isystem /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp -fcxx-exceptions : 'RUN: at line 4'; /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 -internal-isystem /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include -nostdsysteminc -std=c++14 -verify -fsyntax-only -fblocks /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp -DCPP14_AND_EARLIER -fcxx-exceptions -- Exit Code: 1 Command Output (stderr): -- error: 'error' diagnostics expected but not seen: File /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Line 26 (directive at /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp:28): use of this statement in a constexpr function is a C++2a extension error: 'warning' diagnostics seen but not expected: File /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Line 26: use of this statement in a constexpr function is a C++2a extension 2 errors generated. -- Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Testing Time: 79.76s Failing Tests (1): Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp ``` Could you look into this? Thanks. On Mon, Aug 19, 2019 at 10:39 AM Erich Keane via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: erichkeane > Date: Mon Aug 19 10:39:59 2019 > New Revision: 369281 > > URL: http://llvm.org/viewvc/llvm-project?rev=369281&view=rev > Log: > Implement P1668R1 > > Allow inline assembly statements in unexecuted branches of constexpr > functions. > > Modified: > cfe/trunk/lib/Frontend/InitPreprocessor.cpp > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp > cfe/trunk/test/Lexer/cxx-features.cpp > cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > > Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=369281&r1=369280&r2=369281&view=diff > > == > --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) > +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Aug 19 10:39:59 2019 > @@ -480,6 +480,7 @@ static void InitializeCPlusPlusFeatureTe > Builder.defineMacro("__cpp_user_defined_literals", "200809L"); > Builder.defineMacro("__cpp_lambdas", "200907L"); > Builder.defineMacro("__cpp_constexpr", > +LangOpts.CPlusPlus2a ? "201907L" : > LangOpts.CPlusPlus17 ? "201603L" : > LangOpts.CPlusPlus14 ? "201304L" : "200704"); > Builder.defineMacro("__cpp_range_based_for", > > Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=369281&r1=369280&r2=369281&view=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 19 10:39:59 2019 > @@ -1995,6 +1995,9 @@ CheckConstexprFunctionStmt(Sema &SemaRef > return false; > return true; > > + case Stmt::GCCAsmStmtClass: > + case Stmt::MSAsmStmtClass: > +// C++2a allows inline assembly statements. >case Stmt::CXXTryStmtClass: > if (Cxx2aLoc.isInvalid()) >Cxx2aLoc = S->getBeginLoc(); > > Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp?rev=369281&r1=369280&r2=369281&view=diff > > == > --- cfe/trunk/t
Re: r369281 - Implement P1668R1
👍 Thanks On Mon, Aug 19, 2019 at 11:34 AM Keane, Erich wrote: > Yeah, sorry about that. I fixed it in 369284. > > > > *From:* Leonard Chan [mailto:leonardc...@google.com] > *Sent:* Monday, August 19, 2019 11:33 AM > *To:* Keane, Erich > *Cc:* cfe-commits cfe > *Subject:* Re: r369281 - Implement P1668R1 > > > > Not sure if this was caught by upstream bots already, but we're seeing a > failing test ob our x64 bots: > > > > ``` > > FAIL: Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp (9574 of 15387) > TEST 'Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp' > FAILED > Script: > -- > : 'RUN: at line 1'; > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 > -internal-isystem > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include > -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > -fcxx-exceptions > : 'RUN: at line 2'; > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 > -internal-isystem > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include > -nostdsysteminc -std=c++2a -verify -fsyntax-only -fblocks > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > -fcxx-exceptions > : 'RUN: at line 3'; > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 > -internal-isystem > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include > -nostdsysteminc -std=c++1z -verify -fsyntax-only -fblocks > -fdelayed-template-parsing > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > -fcxx-exceptions > : 'RUN: at line 4'; > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/bin/clang -cc1 > -internal-isystem > /b/s/w/ir/k/recipe_cleanup/clangAGxiPQ/llvm_build_dir/lib/clang/10.0.0/include > -nostdsysteminc -std=c++14 -verify -fsyntax-only -fblocks > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > -DCPP14_AND_EARLIER -fcxx-exceptions > -- > Exit Code: 1 > > Command Output (stderr): > -- > error: 'error' diagnostics expected but not seen: > File > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > Line 26 (directive at > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp:28): > use of this statement in a constexpr function is a C++2a extension > error: 'warning' diagnostics seen but not expected: > File > /b/s/w/ir/k/llvm-project/clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > Line 26: use of this statement in a constexpr function is a C++2a extension > 2 errors generated. > > -- > > > Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. > Testing Time: 79.76s > > Failing Tests (1): > Clang :: SemaCXX/cxx1z-constexpr-lambdas.cpp > > ``` > > > > Could you look into this? Thanks. > > > > On Mon, Aug 19, 2019 at 10:39 AM Erich Keane via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > Author: erichkeane > Date: Mon Aug 19 10:39:59 2019 > New Revision: 369281 > > URL: http://llvm.org/viewvc/llvm-project?rev=369281&view=rev > Log: > Implement P1668R1 > > Allow inline assembly statements in unexecuted branches of constexpr > functions. > > Modified: > cfe/trunk/lib/Frontend/InitPreprocessor.cpp > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp > cfe/trunk/test/Lexer/cxx-features.cpp > cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > > Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=369281&r1=369280&r2=369281&view=diff > > == > --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) > +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Aug 19 10:39:59 2019 > @@ -480,6 +480,7 @@ static void InitializeCPlusPlusFeatureTe > Builder.defineMacro("__cpp_user_defined_literals", "200809L"); > Builder.defineMacro("__cpp_lambdas", "200907L"); > Builder.defineMacro("__cpp_constexpr", > +LangOpts.CPlusPlus2a ? "201907L" : > LangOpts.CPlusPlus17 ? "201603L" : > LangOpts.CPlusPlus14 ? "201304L" : "200704"); > Builder.defineMacro("__cpp_range_based_for", > > Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=369281&r1=369280&r2=369281&view=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Aug 19 10:39:59 2019 > @@ -1995,6 +1995,9 @@ CheckConstexprFunctionStmt(Sema &SemaRef > return false; > return true; > > + case Stmt::GCCAsmStmtClass: > + case Stmt::MSAsmStmtClass: > +
r364066 - [clang][NewPM] Add -fno-experimental-new-pass-manager to tests
Author: leonardchan Date: Fri Jun 21 09:03:06 2019 New Revision: 364066 URL: http://llvm.org/viewvc/llvm-project?rev=364066&view=rev Log: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests As per the discussion on D58375, we disable test that have optimizations under the new PM. This patch adds -fno-experimental-new-pass-manager to RUNS that: - Already run with optimizations (-O1 or higher) that were missed in D58375. - Explicitly test new PM behavior along side some new PM RUNS, but are missing this flag if new PM is enabled by default. - Specify -O without the number. Based on getOptimizationLevel(), it seems the default is 2, and the IR appears to be the same when changed to -O2, so update the test to explicitly say -O2 and provide -fno-experimental-new-pass-manager`. Differential Revision: https://reviews.llvm.org/D63156 Modified: cfe/trunk/test/CodeGen/aggregate-assign-call.c cfe/trunk/test/CodeGen/arm_acle.c cfe/trunk/test/CodeGen/cspgo-instrumentation.c cfe/trunk/test/CodeGen/cspgo-instrumentation_lto.c cfe/trunk/test/CodeGen/cspgo-instrumentation_thinlto.c cfe/trunk/test/CodeGen/pgo-instrumentation.c cfe/trunk/test/CodeGen/thinlto-debug-pm.c cfe/trunk/test/CodeGenCXX/auto-var-init.cpp cfe/trunk/test/CodeGenCXX/conditional-temporaries.cpp cfe/trunk/test/CodeGenCXX/member-function-pointer-calls.cpp cfe/trunk/test/CodeGenObjC/os_log.m cfe/trunk/test/CodeGenObjCXX/os_log.mm cfe/trunk/test/Misc/pr32207.c Modified: cfe/trunk/test/CodeGen/aggregate-assign-call.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aggregate-assign-call.c?rev=364066&r1=364065&r2=364066&view=diff == --- cfe/trunk/test/CodeGen/aggregate-assign-call.c (original) +++ cfe/trunk/test/CodeGen/aggregate-assign-call.c Fri Jun 21 09:03:06 2019 @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=O1 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=O1,O1-LEGACY +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=O1,O1-NEWPM // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=O0 // // Ensure that we place appropriate lifetime markers around indirectly returned @@ -50,34 +51,32 @@ struct S baz(int i, volatile int *j) { struct S r; // O1: %[[TMP1_ALLOCA:[^ ]+]] = alloca %struct.S // O1: %[[TMP2_ALLOCA:[^ ]+]] = alloca %struct.S - // O1: br label %[[DO_BODY:.+]] do { -// O1: [[DO_BODY]]: // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8* -// O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]]) -// O1: br i1 {{[^,]+}}, label %[[IF_THEN:[^,]+]], label %[[IF_END:[^,]+]] +// O1-LEGACY: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]]) +// O1-NEWPM: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull %[[P]]) // -// O1: [[IF_THEN]]: -// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8* -// O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]]) -// O1: br label %[[DO_END:.*]] +// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8* +// O1-LEGACY: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]]) +// O1-NEWPM: %[[TMP3:.*]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8* +// O1-NEWPM: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull %[[P]]) // -// O1: [[IF_END]]: -// O1: call void @foo_int(%struct.S* sret %[[TMP1_ALLOCA]], +// O1-LEGACY: call void @foo_int(%struct.S* sret %[[TMP1_ALLOCA]], +// O1-NEWPM: call void @foo_int(%struct.S* nonnull sret %[[TMP1_ALLOCA]], // O1: call void @llvm.memcpy -// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8* -// O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]]) -// O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8* -// O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]]) -// O1: call void @foo_int(%struct.S* sret %[[TMP2_ALLOCA]], +// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8* +// O1-LEGACY: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]]) +// O1-NEWPM: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull %[[P]]) +// O1-LEGACY: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8* +// O1-LEGACY: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]]) +// O1-NEWPM: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull %[[TMP3]]) +// O1-LEGACY: call void @foo_int(%struct.S* sret %[[TMP2_ALLOCA]], +// O1-NEWPM: call void @foo_int(%struct.S* nonnull sret %[[TMP2_ALLOCA]], // O1: call void @llvm.m
r364201 - [clang][NewPM] Remove exception handling before loading pgo sample profile data
Author: leonardchan Date: Mon Jun 24 09:44:27 2019 New Revision: 364201 URL: http://llvm.org/viewvc/llvm-project?rev=364201&view=rev Log: [clang][NewPM] Remove exception handling before loading pgo sample profile data This patch ensures that SimplifyCFGPass comes before SampleProfileLoaderPass on PGO runs in the new PM and fixes clang/test/CodeGen/pgo-sample.c. Differential Revision: https://reviews.llvm.org/D63626 Modified: cfe/trunk/test/CodeGen/pgo-sample.c Modified: cfe/trunk/test/CodeGen/pgo-sample.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=364201&r1=364200&r2=364201&view=diff == --- cfe/trunk/test/CodeGen/pgo-sample.c (original) +++ cfe/trunk/test/CodeGen/pgo-sample.c Mon Jun 24 09:44:27 2019 @@ -1,6 +1,13 @@ // Test if PGO sample use passes are invoked. // // Ensure Pass PGOInstrumentationGenPass is invoked. -// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -// CHECK: Remove unused exception handling info -// CHECK: Sample profile pass +// RUN: %clang_cc1 -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=LEGACY +// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=NEWPM + +// LEGACY: Remove unused exception handling info +// LEGACY: Sample profile pass + +// NEWPM: SimplifyCFGPass +// NEWPM: SampleProfileLoaderPass + +int func(int a) { return a; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r364202 - [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM
Author: leonardchan Date: Mon Jun 24 09:49:18 2019 New Revision: 364202 URL: http://llvm.org/viewvc/llvm-project?rev=364202&view=rev Log: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM For CodeGenOpenCL/convergent.cl, the new PM produced a slightly different for loop, but this still checks for no loop unrolling as intended. This is committed separately from D63174. Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/convergent.cl?rev=364202&r1=364201&r2=364202&view=diff == --- cfe/trunk/test/CodeGenOpenCL/convergent.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/convergent.cl Mon Jun 24 09:49:18 2019 @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s +// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY +// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - -fexperimental-new-pass-manager | opt -instnamer -S | FileCheck -enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM // This is initially assumed convergent, but can be deduced to not require it. @@ -117,7 +118,12 @@ void test_unroll() { // CHECK: [[for_body]]: // CHECK: tail call spir_func void @nodupfun() #[[attr5:[0-9]+]] // CHECK-NOT: call spir_func void @nodupfun() -// CHECK: br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]] + +// The new PM produces a slightly different IR for the loop from the legacy PM, +// but the test still checks that the loop is not unrolled. +// CHECK-LEGACY: br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]] +// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label %[[for_cond_cleanup]] +// CHECK-NEW: [[for_body_crit_edge]]: void test_not_unroll() { for (int i = 0; i < 10; i++) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r364692 - Revert "[clang][NewPM] Fix broken profile test"
Author: leonardchan Date: Fri Jun 28 17:10:22 2019 New Revision: 364692 URL: http://llvm.org/viewvc/llvm-project?rev=364692&view=rev Log: Revert "[clang][NewPM] Fix broken profile test" This reverts commit ab2c0ed01edfec9a9402d03bdf8633b34b73f3a7. See https://reviews.llvm.org/D63155 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/Profile/gcc-flag-compatibility.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=364692&r1=364691&r2=364692&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jun 28 17:10:22 2019 @@ -60,7 +60,6 @@ #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" -#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" #include "llvm/Transforms/ObjCARC.h" #include "llvm/Transforms/Scalar.h" @@ -1222,11 +1221,6 @@ void EmitAssemblyHelper::EmitAssemblyWit if (CodeGenOpts.OptimizationLevel == 0) addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); - -if (CodeGenOpts.hasProfileIRInstr()) { - // This file is stored as the ProfileFile. - MPM.addPass(PGOInstrumentationGenCreateVar(PGOOpt->ProfileFile)); -} } // FIXME: We still use the legacy pass manager to do code generation. We Modified: cfe/trunk/test/Profile/gcc-flag-compatibility.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/gcc-flag-compatibility.c?rev=364692&r1=364691&r2=364692&view=diff == --- cfe/trunk/test/Profile/gcc-flag-compatibility.c (original) +++ cfe/trunk/test/Profile/gcc-flag-compatibility.c Fri Jun 28 17:10:22 2019 @@ -7,29 +7,25 @@ // -fprofile-use=Uses the profile file /default.profdata // -fprofile-use=/file Uses the profile file /file -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s // PROFILE-GEN: __llvm_profile_filename // Check that -fprofile-generate=/path/to generates /path/to/default.profraw -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s -// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-GEN-EQ %s +// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00" // Check that -fprofile-use=some/path reads some/path/default.profdata // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-2 %s -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-2 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2} // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof -fno-experimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-3 %s -// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof -fexperimental-new-pass-manager | FileCheck -check-prefix=PROFILE-USE-3 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2} int X = 0; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360448 - Fix and test for assertion error in P41835.
Author: leonardchan Date: Fri May 10 11:05:15 2019 New Revision: 360448 URL: http://llvm.org/viewvc/llvm-project?rev=360448&view=rev Log: Fix and test for assertion error in P41835. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/Frontend/macro_defined_type.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=360448&r1=360447&r2=360448&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri May 10 11:05:15 2019 @@ -2758,6 +2758,12 @@ QualType ASTContext::getFunctionTypeWith return getParenType( getFunctionTypeWithExceptionSpec(PT->getInnerType(), ESI)); + // Might be wrapped in a macro qualified type. + if (const auto *MQT = dyn_cast(Orig)) +return getMacroQualifiedType( +getFunctionTypeWithExceptionSpec(MQT->getUnderlyingType(), ESI), +MQT->getMacroIdentifier()); + // Might have a calling-convention attribute. if (const auto *AT = dyn_cast(Orig)) return getAttributedType( Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360448&r1=360447&r2=360448&view=diff == --- cfe/trunk/test/Frontend/macro_defined_type.cpp (original) +++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 11:05:15 2019 @@ -13,3 +13,9 @@ void Func() { auto NODEREF *auto_i_ptr2 = i_ptr; auto NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on an array or pointer type}} } + +// Added test for fix for P41835 +#define _LIBCPP_FLOAT_ABI __attribute__((pcs("aapcs"))) +struct A { + _LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' calling convention ignored for this target}} +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360465 - Add target triple to test.
Author: leonardchan Date: Fri May 10 13:07:47 2019 New Revision: 360465 URL: http://llvm.org/viewvc/llvm-project?rev=360465&view=rev Log: Add target triple to test. Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360465&r1=360464&r2=360465&view=diff == --- cfe/trunk/test/Frontend/macro_defined_type.cpp (original) +++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 13:07:47 2019 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-gnu %s #define NODEREF __attribute__((noderef)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360544 - Fix for P41852 where builtin attributes were being caught by FindLocsWithCommonFileID().
Author: leonardchan Date: Sun May 12 14:50:01 2019 New Revision: 360544 URL: http://llvm.org/viewvc/llvm-project?rev=360544&view=rev Log: Fix for P41852 where builtin attributes were being caught by FindLocsWithCommonFileID(). Added: cfe/trunk/test/Driver/mingw-macro-qualified-type.c Modified: cfe/trunk/lib/Parse/ParseDecl.cpp Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=360544&r1=360543&r2=360544&view=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun May 12 14:50:01 2019 @@ -224,8 +224,9 @@ void Parser::ParseGNUAttributes(ParsedAt // If this was declared in a macro, attach the macro IdentifierInfo to the // parsed attribute. -if (FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) { - auto &SM = PP.getSourceManager(); +auto &SM = PP.getSourceManager(); +if (!SM.isWrittenInBuiltinFile(SM.getSpellingLoc(AttrTokLoc)) && +FindLocsWithCommonFileID(PP, AttrTokLoc, Loc)) { CharSourceRange ExpansionRange = SM.getExpansionRange(AttrTokLoc); StringRef FoundName = Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts()); Added: cfe/trunk/test/Driver/mingw-macro-qualified-type.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-macro-qualified-type.c?rev=360544&view=auto == --- cfe/trunk/test/Driver/mingw-macro-qualified-type.c (added) +++ cfe/trunk/test/Driver/mingw-macro-qualified-type.c Sun May 12 14:50:01 2019 @@ -0,0 +1,12 @@ +// Ensure that builtin attributes do not get treated as user defined macros to +// be weapped in macro qualified types. This addresses P41852. +// +// RUN: %clang -c %s -target i686-w64-mingw32 + +typedef int WINBOOL; +typedef unsigned int UINT_PTR, *PUINT_PTR; +typedef unsigned long long ULONG64, *PULONG64; +#define WINAPI __stdcall +#define CALLBACK __stdcall + +typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360548 - Fix test to use -cc1.
Author: leonardchan Date: Sun May 12 15:44:46 2019 New Revision: 360548 URL: http://llvm.org/viewvc/llvm-project?rev=360548&view=rev Log: Fix test to use -cc1. Added: cfe/trunk/test/Sema/mingw-macro-qualified-type.c Removed: cfe/trunk/test/Driver/mingw-macro-qualified-type.c Removed: cfe/trunk/test/Driver/mingw-macro-qualified-type.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-macro-qualified-type.c?rev=360547&view=auto == --- cfe/trunk/test/Driver/mingw-macro-qualified-type.c (original) +++ cfe/trunk/test/Driver/mingw-macro-qualified-type.c (removed) @@ -1,12 +0,0 @@ -// Ensure that builtin attributes do not get treated as user defined macros to -// be weapped in macro qualified types. This addresses P41852. -// -// RUN: %clang -c %s -target i686-w64-mingw32 - -typedef int WINBOOL; -typedef unsigned int UINT_PTR, *PUINT_PTR; -typedef unsigned long long ULONG64, *PULONG64; -#define WINAPI __stdcall -#define CALLBACK __stdcall - -typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); Added: cfe/trunk/test/Sema/mingw-macro-qualified-type.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/mingw-macro-qualified-type.c?rev=360548&view=auto == --- cfe/trunk/test/Sema/mingw-macro-qualified-type.c (added) +++ cfe/trunk/test/Sema/mingw-macro-qualified-type.c Sun May 12 15:44:46 2019 @@ -0,0 +1,13 @@ +// Ensure that builtin attributes do not get treated as user defined macros to +// be weapped in macro qualified types. This addresses P41852. +// +// RUN: %clang_cc1 %s -triple i686-w64-mingw32 -fsyntax-only -verify +// expected-no-diagnostics + +typedef int WINBOOL; +typedef unsigned int UINT_PTR, *PUINT_PTR; +typedef unsigned long long ULONG64, *PULONG64; +#define WINAPI __stdcall +#define CALLBACK __stdcall + +typedef WINBOOL(CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360707 - [NewPM] Port HWASan and Kernel HWASan
Author: leonardchan Date: Tue May 14 14:17:21 2019 New Revision: 360707 URL: http://llvm.org/viewvc/llvm-project?rev=360707&view=rev Log: [NewPM] Port HWASan and Kernel HWASan Port hardware assisted address sanitizer to new PM following the same guidelines as msan and tsan. Changes: - Separate HWAddressSanitizer into a pass class and a sanitizer class. - Create new PM wrapper pass for the sanitizer class. - Use the getOrINsert pattern for some module level initialization declarations. - Also enable kernel-kwasan in new PM - Update llvm tests and add clang test. Differential Revision: https://reviews.llvm.org/D61709 Added: cfe/trunk/test/CodeGen/hwasan-new-pm.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=360707&r1=360706&r2=360707&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May 14 14:17:21 2019 @@ -57,6 +57,7 @@ #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Instrumentation/BoundsChecking.h" #include "llvm/Transforms/Instrumentation/GCOVProfiler.h" +#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" @@ -265,12 +266,13 @@ static void addHWAddressSanitizerPasses( static_cast(Builder); const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress); - PM.add(createHWAddressSanitizerPass(/*CompileKernel*/ false, Recover)); + PM.add( + createHWAddressSanitizerLegacyPassPass(/*CompileKernel*/ false, Recover)); } static void addKernelHWAddressSanitizerPasses(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { - PM.add(createHWAddressSanitizerPass( + PM.add(createHWAddressSanitizerLegacyPassPass( /*CompileKernel*/ true, /*Recover*/ true)); } @@ -962,6 +964,17 @@ static void addSanitizersAtO0(ModulePass if (LangOpts.Sanitize.has(SanitizerKind::Thread)) { MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass())); } + + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { +bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); +MPM.addPass(createModuleToFunctionPassAdaptor( +HWAddressSanitizerPass(/*CompileKernel=*/false, Recover))); + } + + if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) { +MPM.addPass(createModuleToFunctionPassAdaptor( +HWAddressSanitizerPass(/*CompileKernel=*/true, /*Recover=*/true))); + } } /// A clean version of `EmitAssembly` that uses the new pass manager. @@ -1145,6 +1158,23 @@ void EmitAssemblyHelper::EmitAssemblyWit UseOdrIndicator)); }); } + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { +bool Recover = +CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); +PB.registerOptimizerLastEPCallback( +[Recover](FunctionPassManager &FPM, + PassBuilder::OptimizationLevel Level) { + FPM.addPass(HWAddressSanitizerPass( + /*CompileKernel=*/false, Recover)); +}); + } + if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) { +PB.registerOptimizerLastEPCallback( +[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { + FPM.addPass(HWAddressSanitizerPass( + /*CompileKernel=*/true, /*Recover=*/true)); +}); + } if (Optional Options = getGCOVOptions(CodeGenOpts)) PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) { MPM.addPass(GCOVProfilerPass(*Options)); Added: cfe/trunk/test/CodeGen/hwasan-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hwasan-new-pm.c?rev=360707&view=auto == --- cfe/trunk/test/CodeGen/hwasan-new-pm.c (added) +++ cfe/trunk/test/CodeGen/hwasan-new-pm.c Tue May 14 14:17:21 2019 @@ -0,0 +1,34 @@ +// Test that HWASan and KHWASan runs with the new pass manager. +// We run them under different optimizations and LTOs to ensure the IR is still +// being instrumented properly. + +// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT +// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT +// RUN: %clang_cc1 -S -emit-llvm -o - -f
r360720 - Fix bots by adding target triple to test.
Author: leonardchan Date: Tue May 14 15:37:34 2019 New Revision: 360720 URL: http://llvm.org/viewvc/llvm-project?rev=360720&view=rev Log: Fix bots by adding target triple to test. Modified: cfe/trunk/test/CodeGen/hwasan-new-pm.c Modified: cfe/trunk/test/CodeGen/hwasan-new-pm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hwasan-new-pm.c?rev=360720&r1=360719&r2=360720&view=diff == --- cfe/trunk/test/CodeGen/hwasan-new-pm.c (original) +++ cfe/trunk/test/CodeGen/hwasan-new-pm.c Tue May 14 15:37:34 2019 @@ -2,19 +2,19 @@ // We run them under different optimizations and LTOs to ensure the IR is still // being instrumented properly. -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN -// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s int foo(int *a) { return *a; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r361205 - [Sema] Fix for build on some iOS programs.
Author: leonardchan Date: Mon May 20 15:42:19 2019 New Revision: 361205 URL: http://llvm.org/viewvc/llvm-project?rev=361205&view=rev Log: [Sema] Fix for build on some iOS programs. Nullability attributes weren't being stripped for AttributedTypes that were wrapped in a MacroQualifiedType. This fix adds a check for this type and a test. Added: cfe/trunk/test/SemaObjC/nullability_macro.m Modified: cfe/trunk/lib/AST/Type.cpp Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=361205&r1=361204&r2=361205&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Mon May 20 15:42:19 2019 @@ -3929,7 +3929,11 @@ AttributedType::getImmediateNullability( } Optional AttributedType::stripOuterNullability(QualType &T) { - if (auto attributed = dyn_cast(T.getTypePtr())) { + QualType AttrTy = T; + if (auto MacroTy = dyn_cast(T)) +AttrTy = MacroTy->getUnderlyingType(); + + if (auto attributed = dyn_cast(AttrTy)) { if (auto nullability = attributed->getImmediateNullability()) { T = attributed->getModifiedType(); return nullability; Added: cfe/trunk/test/SemaObjC/nullability_macro.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nullability_macro.m?rev=361205&view=auto == --- cfe/trunk/test/SemaObjC/nullability_macro.m (added) +++ cfe/trunk/test/SemaObjC/nullability_macro.m Mon May 20 15:42:19 2019 @@ -0,0 +1,16 @@ +// Test that nullability attributes still get merged even though they are +// wrapped with a MacroQualifiedType. This should just compile with no errors. +// RUN: %clang_cc1 %s -Wno-objc-root-class -fsyntax-only -verify +#define UI_APPEARANCE_SELECTOR __attribute__((annotate("ui_appearance_selector"))) + +@class UIColor; + +@interface Test +@property(null_resettable, nonatomic, strong)Â UIColor *onTintColor UI_APPEARANCE_SELECTOR; // expected-warning{{treating Unicode character as whitespace}} +@end + +@implementation Test +- (void)setOnTintColor:(nullable UIColor *)onTintColor { +} + +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r360109 - Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Thanks for bringing this up! I submitted r361205 which should fix this. The problem seemed to be that stripOuterNullability() was missing checks for AttributedTypes that were wrapped in the MacroQualifiedType which this patch introduces, so I just added a check for that type also. The reason replacing UI_APPEARANCE_SELECTOR with __attribute__((annotate("ui_appearance_selector"))) is because this type wraps AttributedTypes for special cases when the entire attribute is declared in a macro. *From: *Nico Weber *Date: *Mon, May 20, 2019 at 11:34 AM *To: *Leonard Chan *Cc: *cfe-commits Hello, it seems this broke building some iOS programs. > > $ cat test.m > # define UI_APPEARANCE_SELECTOR > __attribute__((annotate("ui_appearance_selector"))) > > @class UIColor; > > @interface Test > @property(null_resettable, nonatomic, strong) UIColor *onTintColor > UI_APPEARANCE_SELECTOR; > @end > > @implementation Test > - (void)setOnTintColor:(nullable UIColor *)onTintColor { > } > > @end > > $ out/gn/bin/clang -c test.m -Wno-objc-root-class > test.m:10:44: error: nullability specifier 'nullable' conflicts with > existing specifier '_Null_unspecified' > - (void)setOnTintColor:(nullable UIColor *)onTintColor { >^ > 1 error generated. > > > Before this change, that compiled fine. Surprisingly, it still builds fine > if UI_APPEARANCE_SELECTOR is replaced by > `__attribute__((annotate("ui_appearance_selector")))` in the source code, > even though both lead to the same -E output. > > *From: *Leonard Chan via cfe-commits > *Date: *Mon, May 6, 2019 at 11:17 PM > *To: * > > Author: leonardchan >> Date: Mon May 6 20:20:17 2019 >> New Revision: 360109 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=360109&view=rev >> Log: >> Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an >> attribute declaration" >> >> Updated with fix for read of uninitialized memory. >> >> Added: >> cfe/trunk/test/Frontend/macro_defined_type.cpp >> cfe/trunk/test/Sema/address_space_print_macro.c >> Modified: >> cfe/trunk/include/clang/AST/ASTContext.h >> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h >> cfe/trunk/include/clang/AST/Type.h >> cfe/trunk/include/clang/AST/TypeLoc.h >> cfe/trunk/include/clang/AST/TypeNodes.def >> cfe/trunk/include/clang/Parse/Parser.h >> cfe/trunk/include/clang/Sema/ParsedAttr.h >> cfe/trunk/include/clang/Sema/Sema.h >> cfe/trunk/include/clang/Serialization/ASTBitCodes.h >> cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp >> cfe/trunk/lib/AST/ASTContext.cpp >> cfe/trunk/lib/AST/ASTDiagnostic.cpp >> cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp >> cfe/trunk/lib/AST/ItaniumMangle.cpp >> cfe/trunk/lib/AST/Type.cpp >> cfe/trunk/lib/AST/TypePrinter.cpp >> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp >> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp >> cfe/trunk/lib/Parse/ParseDecl.cpp >> cfe/trunk/lib/Sema/SemaExpr.cpp >> cfe/trunk/lib/Sema/SemaStmt.cpp >> cfe/trunk/lib/Sema/SemaType.cpp >> cfe/trunk/lib/Sema/TreeTransform.h >> cfe/trunk/lib/Serialization/ASTReader.cpp >> cfe/trunk/lib/Serialization/ASTWriter.cpp >> cfe/trunk/test/Sema/address_spaces.c >> cfe/trunk/test/SemaObjC/externally-retained.m >> cfe/trunk/test/SemaObjC/gc-attributes.m >> cfe/trunk/test/SemaObjC/mrc-weak.m >> cfe/trunk/test/SemaObjCXX/gc-attributes.mm >> cfe/trunk/tools/libclang/CIndex.cpp >> >> Modified: cfe/trunk/include/clang/AST/ASTContext.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360109&r1=360108&r2=360109&view=diff >> >> == >> --- cfe/trunk/include/clang/AST/ASTContext.h (original) >> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon May 6 20:20:17 2019 >> @@ -1441,6 +1441,9 @@ public: >> >>QualType getParenType(QualType NamedType) const; >> >> + QualType getMacroQualifiedType(QualType UnderlyingTy, >> + const IdentifierInfo *MacroII) const; >> + >>QualType getElaboratedType(ElaboratedTypeKeyword Keyword, >> NestedNameSpecifier *NNS, QualType >> NamedType, >> TagDecl *OwnedTagDecl = nullptr) const; >> >> Modified: cfe/trunk/include/clang/AST/Recur
r361302 - Remove unicode character from test
Author: leonardchan Date: Tue May 21 13:12:00 2019 New Revision: 361302 URL: http://llvm.org/viewvc/llvm-project?rev=361302&view=rev Log: Remove unicode character from test Modified: cfe/trunk/test/SemaObjC/nullability_macro.m Modified: cfe/trunk/test/SemaObjC/nullability_macro.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nullability_macro.m?rev=361302&r1=361301&r2=361302&view=diff == --- cfe/trunk/test/SemaObjC/nullability_macro.m (original) +++ cfe/trunk/test/SemaObjC/nullability_macro.m Tue May 21 13:12:00 2019 @@ -1,12 +1,13 @@ // Test that nullability attributes still get merged even though they are // wrapped with a MacroQualifiedType. This should just compile with no errors. // RUN: %clang_cc1 %s -Wno-objc-root-class -fsyntax-only -verify +// expected-no-diagnostics #define UI_APPEARANCE_SELECTOR __attribute__((annotate("ui_appearance_selector"))) @class UIColor; @interface Test -@property(null_resettable, nonatomic, strong)Â UIColor *onTintColor UI_APPEARANCE_SELECTOR; // expected-warning{{treating Unicode character as whitespace}} +@property(null_resettable, nonatomic, strong) UIColor *onTintColor UI_APPEARANCE_SELECTOR; @end @implementation Test ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335993 - [Fixed Point Arithmetic] Rename `-fsame-fbits` flag
Author: leonardchan Date: Fri Jun 29 10:08:19 2018 New Revision: 335993 URL: http://llvm.org/viewvc/llvm-project?rev=335993&view=rev Log: [Fixed Point Arithmetic] Rename `-fsame-fbits` flag - Rename the `-fsame-fbits` flag to `-fpadding-on-unsigned-fixed-point` - Move the flag from a driver option to a cc1 option - Rename the `SameFBits` member in TargetInfo to `PaddingOnUnsignedFixedPoint` - Updated descriptions Differential Revision: https://reviews.llvm.org/D48727 Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Frontend/fixed_point_same_fbits.c Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=335993&r1=335992&r2=335993&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Jun 29 10:08:19 2018 @@ -306,8 +306,8 @@ ENUM_LANGOPT(ClangABICompat, ClangABI, 4 COMPATIBLE_VALUE_LANGOPT(FunctionAlignment, 5, 0, "Default alignment for functions") LANGOPT(FixedPoint, 1, 0, "fixed point types") -LANGOPT(SameFBits, 1, 0, -"unsigned and signed fixed point type having the same number of fractional bits") +LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0, +"unsigned fixed point types having one extra padding bit") #undef LANGOPT #undef COMPATIBLE_LANGOPT Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=335993&r1=335992&r2=335993&view=diff == --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Jun 29 10:08:19 2018 @@ -84,10 +84,11 @@ protected: unsigned char LongFractWidth, LongFractAlign; // If true, unsigned fixed point types have the same number of fractional bits - // as their signed counterparts. Otherwise, unsigned fixed point types have + // as their signed counterparts, forcing the unsigned types to have one extra + // bit of padding. Otherwise, unsigned fixed point types have // one more fractional bit than its corresponding signed type. This is false // by default. - bool SameFBits; + bool PaddingOnUnsignedFixedPoint; // Fixed point integral and fractional bit sizes // Saturated types share the same integral/fractional bits as their @@ -95,7 +96,7 @@ protected: // For simplicity, the fractional bits in a _Fract type will be one less the // width of that _Fract type. This leaves all signed _Fract types having no // padding and unsigned _Fract types will only have 1 bit of padding after the - // sign if SameFBits is set. + // sign if PaddingOnUnsignedFixedPoint is set. unsigned char ShortAccumScale; unsigned char AccumScale; unsigned char LongAccumScale; @@ -436,30 +437,33 @@ public: /// getUnsignedShortAccumScale/IBits - Return the number of /// fractional/integral bits in a 'unsigned short _Accum' type. unsigned getUnsignedShortAccumScale() const { -return SameFBits ? ShortAccumScale : ShortAccumScale + 1; +return PaddingOnUnsignedFixedPoint ? ShortAccumScale : ShortAccumScale + 1; } unsigned getUnsignedShortAccumIBits() const { -return SameFBits ? getShortAccumIBits() - : ShortAccumWidth - getUnsignedShortAccumScale(); +return PaddingOnUnsignedFixedPoint + ? getShortAccumIBits() + : ShortAccumWidth - getUnsignedShortAccumScale(); } /// getUnsignedAccumScale/IBits - Return the number of fractional/integral /// bits in a 'unsigned _Accum' type. unsigned getUnsignedAccumScale() const { -return SameFBits ? AccumScale : AccumScale + 1; +return PaddingOnUnsignedFixedPoint ? AccumScale : AccumScale + 1; } unsigned getUnsignedAccumIBits() const { -return SameFBits ? getAccumIBits() : AccumWidth - getUnsignedAccumScale(); +return PaddingOnUnsignedFixedPoint ? getAccumIBits() + : AccumWidth - getUnsignedAccumScale(); } /// getUnsignedLongAccumScale/IBits - Return the number of fractional/integral /// bits in a 'unsigned long _Accum' type. unsigned getUnsignedLongAccumScale() const { -return SameFBits ? LongAccumScale : LongAccumScale + 1; +return PaddingOnUnsignedFixedPoint ? LongAccumScale : LongAccumScale + 1; } unsigned getUnsignedLongAccumIBits() const { -return SameFBits ? getLongAccumIBits() - : LongAccumWidth - getUnsignedLongAccumScal
r337289 - [Fixed Point Arithmetic] Fix for bug where integer literals could be treated as fixed point literals
Author: leonardchan Date: Tue Jul 17 07:58:49 2018 New Revision: 337289 URL: http://llvm.org/viewvc/llvm-project?rev=337289&view=rev Log: [Fixed Point Arithmetic] Fix for bug where integer literals could be treated as fixed point literals This addresses a bug brought up in https://bugs.llvm.org/show_bug.cgi?id=38161 where integer literals could be treated as fixed point types and throw errors related to fixed point types when the 'k' or 'r' suffix used. The fix also addresses the second issue brought up with the assertion by not treating integers as fixed point types in the first place. Integers that have suffixes 'k' and 'r' now throw the error `invalid suffix 'k/r' on integer constant`. A few more tests were also added to ensure that fixed point types, and any errors/warnings related to them, are limited to C for now. Prior discussion also at https://reviews.llvm.org/D46915. Differential Revision: https://reviews.llvm.org/D49327 Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp cfe/trunk/test/Frontend/fixed_point_errors.c cfe/trunk/test/Frontend/fixed_point_errors.cpp cfe/trunk/test/Frontend/fixed_point_not_enabled.c Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=337289&r1=337288&r2=337289&view=diff == --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original) +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Jul 17 07:58:49 2018 @@ -572,10 +572,12 @@ NumericLiteralParser::NumericLiteralPars checkSeparator(TokLoc, s, CSK_AfterDigits); // Initial scan to lookahead for fixed point suffix. - for (const char *c = s; c != ThisTokEnd; ++c) { -if (*c == 'r' || *c == 'k' || *c == 'R' || *c == 'K') { - saw_fixed_point_suffix = true; - break; + if (PP.getLangOpts().FixedPoint) { +for (const char *c = s; c != ThisTokEnd; ++c) { + if (*c == 'r' || *c == 'k' || *c == 'R' || *c == 'K') { +saw_fixed_point_suffix = true; +break; + } } } @@ -589,12 +591,16 @@ NumericLiteralParser::NumericLiteralPars switch (*s) { case 'R': case 'r': + if (!PP.getLangOpts().FixedPoint) break; if (isFract || isAccum) break; + if (!(saw_period || saw_exponent)) break; isFract = true; continue; case 'K': case 'k': + if (!PP.getLangOpts().FixedPoint) break; if (isFract || isAccum) break; + if (!(saw_period || saw_exponent)) break; isAccum = true; continue; case 'h': // FP Suffix for "half". @@ -734,7 +740,6 @@ NumericLiteralParser::NumericLiteralPars if (!hadError && saw_fixed_point_suffix) { assert(isFract || isAccum); -//assert(radix == 16 || radix == 10); } } Modified: cfe/trunk/test/Frontend/fixed_point_errors.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/fixed_point_errors.c?rev=337289&r1=337288&r2=337289&view=diff == --- cfe/trunk/test/Frontend/fixed_point_errors.c (original) +++ cfe/trunk/test/Frontend/fixed_point_errors.c Tue Jul 17 07:58:49 2018 @@ -148,3 +148,87 @@ _Accum dec_with_hex_exp1 = 0.1p10k;/ _Accum dec_with_hex_exp2 = 0.1P10k;// expected-error{{invalid suffix 'P10k' on integer constant}} _Accum hex_with_dex_exp1 = 0x0.1e10k; // expected-error{{hexadecimal floating constant requires an exponent}} _Accum hex_with_dex_exp2 = 0x0.1E10k; // expected-error{{hexadecimal floating constant requires an exponent}} + +void CheckSuffixOnIntegerLiterals() { + _Accum short_acc_int; + _Accum acc_int; + _Accum long_acc_int; + + _Accum u_short_acc_int; + _Accum u_acc_int; + _Accum u_long_acc_int; + + _Fract short_fract_int; + _Fract fract_int; + _Fract long_fract_int; + + _Fract u_short_fract_int; + _Fract u_fract_int; + _Fract u_long_fract_int; + + // Decimal integer literals (non-zero) + short_acc_int = 10hk; // expected-error{{invalid suffix 'hk' on integer constant}} + acc_int = 10k;// expected-error{{invalid suffix 'k' on integer constant}} + long_acc_int = 10lk; // expected-error{{invalid suffix 'lk' on integer constant}} + + u_short_acc_int = 10uhk; // expected-error{{invalid suffix 'uhk' on integer constant}} + u_acc_int = 10uk;// expected-error{{invalid suffix 'uk' on integer constant}} + u_long_acc_int = 10ulk; // expected-error{{invalid suffix 'ulk' on integer constant}} + + short_fract_int = 10hr; // expected-error{{invalid suffix 'hr' on integer constant}} + fract_int = 10r;// expected-error{{invalid suffix 'r' on integer constant}} + long_fract_int = 10lr; // expected-error{{invalid suffix 'lr' on integer constant}} + + u_short_fract_int = 10uhr; // expected-error{{invalid suffix 'uhr' on integer constant}} + u_fract_int = 10ur;// expected-error{{invalid suffix 'ur' on integer constant}} + u_lon
[clang] 85b718f - [Driver] Enable ShadowCallStack, not SafeStack, by default on AArch64 Fuchsia
Author: Leonard Chan Date: 2019-10-28T14:19:38-07:00 New Revision: 85b718f53a3575bca2f1b7fdb1b3aaa6df7c10e3 URL: https://github.com/llvm/llvm-project/commit/85b718f53a3575bca2f1b7fdb1b3aaa6df7c10e3 DIFF: https://github.com/llvm/llvm-project/commit/85b718f53a3575bca2f1b7fdb1b3aaa6df7c10e3.diff LOG: [Driver] Enable ShadowCallStack, not SafeStack, by default on AArch64 Fuchsia Submitted for mcgrathr. On AArch64, Fuchsia fully supports both SafeStack and ShadowCallStack ABIs. The latter is now preferred and will be the default. It's possible to enable both simultaneously, but ShadowCallStack is believed to have most of the practical benefit of SafeStack with less cost. Differential Revision: https://reviews.llvm.org/D66712 Added: Modified: clang/lib/Driver/ToolChains/Fuchsia.cpp clang/test/Driver/fuchsia.c Removed: diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index e7d38ff9f227..df2b4724dc22 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -343,5 +343,10 @@ SanitizerMask Fuchsia::getSupportedSanitizers() const { } SanitizerMask Fuchsia::getDefaultSanitizers() const { - return SanitizerKind::SafeStack; + SanitizerMask Res; + if (getTriple().getArch() == llvm::Triple::aarch64) +Res |= SanitizerKind::ShadowCallStack; + else +Res |= SanitizerKind::SafeStack; + return Res; } diff --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c index bf8e5a04dc91..b5f9c326ea69 100644 --- a/clang/test/Driver/fuchsia.c +++ b/clang/test/Driver/fuchsia.c @@ -13,7 +13,8 @@ // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include" -// CHECK: "-fsanitize=safe-stack" +// CHECK-AARCH64: "-fsanitize=shadow-call-stack" +// CHECK-X86_64: "-fsanitize=safe-stack" // CHECK: "-stack-protector" "2" // CHECK: "-fno-common" // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic" "-z" "separate-loadable-segments" @@ -102,7 +103,7 @@ // RUN: -fuse-ld=lld \ // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64 // CHECK-ASAN-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" -// CHECK-ASAN-AARCH64: "-fsanitize=address" +// CHECK-ASAN-AARCH64: "-fsanitize=address,shadow-call-stack" // CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping" // CHECK-ASAN-AARCH64: "-dynamic-linker" "asan/ld.so.1" // CHECK-ASAN-AARCH64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.asan.so" @@ -134,7 +135,7 @@ // RUN: -fuse-ld=lld \ // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-AARCH64 // CHECK-FUZZER-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" -// CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,safe-stack" +// CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,shadow-call-stack" // CHECK-FUZZER-AARCH64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.fuzzer.a" // RUN: %clang %s -### --target=x86_64-fuchsia \ @@ -153,7 +154,7 @@ // RUN: -fuse-ld=lld \ // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64 // CHECK-SCUDO-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" -// CHECK-SCUDO-AARCH64: "-fsanitize=safe-stack,scudo" +// CHECK-SCUDO-AARCH64: "-fsanitize=shadow-call-stack,scudo" // CHECK-SCUDO-AARCH64: "-pie" // CHECK-SCUDO-AARCH64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.scudo.so" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ef37444 - [Lexer] Fix invalid suffix diagnostic for fixed-point literals
Author: Leonard Chan Date: 2020-05-27T16:16:56-07:00 New Revision: ef37444058550b0f49441b994c9e9368d8e42da8 URL: https://github.com/llvm/llvm-project/commit/ef37444058550b0f49441b994c9e9368d8e42da8 DIFF: https://github.com/llvm/llvm-project/commit/ef37444058550b0f49441b994c9e9368d8e42da8.diff LOG: [Lexer] Fix invalid suffix diagnostic for fixed-point literals Committing on behalf of nagart, who authored this patch. Differential Revision: https://reviews.llvm.org/D80412 Added: Modified: clang/include/clang/Basic/DiagnosticLexKinds.td clang/include/clang/Lex/LiteralSupport.h clang/lib/Lex/LiteralSupport.cpp clang/test/Frontend/fixed_point_errors.c Removed: diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index ef90bdf84c8a..fa07e9ae76c8 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -175,7 +175,7 @@ def ext_unknown_escape : ExtWarn<"unknown escape sequence '\\%0'">, def err_invalid_digit : Error< "invalid digit '%0' in %select{decimal|octal|binary}1 constant">; def err_invalid_suffix_constant : Error< - "invalid suffix '%0' on %select{integer|floating}1 constant">; + "invalid suffix '%0' on %select{integer|floating|fixed-point}1 constant">; def warn_cxx11_compat_digit_separator : Warning< "digit separators are incompatible with C++ standards before C++14">, InGroup, DefaultIgnore; diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index b9d64c24a00b..6829771b2830 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -71,7 +71,9 @@ class NumericLiteralParser { bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk - bool isFixedPointLiteral() const { return saw_fixed_point_suffix; } + bool isFixedPointLiteral() const { +return (saw_period || saw_exponent) && saw_fixed_point_suffix; + } bool isIntegerLiteral() const { return !saw_period && !saw_exponent && !isFixedPointLiteral(); diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 2b1add4d9b98..f44614b4bec4 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -583,6 +583,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // Parse the suffix. At this point we can classify whether we have an FP or // integer constant. + bool isFixedPointConstant = isFixedPointLiteral(); bool isFPConstant = isFloatingLiteral(); // Loop over all of the characters of the suffix. If we see something bad, @@ -737,7 +738,8 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // Report an error if there are any. PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin), diag::err_invalid_suffix_constant) - << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin) << isFPConstant; + << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin) + << (isFixedPointConstant ? 2 : isFPConstant); hadError = true; } } diff --git a/clang/test/Frontend/fixed_point_errors.c b/clang/test/Frontend/fixed_point_errors.c index db15bd874b31..9b600fbc2642 100644 --- a/clang/test/Frontend/fixed_point_errors.c +++ b/clang/test/Frontend/fixed_point_errors.c @@ -137,15 +137,15 @@ _Sat longfract_t td_sat_long_fract; // expected-error{{'_Sat' specifier _Sat longaccum_t td_sat_long_accum; // expected-error{{'_Sat' specifier is only valid on '_Fract' or '_Accum', not 'type-name'}} /* Bad suffixes */ -_Accum fk = 1.0fk;// expected-error{{invalid suffix 'fk' on integer constant}} -_Accum kk = 1.0kk;// expected-error{{invalid suffix 'kk' on integer constant}} -_Accum rk = 1.0rk;// expected-error{{invalid suffix 'rk' on integer constant}} -_Accum rk = 1.0rr;// expected-error{{invalid suffix 'rr' on integer constant}} -_Accum qk = 1.0qr;// expected-error{{invalid suffix 'qr' on integer constant}} +_Accum fk = 1.0fk; // expected-error{{invalid suffix 'fk' on fixed-point constant}} +_Accum kk = 1.0kk; // expected-error{{invalid suffix 'kk' on fixed-point constant}} +_Accum rk = 1.0rk; // expected-error{{invalid suffix 'rk' on fixed-point constant}} +_Accum rk = 1.0rr; // expected-error{{invalid suffix 'rr' on fixed-point constant}} +_Accum qk = 1.0qr; // expected-error{{invalid suffix 'qr' on fixed-point constant}} /* Using wrong exponent notation */ -_Accum dec_with_hex_exp1 = 0.1p10k;// expected-error{{invalid suffix 'p10k' on integer constant}} -_Accum dec_with_hex_exp2 = 0.1P10k;// expected-error{{invalid suffix 'P10k' on integer constant}} +_Accum dec_with_hex_exp1 = 0.1p10k;// expected-error{{invalid suffix 'p1
[clang] 2f6bb2a - [clang][Attribute] Fix noderef attribute false-negatives
Author: Leonard Chan Date: 2020-06-10T12:20:54-07:00 New Revision: 2f6bb2a69215f9cae883da12f8f596d3f80f8d71 URL: https://github.com/llvm/llvm-project/commit/2f6bb2a69215f9cae883da12f8f596d3f80f8d71 DIFF: https://github.com/llvm/llvm-project/commit/2f6bb2a69215f9cae883da12f8f596d3f80f8d71.diff LOG: [clang][Attribute] Fix noderef attribute false-negatives `noderef` was failing to trigger warnings in some cases related to c++ style casting. This patch addresses them. Differential Revision: https://reviews.llvm.org/D77836 Added: Modified: clang/include/clang/Sema/Initialization.h clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaInit.cpp clang/test/Frontend/noderef.cpp Removed: diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h index d50ec2addc8f..ca9e0a198cb9 100644 --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -689,6 +689,9 @@ class InitializationKind { return Context >= IC_StaticCast; } + /// Determine whether this initialization is a static cast. + bool isStaticCast() const { return Context == IC_StaticCast; } + /// Determine whether this initialization is a C-style cast. bool isCStyleOrFunctionalCast() const { return Context >= IC_CStyleCast; diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index f483f7315aec..2efe26052c78 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -161,6 +161,30 @@ namespace { PlaceholderKind = (BuiltinType::Kind) 0; } }; + + void CheckNoDeref(Sema &S, const QualType FromType, const QualType ToType, +SourceLocation OpLoc) { +if (const auto *PtrType = dyn_cast(FromType)) { + if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) { +if (const auto *DestType = dyn_cast(ToType)) { + if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) { +S.Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer); + } +} + } +} + } + + struct CheckNoDerefRAII { +CheckNoDerefRAII(CastOperation &Op) : Op(Op) {} +~CheckNoDerefRAII() { + if (!Op.SrcExpr.isInvalid()) +CheckNoDeref(Op.Self, Op.SrcExpr.get()->getType(), Op.ResultType, + Op.OpRange.getBegin()); +} + +CastOperation &Op; + }; } static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr, @@ -723,6 +747,8 @@ static TryCastResult getCastAwayConstnessCastKind(CastAwayConstnessKind CACK, /// Refer to C++ 5.2.7 for details. Dynamic casts are used mostly for runtime- /// checked downcasts in class hierarchies. void CastOperation::CheckDynamicCast() { + CheckNoDerefRAII NoderefCheck(*this); + if (ValueKind == VK_RValue) SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get()); else if (isPlaceholder()) @@ -876,6 +902,8 @@ void CastOperation::CheckDynamicCast() { /// const char *str = "literal"; /// legacy_function(const_cast\(str)); void CastOperation::CheckConstCast() { + CheckNoDerefRAII NoderefCheck(*this); + if (ValueKind == VK_RValue) SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get()); else if (isPlaceholder()) @@ -1045,6 +1073,8 @@ void CastOperation::CheckReinterpretCast() { /// Refer to C++ 5.2.9 for details. Static casts are mostly used for making /// implicit conversions explicit and getting rid of data loss warnings. void CastOperation::CheckStaticCast() { + CheckNoDerefRAII NoderefCheck(*this); + if (isPlaceholder()) { checkNonOverloadPlaceholders(); if (SrcExpr.isInvalid()) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 0a98cb2a5ce0..d46e7f86d6b3 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -8200,9 +8200,13 @@ ExprResult InitializationSequence::Perform(Sema &S, if (const auto *ToPtrType = Step->Type->getAs()) { if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) && !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) { -S.Diag(CurInit.get()->getExprLoc(), - diag::warn_noderef_to_dereferenceable_pointer) -<< CurInit.get()->getSourceRange(); +// Do not check static casts here because they are checked earlier +// in Sema::ActOnCXXNamedCast() +if (!Kind.isStaticCast()) { + S.Diag(CurInit.get()->getExprLoc(), + diag::warn_noderef_to_dereferenceable_pointer) + << CurInit.get()->getSourceRange(); +} } } } diff --git a/clang/test/Frontend/noderef.cpp b/clang/test/Frontend/noderef.cpp index 15eb4e457c20..32d5ca34d1b1 100644 --- a/clang/test/Frontend/noderef.cpp +++ b/clang/test/Frontend/noderef.cpp @@ -80,12 +80,28 @@ class A { int member;
[clang] de172dd - [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp
Author: Leonard Chan Date: 2020-06-29T13:06:42-07:00 New Revision: de172dd17f0334e1fcbbf28a33d0ea24f7cbff1a URL: https://github.com/llvm/llvm-project/commit/de172dd17f0334e1fcbbf28a33d0ea24f7cbff1a DIFF: https://github.com/llvm/llvm-project/commit/de172dd17f0334e1fcbbf28a33d0ea24f7cbff1a.diff LOG: [clang][RelativeVTablesABI] Update CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp After c7bcd431d9c4bfeb631a3599f1d628603e6351d6, this test started failing when running with the new pass manager. One of the CHECKs in this file checks how the vtable is loaded for a void cast, which involves taking 2 bitcasts from the pointer to the original object. The order of these bitcasts changes under the new PM. The order doesn't matter, so this relaxes the CHECKs. Differential Revision: https://reviews.llvm.org/D82802 Added: Modified: clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp Removed: diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp index 56b56a1b9398..62d674669661 100644 --- a/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp @@ -35,13 +35,13 @@ // CHECK-NEXT: [[isnull:%[0-9]+]] = icmp eq %class.B* %b, null // CHECK-NEXT: br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], label %[[dynamic_cast_notnull:[a-z0-9._]+]] // CHECK: [[dynamic_cast_notnull]]: -// CHECK-NEXT: [[b2:%[0-9]+]] = bitcast %class.B* %b to i32** -// CHECK-NEXT: [[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8 -// CHECK-NEXT: [[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2 -// CHECK-NEXT: [[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4 -// CHECK-NEXT: [[b:%[0-9]+]] = bitcast %class.B* %b to i8* -// CHECK-NEXT: [[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64 -// CHECK-NEXT: [[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]] +// CHECK-DAG:[[b2:%[0-9]+]] = bitcast %class.B* %b to i32** +// CHECK-DAG:[[vtable:%[a-z0-9]+]] = load i32*, i32** [[b2]], align 8 +// CHECK-DAG:[[offset_ptr:%.+]] = getelementptr inbounds i32, i32* [[vtable]], i64 -2 +// CHECK-DAG:[[offset_to_top:%.+]] = load i32, i32* [[offset_ptr]], align 4 +// CHECK-DAG:[[b:%[0-9]+]] = bitcast %class.B* %b to i8* +// CHECK-DAG:[[offset_to_top2:%.+]] = sext i32 [[offset_to_top]] to i64 +// CHECK-DAG:[[casted:%.+]] = getelementptr inbounds i8, i8* [[b]], i64 [[offset_to_top2]] // CHECK-NEXT: br label %[[dynamic_cast_end]] // CHECK: [[dynamic_cast_end]]: // CHECK-NEXT: [[res:%[0-9]+]] = phi i8* [ [[casted]], %[[dynamic_cast_notnull]] ], [ null, %entry ] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e9802aa - Revert "Run Coverage pass before other *San passes under new pass manager"
Author: Leonard Chan Date: 2020-05-14T15:19:27-07:00 New Revision: e9802aa4221ba3857041c2328639ce2aac0ace67 URL: https://github.com/llvm/llvm-project/commit/e9802aa4221ba3857041c2328639ce2aac0ace67 DIFF: https://github.com/llvm/llvm-project/commit/e9802aa4221ba3857041c2328639ce2aac0ace67.diff LOG: Revert "Run Coverage pass before other *San passes under new pass manager" This reverts commit 7d5bb94d78386e4653535c35d3e8258bf4502340. Reverting since this leads to a linker error we're seeing on Fuchsia. The underlying issue seems to be that inlining is run after sanitizers and causes different comdat groups instrumented by Sancov to reference non-key symbols defined in other comdat groups. Will re-land this patch after a fix for that is landed. Added: Modified: clang/lib/CodeGen/BackendUtil.cpp Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 7b876df852b5..33627f3a6733 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1001,15 +1001,6 @@ static void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple, const LangOptions &LangOpts, const CodeGenOptions &CodeGenOpts) { - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); -MPM.addPass(ModuleSanitizerCoveragePass( -SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles, -CodeGenOpts.SanitizeCoverageBlacklistFiles)); - } - auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) { MPM.addPass(RequireAnalysisPass()); bool Recover = CodeGenOpts.SanitizeRecover.has(Mask); @@ -1250,17 +1241,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( EntryExitInstrumenterPass(/*PostInlining=*/false))); }); - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) { - auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); - MPM.addPass(ModuleSanitizerCoveragePass( - SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles, - CodeGenOpts.SanitizeCoverageBlacklistFiles)); -}); - } - // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1345,6 +1325,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( } } +if (CodeGenOpts.SanitizeCoverageType || +CodeGenOpts.SanitizeCoverageIndirectCalls || +CodeGenOpts.SanitizeCoverageTraceCmp) { + auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); + MPM.addPass(ModuleSanitizerCoveragePass( + SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles, + CodeGenOpts.SanitizeCoverageBlacklistFiles)); +} + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); MPM.addPass(HWAddressSanitizerPass( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 592303a - [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain
Author: Leonard Chan Date: 2020-05-14T17:03:58-07:00 New Revision: 592303a53e6bc0737c3999e91aab9ea2147f73ab URL: https://github.com/llvm/llvm-project/commit/592303a53e6bc0737c3999e91aab9ea2147f73ab DIFF: https://github.com/llvm/llvm-project/commit/592303a53e6bc0737c3999e91aab9ea2147f73ab.diff LOG: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain gLinux started shipping incompatible versions of Z3, which can lead to a missing `z3.h` header when building the Z3 solver locally. This patch disables the Z3 solver when building a clang toolchain for Fuchsia. Differential Revision: https://reviews.llvm.org/D79974 Added: Modified: clang/cmake/caches/Fuchsia-stage2.cmake Removed: diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index eb2a03e164dd..4ef404b8aaef 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -17,6 +17,7 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "") set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "") +set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "") set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") if(NOT APPLE) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d2fd110 - Reapply "[clang] Support fixed point types in C++ (#67750)" (#69963)
Author: Leonard Chan Date: 2023-11-14T20:18:06Z New Revision: d2fd1106f6879c410b6a807133090866e6c3a243 URL: https://github.com/llvm/llvm-project/commit/d2fd1106f6879c410b6a807133090866e6c3a243 DIFF: https://github.com/llvm/llvm-project/commit/d2fd1106f6879c410b6a807133090866e6c3a243.diff LOG: Reapply "[clang] Support fixed point types in C++ (#67750)" (#69963) This reverts commit d593f6cb387fe86aad47d3b763abcf0048e5b568. Added: clang/test/CodeGenCXX/fixed-point-mangle.cpp Modified: clang/include/clang/Driver/Options.td clang/lib/AST/ItaniumMangle.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Parse/ParseTentative.cpp clang/test/Frontend/fixed_point_errors.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d1b67a448b2a59b..e63ee583f6b30c5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2117,7 +2117,7 @@ defm fixed_point : BoolFOption<"fixed-point", LangOpts<"FixedPoint">, DefaultFalse, PosFlag, NegFlag, - BothFlags<[], [ClangOption], " fixed point types">>, ShouldParseIf; + BothFlags<[], [ClangOption], " fixed point types">>; defm cxx_static_destructors : BoolFOption<"c++-static-destructors", LangOpts<"RegisterStaticDestructors">, DefaultTrue, NegFlag _ # ISO/IEC TS 18661 binary floating point - // type _FloatN (N bits); + // ::= DF _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits); // ::= Di # char32_t // ::= Ds # char16_t // ::= Dn # std::nullptr_t (i.e., decltype(nullptr)) + // ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum + // ::= [DS] DR # N1169 fixed-point [_Sat] T _Fract // ::= u # vendor extended type + // + // + // ::= s # short + // ::= t # unsigned short + // ::= i # plain + // ::= j # unsigned + // ::= l # long + // ::= m # unsigned long std::string type_name; // Normalize integer types as vendor extended types: // ui @@ -3201,30 +3210,77 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { Out << "DF16_"; break; case BuiltinType::ShortAccum: +Out << "DAs"; +break; case BuiltinType::Accum: +Out << "DAi"; +break; case BuiltinType::LongAccum: +Out << "DAl"; +break; case BuiltinType::UShortAccum: +Out << "DAt"; +break; case BuiltinType::UAccum: +Out << "DAj"; +break; case BuiltinType::ULongAccum: +Out << "DAm"; +break; case BuiltinType::ShortFract: +Out << "DRs"; +break; case BuiltinType::Fract: +Out << "DRi"; +break; case BuiltinType::LongFract: +Out << "DRl"; +break; case BuiltinType::UShortFract: +Out << "DRt"; +break; case BuiltinType::UFract: +Out << "DRj"; +break; case BuiltinType::ULongFract: +Out << "DRm"; +break; case BuiltinType::SatShortAccum: +Out << "DSDAs"; +break; case BuiltinType::SatAccum: +Out << "DSDAi"; +break; case BuiltinType::SatLongAccum: +Out << "DSDAl"; +break; case BuiltinType::SatUShortAccum: +Out << "DSDAt"; +break; case BuiltinType::SatUAccum: +Out << "DSDAj"; +break; case BuiltinType::SatULongAccum: +Out << "DSDAm"; +break; case BuiltinType::SatShortFract: +Out << "DSDRs"; +break; case BuiltinType::SatFract: +Out << "DSDRi"; +break; case BuiltinType::SatLongFract: +Out << "DSDRl"; +break; case BuiltinType::SatUShortFract: +Out << "DSDRt"; +break; case BuiltinType::SatUFract: +Out << "DSDRj"; +break; case BuiltinType::SatULongFract: -llvm_unreachable("Fixed point types are disabled for c++"); +Out << "DSDRm"; +break; case BuiltinType::Half: Out << "Dh"; break; diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 9e05394e8d07dd6..897810557976151 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1577,6 +1577,9 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind, case tok::kw_typename: case tok::kw_typeof: case tok::kw___vector: + case tok::kw__Accum: + case tok::kw__Fract: + case tok::kw__Sat: #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" { diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 99b4931004546c1..79db094e098f8e6 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -2354,6 +2354,15 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { case tok::kw_bool: DS.SetType
[clang-tools-extra] 474c873 - Revert "[llvm] cmake config groundwork to have ZSTD in LLVM"
Author: Leonard Chan Date: 2022-07-08T13:48:05-07:00 New Revision: 474c873148b1441f1dd7a2b269441a1b20e30aa2 URL: https://github.com/llvm/llvm-project/commit/474c873148b1441f1dd7a2b269441a1b20e30aa2 DIFF: https://github.com/llvm/llvm-project/commit/474c873148b1441f1dd7a2b269441a1b20e30aa2.diff LOG: Revert "[llvm] cmake config groundwork to have ZSTD in LLVM" This reverts commit f07caf20b9d35e45501c9d5d903fa182b3bdb95a which seems to break upstream https://lab.llvm.org/buildbot/#/builders/109/builds/42253. Added: Modified: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/test/lit.cfg.py clang-tools-extra/clangd/test/lit.site.cfg.py.in clang/test/CMakeLists.txt clang/test/lit.site.cfg.py.in compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh compiler-rt/test/lit.common.cfg.py compiler-rt/test/lit.common.configured.in flang/CMakeLists.txt lld/ELF/CMakeLists.txt lld/test/lit.site.cfg.py.in lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt lldb/test/Shell/lit.site.cfg.py.in llvm/CMakeLists.txt llvm/cmake/config-ix.cmake llvm/cmake/modules/LLVMConfig.cmake.in llvm/include/llvm/Config/llvm-config.h.cmake llvm/test/lit.site.cfg.py.in utils/bazel/llvm_configs/llvm-config.h.cmake Removed: llvm/cmake/modules/FindZSTD.cmake diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt index bda9d8c1585eb..7cfbd6f95750e 100644 --- a/clang-tools-extra/clangd/CMakeLists.txt +++ b/clang-tools-extra/clangd/CMakeLists.txt @@ -29,7 +29,6 @@ llvm_canonicalize_cmake_booleans( CLANGD_MALLOC_TRIM CLANGD_TIDY_CHECKS LLVM_ENABLE_ZLIB - LLVM_ENABLE_ZSTD ) configure_file( diff --git a/clang-tools-extra/clangd/test/lit.cfg.py b/clang-tools-extra/clangd/test/lit.cfg.py index 8a31cd54de8ee..0f3d8b310b290 100644 --- a/clang-tools-extra/clangd/test/lit.cfg.py +++ b/clang-tools-extra/clangd/test/lit.cfg.py @@ -36,6 +36,3 @@ def calculate_arch_features(arch_string): if config.have_zlib: config.available_features.add('zlib') - -if config.have_zstd: - config.available_features.add('zstd') diff --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in b/clang-tools-extra/clangd/test/lit.site.cfg.py.in index 83bfe322a9adc..20caa72af3da1 100644 --- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in +++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in @@ -17,7 +17,6 @@ config.clangd_build_xpc = @CLANGD_BUILD_XPC@ config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@ config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@ config.have_zlib = @LLVM_ENABLE_ZLIB@ -config.have_zstd = @LLVM_ENABLE_ZSTD@ # Delegate logic to lit.cfg.py. lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 5af7c30835996..5b604b2a3eeba 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -11,7 +11,6 @@ llvm_canonicalize_cmake_booleans( CLANG_SPAWN_CC1 ENABLE_BACKTRACES LLVM_ENABLE_ZLIB - LLVM_ENABLE_ZSTD LLVM_ENABLE_PER_TARGET_RUNTIME_DIR LLVM_ENABLE_THREADS LLVM_WITH_Z3 diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index eb1013059e0ea..8a9849fe4549d 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -21,7 +21,6 @@ config.host_cc = "@CMAKE_C_COMPILER@" config.host_cxx = "@CMAKE_CXX_COMPILER@" config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.have_zlib = @LLVM_ENABLE_ZLIB@ -config.have_zstd = @LLVM_ENABLE_ZSTD@ config.clang_arcmt = @CLANG_ENABLE_ARCMT@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@ diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh index f4f242feae013..b6f731566c19b 100755 --- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh +++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh @@ -140,7 +140,6 @@ if [[ ! -d ${LLVM_BUILD} ]]; then -DLLVM_TABLEGEN=$TBLGEN \ -DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}" \ -DLLVM_ENABLE_ZLIB=ON \ --DLLVM_ENABLE_ZSTD=ON \ -DLLVM_ENABLE_TERMINFO=OFF \ -DLLVM_ENABLE_THREADS=OFF \ $LLVM_SRC diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index a38c1308ecf43..62a73dd313968 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -217,9 +217,6 @@ def get_path_from_clang(args, allow_failure): if config.have_zlib == "1": config.available_features.add("zlib") - -if config.have_zstd == "1": - config.available_features.add("zstd") # Use ugly construction to explicitly prohibit "clang"
[clang] 33171df - Revert "[clang][Darwin] Always set the default C++ Standard Library to libc++"
Author: Leonard Chan Date: 2022-08-04T22:56:32Z New Revision: 33171df9cc7f6560dea7b0b162ab51ff97417468 URL: https://github.com/llvm/llvm-project/commit/33171df9cc7f6560dea7b0b162ab51ff97417468 DIFF: https://github.com/llvm/llvm-project/commit/33171df9cc7f6560dea7b0b162ab51ff97417468.diff LOG: Revert "[clang][Darwin] Always set the default C++ Standard Library to libc++" This reverts commit c5ccb78ade8136134e0ca9dde64de97f913f0f8c. We're seeing darwin-stdlib.cpp fail on our linux, mac, and windows builders: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8806821020552676065/overview Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/darwin-iphone-defaults.m clang/test/Driver/darwin-stdlib.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 7e3fc625d8c85..bada811daadfe 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -896,7 +896,12 @@ types::ID MachO::LookupTypeForExtension(StringRef Ext) const { bool MachO::HasNativeLLVMSupport() const { return true; } ToolChain::CXXStdlibType Darwin::GetDefaultCXXStdlibType() const { - // Always use libc++ by default + // Use libstdc++ on old targets (OSX < 10.9 and iOS < 7) + if ((isTargetMacOSBased() && isMacosxVersionLT(10, 9)) || + (isTargetIOSBased() && isIPhoneOSVersionLT(7, 0))) +return ToolChain::CST_Libstdcxx; + + // On all other targets, use libc++ return ToolChain::CST_Libcxx; } diff --git a/clang/test/Driver/darwin-iphone-defaults.m b/clang/test/Driver/darwin-iphone-defaults.m index 79d3bc848faf5..ec9507fd091a3 100644 --- a/clang/test/Driver/darwin-iphone-defaults.m +++ b/clang/test/Driver/darwin-iphone-defaults.m @@ -1,4 +1,4 @@ -// RUN: %clang -target i386-apple-darwin -miphoneos-version-min=5.0 -arch armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s +// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -stdlib=platform -flto -S -o - %s | FileCheck %s // CHECK: @f0() [[F0:#[0-9]+]] // CHECK: @__f0_block_invoke diff --git a/clang/test/Driver/darwin-stdlib.cpp b/clang/test/Driver/darwin-stdlib.cpp index d15eb1932e3ca..0538a42ecd5cc 100644 --- a/clang/test/Driver/darwin-stdlib.cpp +++ b/clang/test/Driver/darwin-stdlib.cpp @@ -2,10 +2,13 @@ // than the platform default. (see https://llvm.org/bugs/show_bug.cgi?id=30548) // XFAIL: default-cxx-stdlib-set -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s -// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.8 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=6.1 -Wno-stdlibcxx-not-found %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX +// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX -// CHECK: "-stdlib=libc++" -// CHECK-NOT: "-stdlib=libstdc++" +// CHECK-LIBCXX: "-stdlib=libc++" +// CHECK-LIBSTDCXX-NOT: -stdlib=libc++ +// CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4ac58b6 - [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check
Author: Leonard Chan Date: 2022-02-08T10:53:22-08:00 New Revision: 4ac58b61022d128d60ffea06c20611b8eaf8601a URL: https://github.com/llvm/llvm-project/commit/4ac58b61022d128d60ffea06c20611b8eaf8601a DIFF: https://github.com/llvm/llvm-project/commit/4ac58b61022d128d60ffea06c20611b8eaf8601a.diff LOG: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check Differential Revision: https://reviews.llvm.org/D119201 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 8addee22a2bd..40364d23c559 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -771,11 +771,6 @@ static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) { void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) { - // Fuchsia never needs these. Any sanitizer runtimes with system - // dependencies use the `.deplibs` feature instead. - if (TC.getTriple().isOSFuchsia()) -return; - // Force linking against the system libraries sanitizers depends on // (see PR15823 why this is necessary). CmdArgs.push_back(getAsNeededOption(TC, false)); diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index bd1600d060c8..9e0b259dfcae 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -127,10 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA, D.getLTOMode() == LTOK_Thin); } - bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); - bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); - ToolChain.addProfileRTLibs(Args, CmdArgs); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, options::OPT_r)) { @@ -153,11 +150,14 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } -if (NeedsSanitizerDeps) - linkSanitizerRuntimeDeps(ToolChain, CmdArgs); +// Note that Fuchsia never needs to link in sanitizer runtime deps. Any +// sanitizer runtimes with system dependencies use the `.deplibs` feature +// instead. +addSanitizerRuntimes(ToolChain, Args, CmdArgs); -if (NeedsXRayDeps) - linkXRayRuntimeDeps(ToolChain, CmdArgs); +addXRayRuntime(ToolChain, Args, CmdArgs); + +ToolChain.addProfileRTLibs(Args, CmdArgs); AddRunTimeLibs(ToolChain, D, CmdArgs, Args); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r369442 - [NewPM] Run ubsan-coroutines test under the legacy pass manager only
Author: leonardchan Date: Tue Aug 20 13:55:36 2019 New Revision: 369442 URL: http://llvm.org/viewvc/llvm-project?rev=369442&view=rev Log: [NewPM] Run ubsan-coroutines test under the legacy pass manager only The passes that lower the llvm.coro.* instrinsics have not yet been ported, so only run under the legacy PM for now. See https://bugs.llvm.org/show_bug.cgi?id=42867 Differential Revision: https://reviews.llvm.org/D66493 Modified: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Modified: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp?rev=369442&r1=369441&r2=369442&view=diff == --- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp (original) +++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Tue Aug 20 13:55:36 2019 @@ -1,6 +1,8 @@ // This test merely verifies that emitting the object file does not cause a // crash when the LLVM coroutines passes are run. -// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o +// PR42867: Disable this test for the new PM since the passes that lower the +// llvm.coro.* intrinsics have not yet been ported. +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a -fsanitize=null %s -o %t.o namespace std::experimental { template struct coroutine_traits { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r369550 - [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager
Author: leonardchan Date: Wed Aug 21 10:24:14 2019 New Revision: 369550 URL: http://llvm.org/viewvc/llvm-project?rev=369550&view=rev Log: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager Match the behavior of D65009 under the new pass manager. This addresses the test clang/test/CodeGen/split-lto-unit.c when running under the new PM. Differential Revision: https://reviews.llvm.org/D66488 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/split-lto-unit.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=369550&r1=369549&r2=369550&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Aug 21 10:24:14 2019 @@ -1291,7 +1291,7 @@ void EmitAssemblyHelper::EmitAssemblyWit if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit", - CodeGenOpts.EnableSplitLTOUnit); + uint32_t(1)); } MPM.addPass( BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary)); Modified: cfe/trunk/test/CodeGen/split-lto-unit.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-lto-unit.c?rev=369550&r1=369549&r2=369550&view=diff == --- cfe/trunk/test/CodeGen/split-lto-unit.c (original) +++ cfe/trunk/test/CodeGen/split-lto-unit.c Wed Aug 21 10:24:14 2019 @@ -7,6 +7,7 @@ // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1} // // ; Check that regular LTO has EnableSplitLTOUnit = 1 -// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT +// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT +// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT int main() {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r370971 - [NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes
Author: leonardchan Date: Wed Sep 4 13:30:29 2019 New Revision: 370971 URL: http://llvm.org/viewvc/llvm-project?rev=370971&view=rev Log: [NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes This patch merges the sancov module and funciton passes into one module pass. The reason for this is because we ran into an out of memory error when attempting to run asan fuzzer on some protobufs (pc.cc files). I traced the OOM error to the destructor of SanitizerCoverage where we only call appendTo[Compiler]Used which calls appendToUsedList. I'm not sure where precisely in appendToUsedList causes the OOM, but I am able to confirm that it's calling this function *repeatedly* that causes the OOM. (I hacked sancov a bit such that I can still create and destroy a new sancov on every function run, but only call appendToUsedList after all functions in the module have finished. This passes, but when I make it such that appendToUsedList is called on every sancov destruction, we hit OOM.) I don't think the OOM is from just adding to the SmallSet and SmallVector inside appendToUsedList since in either case for a given module, they'll have the same max size. I suspect that when the existing llvm.compiler.used global is erased, the memory behind it isn't freed. I could be wrong on this though. This patch works around the OOM issue by just calling appendToUsedList at the end of every module run instead of function run. The same amount of constants still get added to llvm.compiler.used, abd we make the pass usage and logic simpler by not having any inter-pass dependencies. Differential Revision: https://reviews.llvm.org/D66988 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=370971&r1=370970&r2=370971&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Sep 4 13:30:29 2019 @@ -224,7 +224,6 @@ static void addSanitizerCoveragePass(con const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); auto Opts = getSancovOptsFromCGOpts(CGOpts); PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts)); - PM.add(createSanitizerCoverageLegacyPassPass(Opts)); } // Check if ASan should use GC-friendly instrumentation for globals. @@ -1159,11 +1158,6 @@ void EmitAssemblyHelper::EmitAssemblyWit [SancovOpts](ModulePassManager &MPM) { MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); }); -PB.registerOptimizerLastEPCallback( -[SancovOpts](FunctionPassManager &FPM, - PassBuilder::OptimizationLevel Level) { - FPM.addPass(SanitizerCoveragePass(SancovOpts)); -}); } // Register callbacks to schedule sanitizer passes at the appropriate part of @@ -1249,8 +1243,6 @@ void EmitAssemblyHelper::EmitAssemblyWit CodeGenOpts.SanitizeCoverageTraceCmp) { auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); -MPM.addPass(createModuleToFunctionPassAdaptor( -SanitizerCoveragePass(SancovOpts))); } addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r371326 - [NewPM][Sancov] Create the Sancov Pass after building the pipelines
Author: leonardchan Date: Sun Sep 8 00:30:17 2019 New Revision: 371326 URL: http://llvm.org/viewvc/llvm-project?rev=371326&view=rev Log: [NewPM][Sancov] Create the Sancov Pass after building the pipelines We're running into linker errors from missing sancov sections: ``` ld.lld: error: relocation refers to a discarded section: __sancov_guards >>> defined in >>> user-arm64-ubsan-sancov-full.shlib/obj/third_party/ulib/scudo/scudo.wrappers_c.cc.o >>> referenced by common.h:26 (../../zircon/third_party/ulib/scudo/common.h:26) ... many other references ``` I believe this is due to a pass in the default pipeline that somehow discards these sections. The ModuleSanitizerCoveragePass was initially added at the start of the pipeline. This now adds it to the end of the pipeline for optimized and unoptimized builds. Differential Revision: https://reviews.llvm.org/D67323 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=371326&r1=371325&r2=371326&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sun Sep 8 00:30:17 2019 @@ -1149,16 +1149,6 @@ void EmitAssemblyHelper::EmitAssemblyWit EntryExitInstrumenterPass(/*PostInlining=*/false))); }); - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); -PB.registerPipelineStartEPCallback( -[SancovOpts](ModulePassManager &MPM) { - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); -}); - } - // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1226,6 +1216,13 @@ void EmitAssemblyHelper::EmitAssemblyWit } } +if (CodeGenOpts.SanitizeCoverageType || +CodeGenOpts.SanitizeCoverageIndirectCalls || +CodeGenOpts.SanitizeCoverageTraceCmp) { + auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); + MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); +} + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); MPM.addPass(HWAddressSanitizerPass( @@ -1237,13 +1234,6 @@ void EmitAssemblyHelper::EmitAssemblyWit } if (CodeGenOpts.OptimizationLevel == 0) { - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { -auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); -MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); - } - addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 15d94a7 - Revert "Canonicalize declaration pointers when forming APValues."
Author: Leonard Chan Date: 2020-09-22T17:40:53-07:00 New Revision: 15d94a7d0f8f0d6b3b5308fff51b286957e45650 URL: https://github.com/llvm/llvm-project/commit/15d94a7d0f8f0d6b3b5308fff51b286957e45650 DIFF: https://github.com/llvm/llvm-project/commit/15d94a7d0f8f0d6b3b5308fff51b286957e45650.diff LOG: Revert "Canonicalize declaration pointers when forming APValues." This reverts commit 905b9ca26c94fa86339451a528cedde5004fc1bb. Reverting because this strips `weak` attributes off function declarations, leading to the linker error we see at https://ci.chromium.org/p/fuchsia/builders/ci/clang_toolchain.fuchsia-arm64-debug-subbuild/b8868932035091473008. See https://reviews.llvm.org/rG905b9ca26c94 for reproducer details. Added: Modified: clang/include/clang/AST/APValue.h clang/lib/AST/APValue.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclBase.cpp clang/lib/AST/ExprConstant.cpp clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp clang/test/OpenMP/ordered_messages.cpp Removed: diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h index 6307f8a92e5a..5103cfa8604e 100644 --- a/clang/include/clang/AST/APValue.h +++ b/clang/include/clang/AST/APValue.h @@ -174,7 +174,6 @@ class APValue { return !(LHS == RHS); } friend llvm::hash_code hash_value(const LValueBase &Base); -friend struct llvm::DenseMapInfo; private: PtrTy Ptr; @@ -202,7 +201,8 @@ class APValue { public: LValuePathEntry() : Value() {} -LValuePathEntry(BaseOrMemberType BaseOrMember); +LValuePathEntry(BaseOrMemberType BaseOrMember) +: Value{reinterpret_cast(BaseOrMember.getOpaqueValue())} {} static LValuePathEntry ArrayIndex(uint64_t Index) { LValuePathEntry Result; Result.Value = Index; diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index 32d3ff7ce1d0..08ae0ff3c67d 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -38,7 +38,7 @@ static_assert( "Type is insufficiently aligned"); APValue::LValueBase::LValueBase(const ValueDecl *P, unsigned I, unsigned V) -: Ptr(P ? cast(P->getCanonicalDecl()) : nullptr), Local{I, V} {} +: Ptr(P), Local{I, V} {} APValue::LValueBase::LValueBase(const Expr *P, unsigned I, unsigned V) : Ptr(P), Local{I, V} {} @@ -82,19 +82,13 @@ bool operator==(const APValue::LValueBase &LHS, const APValue::LValueBase &RHS) { if (LHS.Ptr != RHS.Ptr) return false; - if (LHS.is() || LHS.is()) + if (LHS.is()) return true; return LHS.Local.CallIndex == RHS.Local.CallIndex && LHS.Local.Version == RHS.Local.Version; } } -APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType BaseOrMember) { - if (const Decl *D = BaseOrMember.getPointer()) -BaseOrMember.setPointer(D->getCanonicalDecl()); - Value = reinterpret_cast(BaseOrMember.getOpaqueValue()); -} - namespace { struct LVBase { APValue::LValueBase Base; @@ -119,16 +113,14 @@ APValue::LValueBase::operator bool () const { clang::APValue::LValueBase llvm::DenseMapInfo::getEmptyKey() { - clang::APValue::LValueBase B; - B.Ptr = DenseMapInfo::getEmptyKey(); - return B; + return clang::APValue::LValueBase( + DenseMapInfo::getEmptyKey()); } clang::APValue::LValueBase llvm::DenseMapInfo::getTombstoneKey() { - clang::APValue::LValueBase B; - B.Ptr = DenseMapInfo::getTombstoneKey(); - return B; + return clang::APValue::LValueBase( + DenseMapInfo::getTombstoneKey()); } namespace clang { @@ -781,10 +773,8 @@ void APValue::MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember, assert(isAbsent() && "Bad state change"); MemberPointerData *MPD = new ((void*)(char*)Data.buffer) MemberPointerData; Kind = MemberPointer; - MPD->MemberAndIsDerivedMember.setPointer( - Member ? cast(Member->getCanonicalDecl()) : nullptr); + MPD->MemberAndIsDerivedMember.setPointer(Member); MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember); MPD->resizePath(Path.size()); - for (unsigned I = 0; I != Path.size(); ++I) -MPD->getPath()[I] = Path[I]->getCanonicalDecl(); + memcpy(MPD->getPath(), Path.data(), Path.size()*sizeof(const CXXRecordDecl*)); } diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index ae38e3dd2a72..0ee1399d42df 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -4686,7 +4686,7 @@ char *Buffer = new (getASTContext(), 1) char[Name.size() + 1]; void ValueDecl::anchor() {} bool ValueDecl::isWeak() const { - for (const auto *I : getMostRecentDecl()->attrs()) + for (const auto *I : attrs()) if (isa(I) || isa(I)) return true; diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index ab2b55c0762e..f4314d0bd961 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -720,7 +720,7 @@ bool Decl::isWeakImporte
Re: [PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes
Thanks for looking into it. We have that commit but it still seems to be failing for us with the same error. On Tue, Sep 29, 2020 at 12:58 AM Serge Pavlov wrote: > Hi! > > This issue must be fixed by: https://reviews.llvm.org/rGf91b9c0f9858 > Do you have recent changes from the trunk? > > Thanks, > --Serge > > > On Tue, Sep 29, 2020 at 4:22 AM Leonard Chan via Phabricator < > revi...@reviews.llvm.org> wrote: > >> leonardchan added a comment. >> >> Hi! It looks like this is causing a test failure on our aach64 builders ( >> https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-arm64/b8868095822628984976? >> ): >> >> [1113/1114] Running the Clang regression tests >> llvm-lit: >> /b/s/w/ir/k/staging/llvm_build/bin/../../../llvm-project/llvm/utils/lit/lit/llvm/config.py:379: >> note: using clang: /b/s/w/ir/k/staging/llvm_build/bin/clang >> -- Testing: 26708 tests, 256 workers -- >> Testing: >> FAIL: Clang :: AST/const-fpfeatures-diag.c (269 of 26708) >> TEST 'Clang :: AST/const-fpfeatures-diag.c' FAILED >> >> Script: >> -- >> : 'RUN: at line 1'; /b/s/w/ir/k/staging/llvm_build/bin/clang -cc1 >> -internal-isystem /b/s/w/ir/k/staging/llvm_build/lib/clang/12.0.0/include >> -nostdsysteminc -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas >> /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c >> -- >> Exit Code: 1 >> >> Command Output (stderr): >> -- >> error: 'error' diagnostics expected but not seen: >> File /b/s/w/ir/k/llvm-project/clang/test/AST/const-fpfeatures-diag.c >> Line 8: initializer element is not a compile-time constant >> error: 'warning' diagnostics seen but not expected: >> (frontend): overriding currently unsupported use of floating point >> exceptions on this target >> 2 errors generated. >> >> -- >> >> >> Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. >> >> Failed Tests (1): >> Clang :: AST/const-fpfeatures-diag.c >> >> Would you mind taking a look and sending out a fix? Thanks. >> >> >> Repository: >> rG LLVM Github Monorepo >> >> CHANGES SINCE LAST ACTION >> https://reviews.llvm.org/D87822/new/ >> >> https://reviews.llvm.org/D87822 >> >> ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64c0792 - [clang][feature] Add cxx_abi_relative_vtable feature
Author: Leonard Chan Date: 2020-10-08T10:30:54-07:00 New Revision: 64c0792946b792839b2f39e4e208fdd7398aaea0 URL: https://github.com/llvm/llvm-project/commit/64c0792946b792839b2f39e4e208fdd7398aaea0 DIFF: https://github.com/llvm/llvm-project/commit/64c0792946b792839b2f39e4e208fdd7398aaea0.diff LOG: [clang][feature] Add cxx_abi_relative_vtable feature This will be enabled if relative vtables is enabled. Differential revision: https://reviews.llvm.org/D85924 Added: clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp Modified: clang/include/clang/Basic/Features.def Removed: diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index 999bcb7e2e29..302c56763c39 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -256,5 +256,7 @@ EXTENSION(gnu_asm, LangOpts.GNUAsm) EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm) EXTENSION(matrix_types, LangOpts.MatrixTypes) +FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables) + #undef EXTENSION #undef FEATURE diff --git a/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp new file mode 100644 index ..d0f0c27b09d3 --- /dev/null +++ b/clang/test/Lexer/has_feature_cxx_abi_relative_vtable.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE +// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -fexperimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=RELATIVE-VTABLE +// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c++ -fno-experimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE +// RUN: %clang_cc1 -E %s -triple x86_64-linux-gnu -x c -fexperimental-relative-c++-abi-vtables -o - | FileCheck %s --check-prefix=NO-RELATIVE-VTABLE + +#if __has_feature(cxx_abi_relative_vtable) +int has_relative_vtable(); +#else +int has_no_relative_vtable(); +#endif + +// RELATIVE-VTABLE: has_relative_vtable +// NO-RELATIVE-VTABLE: has_no_relative_vtable ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 683b308 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use
Author: Leonard Chan Date: 2020-10-14T12:31:21-07:00 New Revision: 683b308c07bf827255fe1403056413f790e03729 URL: https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729 DIFF: https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729.diff LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use This implements the flag proposed in RFC http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html. The goal is to add a way to override the default target C++ ABI through a compiler flag. This makes it easier to test and transition between different C++ ABIs through compile flags rather than build flags. In this patch: - Store `-fc++-abi=` in a LangOpt. This isn't stored in a CodeGenOpt because there are instances outside of codegen where Clang needs to know what the ABI is (particularly through ASTContext::createCXXABI), and we should be able to override the target default if the flag is provided at that point. - Expose the existing ABIs in TargetCXXABI as values that can be passed through this flag. - Create a .def file for these ABIs to make it easier to check flag values. - Add an error for diagnosing bad ABI flag values. Differential Revision: https://reviews.llvm.org/D85802 Added: clang/include/clang/Basic/TargetCXXABI.def clang/test/Frontend/invalid-cxx-abi.cpp Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Basic/TargetCXXABI.h clang/include/clang/Driver/Options.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 3f4079e2569b..e5c80866a0a9 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -39,6 +39,7 @@ #include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/XRayLists.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" @@ -697,6 +698,11 @@ class ASTContext : public RefCountedBase { return FullSourceLoc(Loc,SourceMgr); } + /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden + /// at compile time with `-fc++-abi=`. If this is not provided, we instead use + /// the default ABI set by the target. + TargetCXXABI::Kind getCXXABIKind() const; + /// All comments in this translation unit. RawCommentList Comments; diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 29bc19e5a84e..f1b3d4d9087e 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -524,4 +524,6 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognize def err_drv_invalid_sve_vector_bits : Error< "'-msve-vector-bits' is not supported without SVE enabled">; + +def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">; } diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 84d25c359c55..147fab614308 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -18,6 +18,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" +#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/Visibility.h" #include "llvm/ADT/FloatingPointMode.h" #include "llvm/ADT/StringRef.h" @@ -294,6 +295,10 @@ class LangOptions : public LangOptionsBase { /// host code generation. std::string OMPHostIRFile; + /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=. + /// This overrides the default ABI used by the target. + llvm::Optional CXXABI; + /// Indicates whether the front-end is explicitly told that the /// input is a header file (i.e. -x c-header). bool IsHeaderFile = false; diff --git a/clang/include/clang/Basic/TargetCXXABI.def b/clang/include/clang/Basic/TargetCXXABI.def new file mode 100644 index ..0ae0bb555f60 --- /dev/null +++ b/clang/include/clang/Basic/TargetCXXABI.def @@ -0,0 +1,129 @@ +//===--- TargetCXXABI.def - Target C++ ABI database --- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This f
[clang] 8487bfd - [clang][NFC] Change diagnostic to start with lowercase letter
Author: Leonard Chan Date: 2020-10-14T15:48:29-07:00 New Revision: 8487bfd4e9ae186f9f588ef989d27a96cc2438c9 URL: https://github.com/llvm/llvm-project/commit/8487bfd4e9ae186f9f588ef989d27a96cc2438c9 DIFF: https://github.com/llvm/llvm-project/commit/8487bfd4e9ae186f9f588ef989d27a96cc2438c9.diff LOG: [clang][NFC] Change diagnostic to start with lowercase letter Added: Modified: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/test/Frontend/invalid-cxx-abi.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index f1b3d4d9087e..d87983ef5249 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -525,5 +525,5 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognize def err_drv_invalid_sve_vector_bits : Error< "'-msve-vector-bits' is not supported without SVE enabled">; -def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">; +def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">; } diff --git a/clang/test/Frontend/invalid-cxx-abi.cpp b/clang/test/Frontend/invalid-cxx-abi.cpp index 20c6d7bde22c..02a5f3a4e368 100644 --- a/clang/test/Frontend/invalid-cxx-abi.cpp +++ b/clang/test/Frontend/invalid-cxx-abi.cpp @@ -12,5 +12,5 @@ // RUN: not %clang_cc1 -fc++-abi=InvalidABI %s 2>&1 | FileCheck %s -check-prefix=INVALID // RUN: not %clang_cc1 -fc++-abi=Fuchsia %s 2>&1 | FileCheck %s -check-prefix=CASE-SENSITIVE -// INVALID: error: Invalid C++ ABI name 'InvalidABI' -// CASE-SENSITIVE: error: Invalid C++ ABI name 'Fuchsia' +// INVALID: error: invalid C++ ABI name 'InvalidABI' +// CASE-SENSITIVE: error: invalid C++ ABI name 'Fuchsia' ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang] 683b308 - [clang] Add -fc++-abi= flag for specifying which C++ ABI to use
Updated with 8487bfd4e9ae186f9f588ef989d27a96cc2438c9 On Wed, Oct 14, 2020 at 1:53 PM Richard Smith wrote: > On Wed, 14 Oct 2020 at 12:31, Leonard Chan via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> >> Author: Leonard Chan >> Date: 2020-10-14T12:31:21-07:00 >> New Revision: 683b308c07bf827255fe1403056413f790e03729 >> >> URL: >> https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729 >> DIFF: >> https://github.com/llvm/llvm-project/commit/683b308c07bf827255fe1403056413f790e03729.diff >> >> LOG: [clang] Add -fc++-abi= flag for specifying which C++ ABI to use >> >> This implements the flag proposed in RFC >> http://lists.llvm.org/pipermail/cfe-dev/2020-August/066437.html. >> >> The goal is to add a way to override the default target C++ ABI through >> a compiler flag. This makes it easier to test and transition between >> different >> C++ ABIs through compile flags rather than build flags. >> >> In this patch: >> - Store `-fc++-abi=` in a LangOpt. This isn't stored in a >> CodeGenOpt because there are instances outside of codegen where Clang >> needs to know what the ABI is (particularly through >> ASTContext::createCXXABI), and we should be able to override the >> target default if the flag is provided at that point. >> - Expose the existing ABIs in TargetCXXABI as values that can be passed >> through this flag. >> - Create a .def file for these ABIs to make it easier to check flag >> values. >> - Add an error for diagnosing bad ABI flag values. >> >> Differential Revision: https://reviews.llvm.org/D85802 >> >> Added: >> clang/include/clang/Basic/TargetCXXABI.def >> clang/test/Frontend/invalid-cxx-abi.cpp >> >> Modified: >> clang/include/clang/AST/ASTContext.h >> clang/include/clang/Basic/DiagnosticDriverKinds.td >> clang/include/clang/Basic/LangOptions.h >> clang/include/clang/Basic/TargetCXXABI.h >> clang/include/clang/Driver/Options.td >> clang/lib/AST/ASTContext.cpp >> clang/lib/CodeGen/CodeGenModule.cpp >> clang/lib/CodeGen/ItaniumCXXABI.cpp >> clang/lib/Driver/ToolChains/Clang.cpp >> clang/lib/Frontend/CompilerInvocation.cpp >> >> Removed: >> >> >> >> >> >> diff --git a/clang/include/clang/AST/ASTContext.h >> b/clang/include/clang/AST/ASTContext.h >> index 3f4079e2569b..e5c80866a0a9 100644 >> --- a/clang/include/clang/AST/ASTContext.h >> +++ b/clang/include/clang/AST/ASTContext.h >> @@ -39,6 +39,7 @@ >> #include "clang/Basic/SanitizerBlacklist.h" >> #include "clang/Basic/SourceLocation.h" >> #include "clang/Basic/Specifiers.h" >> +#include "clang/Basic/TargetCXXABI.h" >> #include "clang/Basic/XRayLists.h" >> #include "llvm/ADT/APSInt.h" >> #include "llvm/ADT/ArrayRef.h" >> @@ -697,6 +698,11 @@ class ASTContext : public RefCountedBase >> { >> return FullSourceLoc(Loc,SourceMgr); >>} >> >> + /// Return the C++ ABI kind that should be used. The C++ ABI can be >> overriden >> + /// at compile time with `-fc++-abi=`. If this is not provided, we >> instead use >> + /// the default ABI set by the target. >> + TargetCXXABI::Kind getCXXABIKind() const; >> + >>/// All comments in this translation unit. >>RawCommentList Comments; >> >> >> diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td >> b/clang/include/clang/Basic/DiagnosticDriverKinds.td >> index 29bc19e5a84e..f1b3d4d9087e 100644 >> --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td >> +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td >> @@ -524,4 +524,6 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE >> setting %0 is not recognize >> >> def err_drv_invalid_sve_vector_bits : Error< >>"'-msve-vector-bits' is not supported without SVE enabled">; >> + >> +def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">; >> > > Diagnostics should start with a lowercase letter. > > >> } >> >> diff --git a/clang/include/clang/Basic/LangOptions.h >> b/clang/include/clang/Basic/LangOptions.h >> index 84d25c359c55..147fab614308 100644 >> --- a/clang/include/clang/Basic/LangOptions.h >> +++ b/clang/include/clang/Basic/LangOptions.h
[clang] 79829a4 - Revert "[clang] Add -fc++-abi= flag for specifying which C++ ABI to use"
Author: Leonard Chan Date: 2020-10-15T14:24:38-07:00 New Revision: 79829a47040512fe54001db839ac59146ca55aec URL: https://github.com/llvm/llvm-project/commit/79829a47040512fe54001db839ac59146ca55aec DIFF: https://github.com/llvm/llvm-project/commit/79829a47040512fe54001db839ac59146ca55aec.diff LOG: Revert "[clang] Add -fc++-abi= flag for specifying which C++ ABI to use" This reverts commits 683b308c07bf827255fe1403056413f790e03729 and 8487bfd4e9ae186f9f588ef989d27a96cc2438c9. We will go for a more restricted approach that does not give freedom to everyone to change ABIs on whichever platform. See the discussion on https://reviews.llvm.org/D85802. Added: Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Basic/TargetCXXABI.h clang/include/clang/Driver/Options.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp Removed: clang/include/clang/Basic/TargetCXXABI.def clang/test/Frontend/invalid-cxx-abi.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index e5c80866a0a9..3f4079e2569b 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -39,7 +39,6 @@ #include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/XRayLists.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" @@ -698,11 +697,6 @@ class ASTContext : public RefCountedBase { return FullSourceLoc(Loc,SourceMgr); } - /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden - /// at compile time with `-fc++-abi=`. If this is not provided, we instead use - /// the default ABI set by the target. - TargetCXXABI::Kind getCXXABIKind() const; - /// All comments in this translation unit. RawCommentList Comments; diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index d87983ef5249..29bc19e5a84e 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -524,6 +524,4 @@ def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognize def err_drv_invalid_sve_vector_bits : Error< "'-msve-vector-bits' is not supported without SVE enabled">; - -def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">; } diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 147fab614308..84d25c359c55 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -18,7 +18,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" -#include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/Visibility.h" #include "llvm/ADT/FloatingPointMode.h" #include "llvm/ADT/StringRef.h" @@ -295,10 +294,6 @@ class LangOptions : public LangOptionsBase { /// host code generation. std::string OMPHostIRFile; - /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=. - /// This overrides the default ABI used by the target. - llvm::Optional CXXABI; - /// Indicates whether the front-end is explicitly told that the /// input is a header file (i.e. -x c-header). bool IsHeaderFile = false; diff --git a/clang/include/clang/Basic/TargetCXXABI.def b/clang/include/clang/Basic/TargetCXXABI.def deleted file mode 100644 index 0ae0bb555f60.. --- a/clang/include/clang/Basic/TargetCXXABI.def +++ /dev/null @@ -1,129 +0,0 @@ -//===--- TargetCXXABI.def - Target C++ ABI database --- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// -// -// This file defines the various C++ ABI kinds used on diff erent platforms. -// Users of this file must define the CXXABI macro to make use of this -// information. -// -//===--===// - -#ifndef CXXABI -#error Define the CXXABI macro to handle C++ ABI kinds. -#endif - -#ifndef ITANIUM_CXXABI -#define ITANIUM_CXXABI(Name, Str) CXXABI(Name, Str) -#endif - -#ifndef MICROSOFT_CXXABI -#define MICROSOFT_CXXABI(Name, Str) CXXABI(Name, Str) -#endif - -/// The generic Itanium ABI is the standard ABI of most open-source -/// and Unix-like platforms. It is the primary
[clang] cf8ff75 - [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs
Author: Leonard Chan Date: 2020-11-30T16:02:35-08:00 New Revision: cf8ff75bade763b054476321dcb82dcb2e7744c7 URL: https://github.com/llvm/llvm-project/commit/cf8ff75bade763b054476321dcb82dcb2e7744c7 DIFF: https://github.com/llvm/llvm-project/commit/cf8ff75bade763b054476321dcb82dcb2e7744c7.diff LOG: [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs Thanks to D77248, we can bypass the use of stubs altogether and use PLT relocations if they are available for the target. LLVM and LLD support the R_AARCH64_PLT32 relocation, so we can also guarantee a static PLT relocation on AArch64. Not emitting these stubs saves a lot of extra binary size. Differential Revision: https://reviews.llvm.org/D83812 Added: Modified: clang/lib/CodeGen/CGVTables.cpp clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp Removed: clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 75afc860cc47..bef9a293b7ed 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -641,7 +641,7 @@ void CodeGenVTables::addRelativeComponent(ConstantArrayBuilder &builder, llvm::Constant *target; if (auto *func = dyn_cast(globalVal)) { -target = getOrCreateRelativeStub(func, stubLinkage, isCompleteDtor); +target = llvm::DSOLocalEquivalent::get(func); } else { llvm::SmallString<16> rttiProxyName(globalVal->getName()); rttiProxyName.append(".rtti_proxy"); @@ -669,74 +669,6 @@ void CodeGenVTables::addRelativeComponent(ConstantArrayBuilder &builder, /*position=*/vtableAddressPoint); } -llvm::Function *CodeGenVTables::getOrCreateRelativeStub( -llvm::Function *func, llvm::GlobalValue::LinkageTypes stubLinkage, -bool isCompleteDtor) const { - // A complete object destructor can later be substituted in the vtable for an - // appropriate base object destructor when optimizations are enabled. This can - // happen for child classes that don't have their own destructor. In the case - // where a parent virtual destructor is not guaranteed to be in the same - // linkage unit as the child vtable, it's possible for an external reference - // for this destructor to be substituted into the child vtable, preventing it - // from being in rodata. If this function is a complete virtual destructor, we - // can just force a stub to be emitted for it. - if (func->isDSOLocal() && !isCompleteDtor) -return func; - - llvm::SmallString<16> stubName(func->getName()); - stubName.append(".stub"); - - // Instead of taking the offset between the vtable and virtual function - // directly, we emit a dso_local stub that just contains a tail call to the - // original virtual function and take the offset between that and the - // vtable. We do this because there are some cases where the original - // function that would've been inserted into the vtable is not dso_local - // which may require some kind of dynamic relocation which prevents the - // vtable from being readonly. On x86_64, taking the offset between the - // function and the vtable gets lowered to the offset between the PLT entry - // for the function and the vtable which gives us a PLT32 reloc. On AArch64, - // right now only CALL26 and JUMP26 instructions generate PLT relocations, - // so we manifest them with stubs that are just jumps to the original - // function. - auto &module = CGM.getModule(); - llvm::Function *stub = module.getFunction(stubName