diff --git a/.github/workflows/libc-fullbuild-tests.yml b/.github/workflows/libc-fullbuild-tests.yml index 2c88da653aae4..d93ac84116240 100644 --- a/.github/workflows/libc-fullbuild-tests.yml +++ b/.github/workflows/libc-fullbuild-tests.yml @@ -15,6 +15,7 @@ jobs: strategy: fail-fast: false matrix: + build_type: [Debug, Release, MinSizeRel] include: - os: ubuntu-24.04 ccache-variant: sccache @@ -68,7 +69,7 @@ jobs: cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=MinSizeRel + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} -DCMAKE_INSTALL_PREFIX=${{ steps.strings.outputs.build-install-dir }} diff --git a/.github/workflows/libc-overlay-tests.yml b/.github/workflows/libc-overlay-tests.yml index 0a0916084b18c..de4b58c008ee4 100644 --- a/.github/workflows/libc-overlay-tests.yml +++ b/.github/workflows/libc-overlay-tests.yml @@ -16,6 +16,7 @@ jobs: # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. fail-fast: false matrix: + build_type: [Debug, Release, MinSizeRel] include: # TODO: add linux gcc when it is fixed - os: ubuntu-24.04 @@ -95,7 +96,7 @@ jobs: cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.compiler.c_compiler }} - -DCMAKE_BUILD_TYPE=MinSizeRel + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache-variant }} -DCMAKE_POLICY_DEFAULT_CMP0141=NEW diff --git a/.github/workflows/libcxx-build-containers.yml b/.github/workflows/libcxx-build-containers.yml index 2d040f712ce59..bb4bd8843772f 100644 --- a/.github/workflows/libcxx-build-containers.yml +++ b/.github/workflows/libcxx-build-containers.yml @@ -9,7 +9,6 @@ name: Build Docker images for libc++ CI permissions: contents: read - packages: write on: push: diff --git a/.github/workflows/premerge.yaml b/.github/workflows/premerge.yaml index b268f1faab989..178ab191a58be 100644 --- a/.github/workflows/premerge.yaml +++ b/.github/workflows/premerge.yaml @@ -21,15 +21,16 @@ on: - 'main' - 'release/**' +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + jobs: premerge-checks-linux: if: >- github.repository_owner == 'llvm' && (github.event_name != 'pull_request' || github.event.action != 'closed') runs-on: llvm-premerge-linux-runners - concurrency: - group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number || github.sha }} - cancel-in-progress: true steps: - name: Checkout LLVM uses: actions/checkout@v4 @@ -88,9 +89,6 @@ jobs: github.repository_owner == 'llvm' && (github.event_name != 'pull_request' || github.event.action != 'closed') runs-on: llvm-premerge-windows-runners - concurrency: - group: ${{ github.workflow }}-windows-${{ github.event.pull_request.number || github.sha }} - cancel-in-progress: true defaults: run: shell: bash @@ -148,9 +146,6 @@ jobs: permerge-check-macos: runs-on: macos-14 - concurrency: - group: ${{ github.workflow }}-macos-${{ github.event.pull_request.number || github.sha }} - cancel-in-progress: true if: >- github.repository_owner == 'llvm' && (startswith(github.ref_name, 'release/') || diff --git a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp index 336c6768a7f71..8f5719e84ecea 100644 --- a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp +++ b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp @@ -18,6 +18,7 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" #define DEBUG_TYPE "bolt-rtlib" @@ -38,6 +39,23 @@ std::string RuntimeLibrary::getLibPathByToolPath(StringRef ToolPath, llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX); } llvm::sys::path::append(LibPath, LibFileName); + if (!llvm::sys::fs::exists(LibPath)) { + // If it is a symlink, check the directory that the symlink points to. + if (llvm::sys::fs::is_symlink_file(ToolPath)) { + SmallString<256> RealPath; + llvm::sys::fs::real_path(ToolPath, RealPath); + if (llvm::ErrorOr P = + llvm::sys::findProgramByName(RealPath)) { + outs() << "BOLT-INFO: library not found: " << LibPath << "\n" + << "BOLT-INFO: " << ToolPath << " is a symlink; will look up " + << LibFileName + << " at the target directory that the symlink points to\n"; + return getLibPath(*P, LibFileName); + } + } + errs() << "BOLT-ERROR: library not found: " << LibPath << "\n"; + exit(1); + } return std::string(LibPath); } diff --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp index 8ae4351ac2830..d1902b658061b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp @@ -82,7 +82,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxConstructExpr( hasDeclaration(cxxMethodDecl(hasName("basic_string"))), - hasArgument(0, hasType(qualType(isInteger()))), + argumentCountIs(2), hasArgument(0, hasType(qualType(isInteger()))), hasArgument(1, hasType(qualType(isInteger()))), anyOf( // Detect the expression: string('x', 40); @@ -102,7 +102,7 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) { cxxConstructExpr( hasDeclaration(cxxConstructorDecl(ofClass( cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)))))), - hasArgument(0, hasType(CharPtrType)), + argumentCountIs(2), hasArgument(0, hasType(CharPtrType)), hasArgument(1, hasType(isInteger())), anyOf( // Detect the expression: string("...", 0); @@ -114,7 +114,34 @@ void StringConstructorCheck::registerMatchers(MatchFinder *Finder) { // Detect the expression: string("lit", 5) allOf(hasArgument(0, ConstStrLiteral.bind("literal-with-length")), hasArgument(1, ignoringParenImpCasts( - integerLiteral().bind("int")))))) + integerLiteral().bind("length")))))) + .bind("constructor"), + this); + + // Check the literal string constructor with char pointer, start position and + // length parameters. [i.e. string (const char* s, size_t pos, size_t count);] + Finder->addMatcher( + cxxConstructExpr( + hasDeclaration(cxxConstructorDecl(ofClass( + cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)))))), + argumentCountIs(3), hasArgument(0, hasType(CharPtrType)), + hasArgument(1, hasType(qualType(isInteger()))), + hasArgument(2, hasType(qualType(isInteger()))), + anyOf( + // Detect the expression: string("...", 1, 0); + hasArgument(2, ZeroExpr.bind("empty-string")), + // Detect the expression: string("...", -4, 1); + hasArgument(1, NegativeExpr.bind("negative-pos")), + // Detect the expression: string("...", 0, -4); + hasArgument(2, NegativeExpr.bind("negative-length")), + // Detect the expression: string("lit", 0, 0x1234567); + hasArgument(2, LargeLengthExpr.bind("large-length")), + // Detect the expression: string("lit", 1, 5) + allOf(hasArgument(0, ConstStrLiteral.bind("literal-with-length")), + hasArgument( + 1, ignoringParenImpCasts(integerLiteral().bind("pos"))), + hasArgument(2, ignoringParenImpCasts( + integerLiteral().bind("length")))))) .bind("constructor"), this); @@ -155,14 +182,27 @@ void StringConstructorCheck::check(const MatchFinder::MatchResult &Result) { diag(Loc, "constructor creating an empty string"); } else if (Result.Nodes.getNodeAs("negative-length")) { diag(Loc, "negative value used as length parameter"); + } else if (Result.Nodes.getNodeAs("negative-pos")) { + diag(Loc, "negative value used as position of the " + "first character parameter"); } else if (Result.Nodes.getNodeAs("large-length")) { if (WarnOnLargeLength) diag(Loc, "suspicious large length parameter"); } else if (Result.Nodes.getNodeAs("literal-with-length")) { const auto *Str = Result.Nodes.getNodeAs("str"); - const auto *Lit = Result.Nodes.getNodeAs("int"); - if (Lit->getValue().ugt(Str->getLength())) { + const auto *Length = Result.Nodes.getNodeAs("length"); + if (Length->getValue().ugt(Str->getLength())) { diag(Loc, "length is bigger than string literal size"); + return; + } + if (const auto *Pos = Result.Nodes.getNodeAs("pos")) { + if (Pos->getValue().uge(Str->getLength())) { + diag(Loc, "position of the first character parameter is bigger than " + "string literal character range"); + } else if (Length->getValue().ugt( + (Str->getLength() - Pos->getValue()).getZExtValue())) { + diag(Loc, "length is bigger than remaining string literal size"); + } } } else if (const auto *Ptr = Result.Nodes.getNodeAs("from-ptr")) { Expr::EvalResult ConstPtr; diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp index fc35bc22c52e0..c249244b1a1b2 100644 --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp @@ -139,10 +139,8 @@ static bool areEquivalentExpr(const Expr *Left, const Expr *Right) { return cast(Left)->getOpcode() == cast(Right)->getOpcode(); case Stmt::UnaryExprOrTypeTraitExprClass: - const auto *LeftUnaryExpr = - cast(Left); - const auto *RightUnaryExpr = - cast(Right); + const auto *LeftUnaryExpr = cast(Left); + const auto *RightUnaryExpr = cast(Right); if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType()) return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() && LeftUnaryExpr->getArgumentType() == @@ -699,7 +697,8 @@ static bool retrieveRelationalIntegerConstantExpr( Symbol = OverloadedOperatorExpr->getArg(IntegerConstantIsFirstArg ? 1 : 0); OperandExpr = OverloadedOperatorExpr; - Opcode = BinaryOperator::getOverloadedOpcode(OverloadedOperatorExpr->getOperator()); + Opcode = BinaryOperator::getOverloadedOpcode( + OverloadedOperatorExpr->getOperator()); if (!retrieveIntegerConstantExpr(Result, Id, Value, ConstExpr)) return false; @@ -728,7 +727,8 @@ static bool retrieveRelationalIntegerConstantExpr( } // Checks for expressions like (X == 4) && (Y != 9) -static bool areSidesBinaryConstExpressions(const BinaryOperator *&BinOp, const ASTContext *AstCtx) { +static bool areSidesBinaryConstExpressions(const BinaryOperator *&BinOp, + const ASTContext *AstCtx) { const auto *LhsBinOp = dyn_cast(BinOp->getLHS()); const auto *RhsBinOp = dyn_cast(BinOp->getRHS()); @@ -747,6 +747,28 @@ static bool areSidesBinaryConstExpressions(const BinaryOperator *&BinOp, const A return false; } +static bool areSidesBinaryConstExpressionsOrDefinesOrIntegerConstant( + const BinaryOperator *&BinOp, const ASTContext *AstCtx) { + if (areSidesBinaryConstExpressions(BinOp, AstCtx)) + return true; + + const Expr *Lhs = BinOp->getLHS(); + const Expr *Rhs = BinOp->getRHS(); + + if (!Lhs || !Rhs) + return false; + + auto IsDefineExpr = [AstCtx](const Expr *E) { + const SourceRange Lsr = E->getSourceRange(); + if (!Lsr.getBegin().isMacroID() || E->isValueDependent() || + !E->isIntegerConstantExpr(*AstCtx)) + return false; + return true; + }; + + return IsDefineExpr(Lhs) || IsDefineExpr(Rhs); +} + // Retrieves integer constant subexpressions from binary operator expressions // that have two equivalent sides. // E.g.: from (X == 5) && (X == 5) retrieves 5 and 5. @@ -785,7 +807,7 @@ static bool retrieveConstExprFromBothSides(const BinaryOperator *&BinOp, } static bool isSameRawIdentifierToken(const Token &T1, const Token &T2, - const SourceManager &SM) { + const SourceManager &SM) { if (T1.getKind() != T2.getKind()) return false; if (T1.isNot(tok::raw_identifier)) @@ -808,8 +830,8 @@ static bool areExprsFromDifferentMacros(const Expr *LhsExpr, const ASTContext *AstCtx) { if (!LhsExpr || !RhsExpr) return false; - SourceRange Lsr = LhsExpr->getSourceRange(); - SourceRange Rsr = RhsExpr->getSourceRange(); + const SourceRange Lsr = LhsExpr->getSourceRange(); + const SourceRange Rsr = RhsExpr->getSourceRange(); if (!Lsr.getBegin().isMacroID() || !Rsr.getBegin().isMacroID()) return false; @@ -847,11 +869,83 @@ static bool areExprsMacroAndNonMacro(const Expr *&LhsExpr, if (!LhsExpr || !RhsExpr) return false; - SourceLocation LhsLoc = LhsExpr->getExprLoc(); - SourceLocation RhsLoc = RhsExpr->getExprLoc(); + const SourceLocation LhsLoc = LhsExpr->getExprLoc(); + const SourceLocation RhsLoc = RhsExpr->getExprLoc(); return LhsLoc.isMacroID() != RhsLoc.isMacroID(); } + +static bool areStringsSameIgnoreSpaces(const llvm::StringRef Left, + const llvm::StringRef Right) { + if (Left == Right) + return true; + + // Do running comparison ignoring spaces + llvm::StringRef L = Left.trim(); + llvm::StringRef R = Right.trim(); + while (!L.empty() && !R.empty()) { + L = L.ltrim(); + R = R.ltrim(); + if (L.empty() && R.empty()) + return true; + // If symbol compared are different ==> strings are not the same + if (L.front() != R.front()) + return false; + L = L.drop_front(); + R = R.drop_front(); + } + return L.empty() && R.empty(); +} + +static bool areExprsSameMacroOrLiteral(const BinaryOperator *BinOp, + const ASTContext *Context) { + + if (!BinOp) + return false; + + const Expr *Lhs = BinOp->getLHS(); + const Expr *Rhs = BinOp->getRHS(); + const SourceManager &SM = Context->getSourceManager(); + + const SourceRange Lsr = Lhs->getSourceRange(); + const SourceRange Rsr = Rhs->getSourceRange(); + if (Lsr.getBegin().isMacroID()) { + // Left is macro so right macro too + if (Rsr.getBegin().isMacroID()) { + // Both sides are macros so they are same macro or literal + const llvm::StringRef L = Lexer::getSourceText( + CharSourceRange::getTokenRange(Lsr), SM, Context->getLangOpts(), 0); + const llvm::StringRef R = Lexer::getSourceText( + CharSourceRange::getTokenRange(Rsr), SM, Context->getLangOpts(), 0); + return areStringsSameIgnoreSpaces(L, R); + } + // Left is macro but right is not so they are not same macro or literal + return false; + } + const auto *Lil = dyn_cast(Lhs); + const auto *Ril = dyn_cast(Rhs); + if (Lil && Ril) + return Lil->getValue() == Ril->getValue(); + + const auto *LStrl = dyn_cast(Lhs); + const auto *RStrl = dyn_cast(Rhs); + if (Lil && Ril) { + const llvm::StringRef L = Lexer::getSourceText( + CharSourceRange::getTokenRange(LStrl->getBeginLoc()), SM, + Context->getLangOpts(), 0); + const llvm::StringRef R = Lexer::getSourceText( + CharSourceRange::getTokenRange(RStrl->getBeginLoc()), SM, + Context->getLangOpts(), 0); + return L.compare(R) == 0; + } + + const auto *Lbl = dyn_cast(Lhs); + const auto *Rbl = dyn_cast(Rhs); + if (Lbl && Rbl) + return Lbl->getValue() == Rbl->getValue(); + + return false; +} } // namespace void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { @@ -1089,7 +1183,6 @@ static bool exprEvaluatesToSymbolic(BinaryOperatorKind Opcode, APSInt Value) { ((Opcode == BO_And || Opcode == BO_AndAssign) && ~Value == 0); } - void RedundantExpressionCheck::checkBitwiseExpr( const MatchFinder::MatchResult &Result) { if (const auto *ComparisonOperator = Result.Nodes.getNodeAs( @@ -1134,8 +1227,8 @@ void RedundantExpressionCheck::checkBitwiseExpr( ConstExpr)) return; - if((Value != 0 && ~Value != 0) || Sym->getExprLoc().isMacroID()) - return; + if ((Value != 0 && ~Value != 0) || Sym->getExprLoc().isMacroID()) + return; SourceLocation Loc = IneffectiveOperator->getOperatorLoc(); @@ -1276,19 +1369,23 @@ void RedundantExpressionCheck::check(const MatchFinder::MatchResult &Result) { return; } - if (areSidesBinaryConstExpressions(BinOp, Result.Context)) { + if (areSidesBinaryConstExpressionsOrDefinesOrIntegerConstant( + BinOp, Result.Context)) { const Expr *LhsConst = nullptr, *RhsConst = nullptr; BinaryOperatorKind MainOpcode{}, SideOpcode{}; - - if (!retrieveConstExprFromBothSides(BinOp, MainOpcode, SideOpcode, - LhsConst, RhsConst, Result.Context)) - return; - - if (areExprsFromDifferentMacros(LhsConst, RhsConst, Result.Context) || - areExprsMacroAndNonMacro(LhsConst, RhsConst)) - return; + if (areSidesBinaryConstExpressions(BinOp, Result.Context)) { + if (!retrieveConstExprFromBothSides(BinOp, MainOpcode, SideOpcode, + LhsConst, RhsConst, Result.Context)) + return; + + if (areExprsFromDifferentMacros(LhsConst, RhsConst, Result.Context) || + areExprsMacroAndNonMacro(LhsConst, RhsConst)) + return; + } else { + if (!areExprsSameMacroOrLiteral(BinOp, Result.Context)) + return; + } } - diag(BinOp->getOperatorLoc(), "both sides of operator are equivalent"); } diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 3bddeeda06e06..6b8fe22242417 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -97,10 +97,19 @@ New check aliases Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ +- Improved :doc:`bugprone-string-constructor + ` check to find suspicious + calls of ``std::string`` constructor with char pointer, start position and + length parameters. + - Improved :doc:`bugprone-unsafe-functions ` check to allow specifying additional C++ member functions to match. +- Improved :doc:`misc-redundant-expression + ` check by providing additional + examples and fixing some macro related false positives. + Removed checks ^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst index b45c2ef4a9312..a0bd1d7c5bc15 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst @@ -21,6 +21,7 @@ Examples: .. code-block:: c++ std::string("test", 200); // Will include random characters after "test". + std::string("test", 2, 5); // Will include random characters after "st". std::string_view("test", 200); Creating an empty string from constructors with parameters is considered @@ -31,8 +32,19 @@ Examples: .. code-block:: c++ std::string("test", 0); // Creation of an empty string. + std::string("test", 1, 0); std::string_view("test", 0); +Passing an invalid first character position parameter to constructor will +cause ``std::out_of_range`` exception at runtime. + +Examples: + +.. code-block:: c++ + + std::string("test", -1, 10); // Negative first character position. + std::string("test", 10, 10); // First character position is bigger than string literal character range". + Options ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/redundant-expression.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/redundant-expression.rst index 44f0772d0bedf..cea998d39bd73 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/redundant-expression.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/redundant-expression.rst @@ -19,12 +19,14 @@ Examples: .. code-block:: c++ - ((x+1) | (x+1)) // (x+1) is redundant - (p->x == p->x) // always true - (p->x < p->x) // always false - (speed - speed + 1 == 12) // speed - speed is always zero - int b = a | 4 | a // identical expr on both sides - ((x=1) | (x=1)) // expression is identical + ((x+1) | (x+1)) // (x+1) is redundant + (p->x == p->x) // always true + (p->x < p->x) // always false + (speed - speed + 1 == 12) // speed - speed is always zero + int b = a | 4 | a // identical expr on both sides + ((x=1) | (x=1)) // expression is identical + (DEFINE_1 | DEFINE_1) // same macro on the both sides + ((DEF_1 + DEF_2) | (DEF_1+DEF_2)) // expressions differ in spaces only Floats are handled except in the case that NaNs are checked like so: diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp index a5b6b240ddc66..2576d19916250 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp @@ -11,6 +11,7 @@ struct basic_string { basic_string(const C*, unsigned int size); basic_string(const C *, const A &allocator = A()); basic_string(unsigned int size, C c); + basic_string(const C*, unsigned int pos, unsigned int size); }; typedef basic_string string; typedef basic_string wstring; @@ -61,6 +62,21 @@ void Test() { // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr is undefined behaviour std::string q7 = 0; // CHECK-MESSAGES: [[@LINE-1]]:20: warning: constructing string from nullptr is undefined behaviour + + std::string r1("test", 1, 0); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string + std::string r2("test", 0, -4); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter + std::string r3("test", -4, 1); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as position of the first character parameter + std::string r4("test", 0, 0x1000000); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter + std::string r5("test", 0, 5); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size + std::string r6("test", 3, 2); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than remaining string literal size + std::string r7("test", 4, 1); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: position of the first character parameter is bigger than string literal character range } void TestView() { @@ -82,6 +98,17 @@ void TestView() { // CHECK-MESSAGES: [[@LINE-1]]:25: warning: constructing string from nullptr is undefined behaviour } +void TestUnsignedArguments() { + std::string s0("test", 0u); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string + std::string s1(0x1000000ull, 'x'); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter + std::string s2("test", 3ull, 2u); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than remaining string literal size + std::string s3("test", 0u, 5ll); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size +} + std::string StringFromZero() { return 0; // CHECK-MESSAGES: [[@LINE-1]]:10: warning: constructing string from nullptr is undefined behaviour @@ -101,6 +128,9 @@ void Valid() { std::string s3("test"); std::string s4("test\000", 5); std::string s6("te" "st", 4); + std::string s7("test", 0, 4); + std::string s8("test", 3, 1); + std::string s9("te" "st", 1, 2); std::string_view emptyv(); std::string_view sv1("test", 4); diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp index 7396d2dce76c4..95d8ecb15a4f1 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp @@ -1,4 +1,5 @@ // RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -fno-delayed-template-parsing -Wno-array-compare-cxx26 +// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -fno-delayed-template-parsing -Wno-array-compare-cxx26 -DTEST_MACRO typedef __INT64_TYPE__ I64; @@ -91,6 +92,223 @@ int TestSimpleEquivalent(int X, int Y) { return 0; } +#ifndef TEST_MACRO +#define VAL_1 2 +#define VAL_3 3 +#else +#define VAL_1 3 +#define VAL_3 2 +#endif + +#define VAL_2 2 + +#ifndef TEST_MACRO +#define VAL_4 2 + 1 +#define VAL_6 3 + 1 +#else +#define VAL_4 3 + 1 +#define VAL_6 2 + 1 +#endif + +#define VAL_5 2 + 1 + +struct TestStruct +{ + int mA; + int mB; + int mC[10]; +}; + +int TestDefineEquivalent() { + + int int_val1 = 3; + int int_val2 = 4; + int int_val = 0; + const int cint_val2 = 4; + + // Cases which should not be reported + if (VAL_1 != VAL_2) return 0; + if (VAL_3 != VAL_2) return 0; + if (VAL_1 == VAL_2) return 0; + if (VAL_3 == VAL_2) return 0; + if (VAL_1 >= VAL_2) return 0; + if (VAL_3 >= VAL_2) return 0; + if (VAL_1 <= VAL_2) return 0; + if (VAL_3 <= VAL_2) return 0; + if (VAL_1 < VAL_2) return 0; + if (VAL_3 < VAL_2) return 0; + if (VAL_1 > VAL_2) return 0; + if (VAL_3 > VAL_2) return 0; + + if (VAL_4 != VAL_5) return 0; + if (VAL_6 != VAL_5) return 0; + if (VAL_6 == VAL_5) return 0; + if (VAL_4 >= VAL_5) return 0; + if (VAL_6 >= VAL_5) return 0; + if (VAL_4 <= VAL_5) return 0; + if (VAL_6 <= VAL_5) return 0; + if (VAL_4 > VAL_5) return 0; + if (VAL_6 > VAL_5) return 0; + if (VAL_4 < VAL_5) return 0; + if (VAL_6 < VAL_5) return 0; + + if (VAL_1 != 2) return 0; + if (VAL_3 == 3) return 0; + + if (VAL_1 >= VAL_1) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + if (VAL_2 <= VAL_2) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + if (VAL_3 > VAL_3) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + if (VAL_4 < VAL_4) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + if (VAL_6 == VAL_6) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + if (VAL_5 != VAL_5) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent + + // Test prefixes + if (+VAL_6 == +VAL_6) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent + if (-VAL_6 == -VAL_6) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent + if ((+VAL_6) == (+VAL_6)) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: both sides of operator are equivalent + if ((-VAL_6) == (-VAL_6)) return 2; + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: both sides of operator are equivalent + + if (1 >= 1) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent + if (0xFF <= 0xFF) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: both sides of operator are equivalent + if (042 > 042) return 0; + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: both sides of operator are equivalent + + int_val = (VAL_6 == VAL_6)?int_val1: int_val2; + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: both sides of operator are equivalent + int_val = (042 > 042)?int_val1: int_val2; + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both sides of operator are equivalent + + + // Ternary operator cases which should not be reported + int_val = (VAL_4 == VAL_5)? int_val1: int_val2; + int_val = (VAL_3 != VAL_2)? int_val1: int_val2; + int_val = (VAL_6 != 10)? int_val1: int_val2; + int_val = (VAL_6 != 3)? int_val1: int_val2; + int_val = (VAL_6 != 4)? int_val1: int_val2; + int_val = (VAL_6 == 3)? int_val1: int_val2; + int_val = (VAL_6 == 4)? int_val1: int_val2; + + TestStruct tsVar1 = { + .mA = 3, + .mB = int_val, + .mC[0 ... VAL_2 - 2] = int_val + 1, + }; + + TestStruct tsVar2 = { + .mA = 3, + .mB = int_val, + .mC[0 ... cint_val2 - 2] = int_val + 1, + }; + + TestStruct tsVar3 = { + .mA = 3, + .mB = int_val, + .mC[0 ... VAL_3 - VAL_3] = int_val + 1, + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: both sides of operator are equivalent + }; + + TestStruct tsVar4 = { + .mA = 3, + .mB = int_val, + .mC[0 ... 5 - 5] = int_val + 1, + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: both sides of operator are equivalent + }; + + return 1 + int_val + sizeof(tsVar1) + sizeof(tsVar2) + + sizeof(tsVar3) + sizeof(tsVar4); +} + +#define LOOP_DEFINE 1 + +unsigned int testLoops(const unsigned int arr1[LOOP_DEFINE]) +{ + unsigned int localIndex; + for (localIndex = LOOP_DEFINE - 1; localIndex > 0; localIndex--) + { + } + for (localIndex = LOOP_DEFINE - 1; 10 > 10; localIndex--) + // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: both sides of operator are equivalent + { + } + + for (localIndex = LOOP_DEFINE - 1; LOOP_DEFINE > LOOP_DEFINE; localIndex--) + // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: both sides of operator are equivalent + { + } + + return localIndex; +} + +#define getValue(a) a +#define getValueM(a) a + +int TestParamDefine() { + int ret = 0; + + // Negative cases + ret += getValue(VAL_6) == getValue(2); + ret += getValue(VAL_6) == getValue(3); + ret += getValue(VAL_5) == getValue(2); + ret += getValue(VAL_5) == getValue(3); + ret += getValue(1) > getValue( 2); + ret += getValue(VAL_1) == getValue(VAL_2); + ret += getValue(VAL_1) != getValue(VAL_2); + ret += getValue(VAL_1) == getValueM(VAL_1); + ret += getValue(VAL_1 + VAL_2) == getValueM(VAL_1 + VAL_2); + ret += getValue(1) == getValueM(1); + ret += getValue(false) == getValueM(false); + ret += -getValue(1) > +getValue( 1); + + // Positive cases + ret += (+getValue(1)) > (+getValue( 1)); + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are equivalent + ret += (-getValue(1)) > (-getValue( 1)); + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are equivalent + + ret += +getValue(1) > +getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both sides of operator are equivalent + ret += -getValue(1) > -getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both sides of operator are equivalent + + ret += getValue(1) > getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: both sides of operator are equivalent + ret += getValue(1) > getValue( 1 ); + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: both sides of operator are equivalent + ret += getValue(1) > getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: both sides of operator are equivalent + ret += getValue( 1) > getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: both sides of operator are equivalent + ret += getValue( 1 ) > getValue( 1); + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: both sides of operator are equivalent + ret += getValue( VAL_5 ) > getValue(VAL_5); + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: both sides of operator are equivalent + ret += getValue( VAL_5 ) > getValue( VAL_5); + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: both sides of operator are equivalent + ret += getValue( VAL_5 ) > getValue( VAL_5 ) ; + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: both sides of operator are equivalent + ret += getValue(VAL_5) > getValue( VAL_5 ) ; + // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both sides of operator are equivalent + ret += getValue(VAL_1+VAL_2) > getValue(VAL_1 + VAL_2) ; + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: both sides of operator are equivalent + ret += getValue(VAL_1)+getValue(VAL_2) > getValue(VAL_1) + getValue( VAL_2) ; + // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: both sides of operator are equivalent + ret += (getValue(VAL_1)+getValue(VAL_2)) > (getValue(VAL_1) + getValue( VAL_2) ) ; + // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: both sides of operator are equivalent + return ret; +} + template int TestSimpleEquivalentDependent() { if (DX > 0 && DX > 0) return 1; diff --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake deleted file mode 100644 index b3c3b63066363..0000000000000 --- a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build. - -include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake) - -if(NOT APPLE) - set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") -endif() - -set(CLANG_BOOTSTRAP_TARGETS - check-all - check-clang - check-lld - check-llvm - clang - clang-test-depends - toolchain-distribution - install-toolchain-distribution - install-toolchain-distribution-stripped - install-toolchain-distribution-toolchain - lld-test-depends - llvm-config - llvm-test-depends - test-depends - test-suite CACHE STRING "") - -get_cmake_property(variableNames VARIABLES) -foreach(variableName ${variableNames}) - if(variableName MATCHES "^STAGE2_") - string(REPLACE "STAGE2_" "" new_name ${variableName}) - list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}") - endif() -endforeach() - -set(CLANG_PGO_TRAINING_DEPS - builtins - runtimes - CACHE STRING "") - -# Setup the bootstrap build. -set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") -set(CLANG_BOOTSTRAP_CMAKE_ARGS - ${EXTRA_ARGS} - -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake - CACHE STRING "") diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index ba1bb35733114..99890b8246ad7 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -190,8 +190,8 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") # Enable FatLTO for Linux and baremetal runtimes - set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO OFF CACHE BOOL "") # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") @@ -276,8 +276,8 @@ if(FUCHSIA_SDK) set(RUNTIMES_${target}+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") # Enable FatLTO for Fuchsia runtimes - set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO OFF CACHE BOOL "") # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") @@ -378,8 +378,8 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") # Enable FatLTO for baremetal runtimes - set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO OFF CACHE BOOL "") endforeach() foreach(target riscv32-unknown-elf) @@ -433,8 +433,8 @@ foreach(target riscv32-unknown-elf) set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") # Enable FatLTO for baremetal runtimes - set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_LTO OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO OFF CACHE BOOL "") endforeach() set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "") diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake index 373b7ddd6e344..83336589da305 100644 --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -126,16 +126,6 @@ else() set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(LIBCXX_HARDENING_MODE "none" CACHE STRING "") set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") - set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "") - set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") - set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") - set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") - set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "") - set(SANITIZER_CXX_ABI "libc++" CACHE STRING "") - set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") - set(SANITIZER_TEST_CXX "libc++" CACHE STRING "") - set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "") set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "") endif() @@ -174,29 +164,34 @@ endif() set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") -set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "") set(_FUCHSIA_BOOTSTRAP_TARGETS - generate-profdata - stage2 - stage2-toolchain-distribution - stage2-install-toolchain-distribution - stage2-install-toolchain-distribution-stripped - stage2-install-toolchain-distribution-toolchain - stage2-check-all - stage2-check-lld - stage2-check-llvm - stage2-check-clang - stage2-test-suite) + check-all + check-clang + check-lld + check-llvm + check-polly + llvm-config + clang-test-depends + lld-test-depends + llvm-test-depends + test-suite + test-depends + toolchain-distribution + install-toolchain-distribution + install-toolchain-distribution-stripped + install-toolchain-distribution-toolchain + clang) if(FUCHSIA_ENABLE_LLDB) list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb) list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS - stage2-check-lldb - stage2-debugger-distribution - stage2-install-debugger-distribution - stage2-install-debugger-distribution-stripped - stage2-install-debugger-distribution-toolchain) + check-lldb + lldb-test-depends + debugger-distribution + install-debugger-distribution + install-debugger-distribution-stripped + install-debugger-distribution-toolchain) endif() set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "") @@ -205,7 +200,6 @@ set(CLANG_BOOTSTRAP_TARGETS ${_FUCHSIA_BOOTSTRAP_TARGETS} CACHE STRING "") get_cmake_property(variableNames VARIABLES) foreach(variableName ${variableNames}) if(variableName MATCHES "^STAGE2_") - list(APPEND EXTRA_ARGS "-D${variableName}=${${variableName}}") string(REPLACE "STAGE2_" "" new_name ${variableName}) string(REPLACE ";" "|" value "${${variableName}}") list(APPEND EXTRA_ARGS "-D${new_name}=${value}") @@ -215,9 +209,6 @@ endforeach() # TODO: This is a temporary workaround until we figure out the right solution. set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") -set(LLVM_BUILTIN_TARGETS "default" CACHE STRING "") -set(LLVM_RUNTIME_TARGETS "default" CACHE STRING "") - # Setup the bootstrap build. set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") set(CLANG_BOOTSTRAP_EXTRA_DEPS @@ -226,5 +217,5 @@ set(CLANG_BOOTSTRAP_EXTRA_DEPS CACHE STRING "") set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} - -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2-instrumented.cmake + -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake CACHE STRING "") diff --git a/clang/docs/BoundsSafety.rst b/clang/docs/BoundsSafety.rst index 8635bec6e17c7..cf5b0c75c0387 100644 --- a/clang/docs/BoundsSafety.rst +++ b/clang/docs/BoundsSafety.rst @@ -777,13 +777,13 @@ the transformed pseudo code of function ``alloc_buf()`` in the example below. size_t count; } sized_buf_t; - void alloc_buf(sized_buf_t *sbuf, sized_t nelems) { + void alloc_buf(sized_buf_t *sbuf, size_t nelems) { sbuf->buf = (int *)malloc(sizeof(int) * nelems); sbuf->count = nelems; } // Transformed pseudo code: - void alloc_buf(sized_buf_t *sbuf, sized_t nelems) { + void alloc_buf(sized_buf_t *sbuf, size_t nelems) { // Materialize RHS values: int *tmp_ptr = (int *)malloc(sizeof(int) * nelems); int tmp_count = nelems; diff --git a/clang/docs/BoundsSafetyImplPlans.rst b/clang/docs/BoundsSafetyImplPlans.rst index 93c2ed7b43402..34276c920f31e 100644 --- a/clang/docs/BoundsSafetyImplPlans.rst +++ b/clang/docs/BoundsSafetyImplPlans.rst @@ -134,7 +134,7 @@ same basic block and without side effect in between. int *__counted_by(count) buf; size_t count; } sized_buf_t; - void alloc_buf(sized_buf_t *sbuf, sized_t nelems) { + void alloc_buf(sized_buf_t *sbuf, size_t nelems) { sbuf->buf = (int *)malloc(sizeof(int) * nelems); sbuf->count = nelems; } diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index ce38a3a9ba1f7..bf6dd9e13915f 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -2182,6 +2182,24 @@ the configuration (without a prefix: ``Auto``). aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); } +.. _BinPackLongBracedList: + +**BinPackLongBracedList** (``Boolean``) :versionbadge:`clang-format 21` :ref:`¶ ` + If ``BinPackLongBracedList`` is ``true`` it overrides + ``BinPackArguments`` if there are 20 or more items in a braced + initializer list. + + .. code-block:: c++ + + BinPackLongBracedList: false vs. BinPackLongBracedList: true + vector x{ vector x{1, 2, ..., + 20, 21}; + 1, + 2, + ..., + 20, + 21}; + .. _BinPackParameters: **BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`¶ ` diff --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst index c31d6e90ecb08..725624ee8c66c 100644 --- a/clang/docs/OpenMPSupport.rst +++ b/clang/docs/OpenMPSupport.rst @@ -416,9 +416,9 @@ implementation. +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ | safe_sync and progress with identifier and API | :none:`unclaimed` | :none:`unclaimed` | | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ -| OpenMP directives in concurrent loop regions | :none:`unclaimed` | :none:`unclaimed` | | +| OpenMP directives in concurrent loop regions | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/125621 | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ -| atomics constructs on concurrent loop regions | :none:`unclaimed` | :none:`unclaimed` | | +| atomics constructs on concurrent loop regions | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/125621 | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ | Loop construct with DO CONCURRENT | :none:`unclaimed` | :none:`unclaimed` | | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ @@ -456,9 +456,7 @@ implementation. +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ | map-type modifiers in arbitrary position | :none:`unclaimed` | :none:`unclaimed` | | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ -| atomic constructs in loop region | :none:`unclaimed` | :none:`unclaimed` | | -+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ -| Lift nesting restriction on concurrent loop | :none:`unclaimed` | :none:`unclaimed` | | +| Lift nesting restriction on concurrent loop | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/125621 | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ | priority clause for target constructs | :none:`unclaimed` | :none:`unclaimed` | | +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 92f63c1503089..369d9e9de7d16 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -117,6 +117,7 @@ Attribute Changes in Clang -------------------------- - The ``no_sanitize`` attribute now accepts both ``gnu`` and ``clang`` names. +- Clang now diagnoses use of declaration attributes on void parameters. (#GH108819) Improvements to Clang's diagnostics ----------------------------------- @@ -128,6 +129,8 @@ Improvements to Clang's diagnostics which are supposed to only exist once per program, but may get duplicated when built into a shared library. - Fixed a bug where Clang's Analysis did not correctly model the destructor behavior of ``union`` members (#GH119415). +- A statement attribute applied to a ``case`` label no longer suppresses + 'bypassing variable initialization' diagnostics (#84072). Improvements to Clang's time-trace ---------------------------------- @@ -151,6 +154,8 @@ Bug Fixes to C++ Support ^^^^^^^^^^^^^^^^^^^^^^^^ - Clang is now better at keeping track of friend function template instance contexts. (#GH55509) +- The initialization kind of elements of structured bindings + direct-list-initialized from an array is corrected to direct-initialization. Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -237,6 +242,8 @@ clang-format ------------ - Adds ``BreakBeforeTemplateCloser`` option. +- Adds ``BinPackLongBracedList`` option to override bin packing options in + long (20 item or more) braced list initializer lists. libclang -------- diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 0f2f313ad184a..d977868b8a2c6 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3125,6 +3125,24 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported by the target, or ``single`` otherwise. +.. option:: -fprofile-continuous + + Enables the continuous instrumentation profiling where profile counter updates + are continuously synced to a file. This option sets any neccessary modifiers + (currently ``%c``) in the default profile filename and passes any necessary + flags to the middle-end to support this mode. Value profiling is not supported + in continuous mode. + + .. code-block:: console + + $ clang++ -O2 -fprofile-generate -fprofile-continuous code.cc -o code + + Running ``./code`` will collect the profile and write it to the + ``default_xxxx.profraw`` file. However, if ``./code`` abruptly terminates or + does not call ``exit()``, in continuous mode the profile collected up to the + point of termination will be available in ``default_xxxx.profraw`` while in + the non-continuous mode, no profile file is generated. + .. option:: -ftemporal-profile Enables the temporal profiling extension for IRPGO to improve startup time by diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 68831093c6ad8..a7f5f1abbb825 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -221,6 +221,7 @@ AFFECTING_VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option spec AFFECTING_VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified. CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set -fprofile-update=atomic +CODEGENOPT(ContinuousProfileSync, 1, 0) ///< Enable continuous instrumentation profiling /// Choose profile instrumenation kind or no instrumentation. ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone) /// Choose profile kind for PGO use compilation. diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index bcae9e9f30093..2fce5e88ba8a0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -350,10 +350,11 @@ def warn_arm_interrupt_vfp_clobber : Warning< InGroup>; def err_arm_interrupt_called : Error< "interrupt service routine cannot be called directly">; -def warn_interrupt_attribute_invalid : Warning< - "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " - "functions that have %select{no parameters|a 'void' return type}1">, - InGroup; +def warn_interrupt_signal_attribute_invalid : Warning< + "%select{MIPS|MSP430|RISC-V|AVR}0 '%select{interrupt|signal}1' " + "attribute only applies to functions that have " + "%select{no parameters|a 'void' return type}2">, + InGroup; def warn_riscv_repeated_interrupt_attribute : Warning< "repeated RISC-V 'interrupt' attribute">, InGroup; def note_riscv_repeated_interrupt_attribute : Note< @@ -3832,6 +3833,9 @@ def warn_type_attribute_wrong_type : Warning< "'%0' only applies to %select{function|pointer|" "Objective-C object or block pointer}1 types; type here is %2">, InGroup; +def warn_attribute_on_void_param: Warning< + "attribute %0 cannot be applied to a 'void' parameter">, + InGroup; def err_type_attribute_wrong_type : Error< warn_type_attribute_wrong_type.Summary>; def warn_incomplete_encoded_type : Warning< @@ -9193,6 +9197,8 @@ def err_cuda_device_exceptions : Error< def err_dynamic_var_init : Error< "dynamic initialization is not supported for " "__device__, __constant__, __shared__, and __managed__ variables">; +def err_cuda_ctor_dtor_attrs + : Error<"CUDA does not support global %0 for __device__ functions">; def err_shared_var_init : Error< "initialization is not supported for __shared__ variables">; def err_cuda_vla : Error< diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index b9e46a5e7d1ca..070cc792ca7db 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1662,7 +1662,7 @@ class TargetInfo : public TransferrableTargetInfo, // access target-specific GPU grid values that must be consistent between // host RTL (plugin), deviceRTL and clang. virtual const llvm::omp::GV &getGridValue() const { - llvm_unreachable("getGridValue not implemented on this target"); + return llvm::omp::SPIRVGridValues; } /// Retrieve the name of the platform as it is used in the diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df226fd9e9aa2..1cf62ab466134 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1795,6 +1795,11 @@ def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, Values<"atomic,prefer-atomic,single">, MetaVarName<"">, HelpText<"Set update method of profile counters">, MarshallingInfoFlag>; +def fprofile_continuous : Flag<["-"], "fprofile-continuous">, + Group, Visibility<[ClangOption, CC1Option]>, + HelpText<"Enable continuous instrumentation profiling mode">, + MarshallingInfoFlag>; + defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling", CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse, PosFlag, @@ -3416,8 +3421,6 @@ def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group, def fstruct_path_tbaa : Flag<["-"], "fstruct-path-tbaa">, Group; def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group; -def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group, - Visibility<[ClangOption, FlangOption]>; defm init_global_zero : BoolOptionWithoutMarshalling<"f", "init-global-zero", PosFlag, @@ -3929,7 +3932,9 @@ defm strict_vtable_pointers : BoolFOption<"strict-vtable-pointers", " overwriting polymorphic C++ objects">, NegFlag>; def fstrict_overflow : Flag<["-"], "fstrict-overflow">, Group, - Visibility<[ClangOption, FlangOption]>; + Visibility<[ClangOption, CLOption, FlangOption]>; +def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group, + Visibility<[ClangOption, CLOption, FlangOption]>; def fpointer_tbaa : Flag<["-"], "fpointer-tbaa">, Group; def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption]>, diff --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h index aa86e41806711..e60440e14a9fe 100644 --- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h +++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h @@ -1146,11 +1146,29 @@ bool ExtractAPIVisitorBase::VisitTypedefNameDecl( StringRef Name = Decl->getName(); + auto nameMatches = [&Name](TagDecl *TagDecl) { + StringRef TagName = TagDecl->getName(); + + if (TagName == Name) + return true; + + // Also check whether the tag decl's name is the same as the typedef name + // with prefixed underscores + if (TagName.starts_with('_')) { + StringRef StrippedName = TagName.ltrim('_'); + + if (StrippedName == Name) + return true; + } + + return false; + }; + // If the underlying type was defined as part of the typedef modify it's // fragments directly and pretend the typedef doesn't exist. if (auto *TagDecl = Decl->getUnderlyingType()->getAsTagDecl()) { if (TagDecl->isEmbeddedInDeclarator() && TagDecl->isCompleteDefinition() && - Decl->getName() == TagDecl->getName()) { + nameMatches(TagDecl)) { SmallString<128> TagUSR; index::generateUSRForDecl(TagDecl, TagUSR); if (auto *Record = API.findRecordForUSR(TagUSR)) { @@ -1164,6 +1182,11 @@ bool ExtractAPIVisitorBase::VisitTypedefNameDecl( .append(Name, DeclarationFragments::FragmentKind::Identifier) .appendSemicolon(); + // Replace the name and subheading in case it's underscored so we can + // use the non-underscored version + Record->Name = Name; + Record->SubHeading = DeclarationFragmentsBuilder::getSubHeading(Decl); + return true; } } diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index fbc9291ae950d..16956b4e0fbd4 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -1212,6 +1212,22 @@ struct FormatStyle { /// \version 3.7 bool BinPackArguments; + /// If ``BinPackLongBracedList`` is ``true`` it overrides + /// ``BinPackArguments`` if there are 20 or more items in a braced + /// initializer list. + /// \code + /// BinPackLongBracedList: false vs. BinPackLongBracedList: true + /// vector x{ vector x{1, 2, ..., + /// 20, 21}; + /// 1, + /// 2, + /// ..., + /// 20, + /// 21}; + /// \endcode + /// \version 21 + bool BinPackLongBracedList; + /// Different way to try to fit all parameters on a line. enum BinPackParametersStyle : int8_t { /// Bin-pack parameters. @@ -5266,6 +5282,7 @@ struct FormatStyle { R.AlwaysBreakBeforeMultilineStrings && AttributeMacros == R.AttributeMacros && BinPackArguments == R.BinPackArguments && + BinPackLongBracedList == R.BinPackLongBracedList && BinPackParameters == R.BinPackParameters && BitFieldColonSpacing == R.BitFieldColonSpacing && BracedInitializerIndentWidth == R.BracedInitializerIndentWidth && diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h index a99c11766f110..3c242898ef6cd 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h @@ -35,7 +35,7 @@ class CallDescription { /// Match calls to functions from the C standard library. This also /// recognizes builtin variants whose name is derived by adding /// "__builtin", "__inline" or similar prefixes or suffixes; but only - /// matches functions than are externally visible and are declared either + /// matches functions that are externally visible and are declared either /// directly within a TU or in the namespace 'std'. /// For the exact heuristics, see CheckerContext::isCLibraryFunction(). CLibrary, @@ -152,7 +152,7 @@ class CallDescription { /// exists only when that is not available, for example, when _only_ /// syntactic check is done on a piece of code. /// - /// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade + /// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate /// for syntactic only matching if you are writing a new checker. This is /// handy if a CallDescriptionMap is already there. /// @@ -233,7 +233,7 @@ template class CallDescriptionMap { /// exists only when that is not available, for example, when _only_ /// syntactic check is done on a piece of code. /// - /// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade + /// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate /// for syntactic only matching if you are writing a new checker. This is /// handy if a CallDescriptionMap is already there. /// @@ -274,7 +274,7 @@ class CallDescriptionSet { /// exists only when that is not available, for example, when _only_ /// syntactic check is done on a piece of code. /// - /// Also, StdLibraryFunctionsChecker::Signature is likely a better candicade + /// Also, StdLibraryFunctionsChecker::Signature is likely a better candidate /// for syntactic only matching if you are writing a new checker. This is /// handy if a CallDescriptionMap is already there. /// diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index de617860b7004..e3b44bdbe3dc5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3902,7 +3902,7 @@ QualType ASTContext::getArrayParameterType(QualType Ty) const { if (Ty->isArrayParameterType()) return Ty; assert(Ty->isConstantArrayType() && "Ty must be an array type."); - const auto *ATy = cast(Ty); + const auto *ATy = cast(Ty.getDesugaredType(*this)); llvm::FoldingSetNodeID ID; ATy->Profile(ID, *this, ATy->getElementType(), ATy->getZExtSize(), ATy->getSizeExpr(), ATy->getSizeModifier(), diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 1f0e022edcd76..cf39209819ade 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -194,12 +194,12 @@ template class StmtExprScope final { template bool Compiler::VisitCastExpr(const CastExpr *CE) { const Expr *SubExpr = CE->getSubExpr(); - switch (CE->getCastKind()) { - case CK_LValueToRValue: { - if (DiscardResult) - return this->discard(SubExpr); + if (DiscardResult) + return this->delegate(SubExpr); + switch (CE->getCastKind()) { + case CK_LValueToRValue: { std::optional SubExprT = classify(SubExpr->getType()); // Prepare storage for the result. if (!Initializing && !SubExprT) { @@ -253,9 +253,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - if (DiscardResult) - return this->discard(SubExpr); - if (!this->delegate(SubExpr)) return false; @@ -285,9 +282,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { } case CK_BaseToDerived: { - if (DiscardResult) - return this->discard(SubExpr); - if (!this->delegate(SubExpr)) return false; @@ -302,8 +296,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { if (!SubExpr->getType()->isFloatingType() || !CE->getType()->isFloatingType()) return false; - if (DiscardResult) - return this->discard(SubExpr); if (!this->visit(SubExpr)) return false; const auto *TargetSemantics = &Ctx.getFloatSemantics(CE->getType()); @@ -311,8 +303,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { } case CK_IntegralToFloating: { - if (DiscardResult) - return this->discard(SubExpr); std::optional FromT = classify(SubExpr->getType()); if (!FromT) return false; @@ -327,8 +317,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_FloatingToBoolean: case CK_FloatingToIntegral: { - if (DiscardResult) - return this->discard(SubExpr); std::optional ToT = classify(CE->getType()); @@ -352,9 +340,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_NullToMemberPointer: { if (!this->discard(SubExpr)) return false; - if (DiscardResult) - return true; - const Descriptor *Desc = nullptr; const QualType PointeeType = CE->getType()->getPointeeType(); if (!PointeeType.isNull()) { @@ -371,9 +356,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { } case CK_PointerToIntegral: { - if (DiscardResult) - return this->discard(SubExpr); - if (!this->visit(SubExpr)) return false; @@ -399,8 +381,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { return false; if (!this->emitArrayDecay(CE)) return false; - if (DiscardResult) - return this->emitPopPtr(CE); return true; } @@ -412,9 +392,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { // FIXME: I think the discard is wrong since the int->ptr cast might cause a // diagnostic. PrimType T = classifyPrim(IntType); - if (DiscardResult) - return this->emitPop(T, CE); - QualType PtrType = CE->getType(); const Descriptor *Desc; if (std::optional T = classify(PtrType->getPointeeType())) @@ -454,10 +431,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { return false; return this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/true, CE); } - - if (DiscardResult) - return this->discard(SubExpr); - QualType SubExprTy = SubExpr->getType(); std::optional FromT = classify(SubExprTy); // Casts from integer/vector to vector. @@ -493,8 +466,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_FixedPointToBoolean: case CK_BooleanToSignedIntegral: case CK_IntegralCast: { - if (DiscardResult) - return this->discard(SubExpr); std::optional FromT = classify(SubExpr->getType()); std::optional ToT = classify(CE->getType()); @@ -546,8 +517,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_IntegralComplexToBoolean: case CK_FloatingComplexToBoolean: { - if (DiscardResult) - return this->discard(SubExpr); if (!this->visit(SubExpr)) return false; return this->emitComplexBoolCast(SubExpr); @@ -585,9 +554,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_FloatingComplexToIntegralComplex: { assert(CE->getType()->isAnyComplexType()); assert(SubExpr->getType()->isAnyComplexType()); - if (DiscardResult) - return this->discard(SubExpr); - if (!Initializing) { std::optional LocalIndex = allocateLocal(CE); if (!LocalIndex) @@ -633,9 +599,6 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { assert(classify(SubExpr->getType())); assert(CE->getType()->isVectorType()); - if (DiscardResult) - return this->discard(SubExpr); - if (!Initializing) { std::optional LocalIndex = allocateLocal(CE); if (!LocalIndex) @@ -3370,15 +3333,23 @@ bool Compiler::VisitCXXNewExpr(const CXXNewExpr *E) { PrimType SizeT = classifyPrim(Stripped->getType()); + // Save evaluated array size to a variable. + unsigned ArrayLen = allocateLocalPrimitive( + Stripped, SizeT, /*IsConst=*/false, /*IsExtended=*/false); + if (!this->visit(Stripped)) + return false; + if (!this->emitSetLocal(SizeT, ArrayLen, E)) + return false; + if (PlacementDest) { if (!this->visit(PlacementDest)) return false; - if (!this->visit(Stripped)) + if (!this->emitGetLocal(SizeT, ArrayLen, E)) return false; if (!this->emitCheckNewTypeMismatchArray(SizeT, E, E)) return false; } else { - if (!this->visit(Stripped)) + if (!this->emitGetLocal(SizeT, ArrayLen, E)) return false; if (ElemT) { @@ -3392,10 +3363,113 @@ bool Compiler::VisitCXXNewExpr(const CXXNewExpr *E) { } } - if (Init && !this->visitInitializer(Init)) - return false; + if (Init) { + QualType InitType = Init->getType(); + size_t StaticInitElems = 0; + const Expr *DynamicInit = nullptr; + if (const ConstantArrayType *CAT = + Ctx.getASTContext().getAsConstantArrayType(InitType)) { + StaticInitElems = CAT->getZExtSize(); + if (!this->visitInitializer(Init)) + return false; - } else { + if (const auto *ILE = dyn_cast(Init); + ILE && ILE->hasArrayFiller()) + DynamicInit = ILE->getArrayFiller(); + } + + // The initializer initializes a certain number of elements, S. + // However, the complete number of elements, N, might be larger than that. + // In this case, we need to get an initializer for the remaining elements. + // There are to cases: + // 1) For the form 'new Struct[n];', the initializer is a + // CXXConstructExpr and its type is an IncompleteArrayType. + // 2) For the form 'new Struct[n]{1,2,3}', the initializer is an + // InitListExpr and the initializer for the remaining elements + // is the array filler. + + if (DynamicInit || InitType->isIncompleteArrayType()) { + const Function *CtorFunc = nullptr; + if (const auto *CE = dyn_cast(Init)) { + CtorFunc = getFunction(CE->getConstructor()); + if (!CtorFunc) + return false; + } + + LabelTy EndLabel = this->getLabel(); + LabelTy StartLabel = this->getLabel(); + + // In the nothrow case, the alloc above might have returned nullptr. + // Don't call any constructors that case. + if (IsNoThrow) { + if (!this->emitDupPtr(E)) + return false; + if (!this->emitNullPtr(0, nullptr, E)) + return false; + if (!this->emitEQPtr(E)) + return false; + if (!this->jumpTrue(EndLabel)) + return false; + } + + // Create loop variables. + unsigned Iter = allocateLocalPrimitive( + Stripped, SizeT, /*IsConst=*/false, /*IsExtended=*/false); + if (!this->emitConst(StaticInitElems, SizeT, E)) + return false; + if (!this->emitSetLocal(SizeT, Iter, E)) + return false; + + this->fallthrough(StartLabel); + this->emitLabel(StartLabel); + // Condition. Iter < ArrayLen? + if (!this->emitGetLocal(SizeT, Iter, E)) + return false; + if (!this->emitGetLocal(SizeT, ArrayLen, E)) + return false; + if (!this->emitLT(SizeT, E)) + return false; + if (!this->jumpFalse(EndLabel)) + return false; + + // Pointer to the allocated array is already on the stack. + if (!this->emitGetLocal(SizeT, Iter, E)) + return false; + if (!this->emitArrayElemPtr(SizeT, E)) + return false; + + if (DynamicInit) { + if (std::optional InitT = classify(DynamicInit)) { + if (!this->visit(DynamicInit)) + return false; + if (!this->emitStorePop(*InitT, E)) + return false; + } else { + if (!this->visitInitializer(DynamicInit)) + return false; + if (!this->emitPopPtr(E)) + return false; + } + } else { + assert(CtorFunc); + if (!this->emitCall(CtorFunc, 0, E)) + return false; + } + + // ++Iter; + if (!this->emitGetPtrLocal(Iter, E)) + return false; + if (!this->emitIncPop(SizeT, E)) + return false; + + if (!this->jump(StartLabel)) + return false; + + this->fallthrough(EndLabel); + this->emitLabel(EndLabel); + } + } + } else { // Non-array. if (PlacementDest) { if (!this->visit(PlacementDest)) return false; diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index bf48139f57c0f..c80be094856b0 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1564,34 +1564,38 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E, bool InvalidNewDeleteExpr(InterpState &S, CodePtr OpPC, const Expr *E) { assert(E); - if (S.getLangOpts().CPlusPlus26) - return true; - - const auto &Loc = S.Current->getSource(OpPC); - if (const auto *NewExpr = dyn_cast(E)) { const FunctionDecl *OperatorNew = NewExpr->getOperatorNew(); - if (!S.getLangOpts().CPlusPlus26 && NewExpr->getNumPlacementArgs() > 0) { + if (NewExpr->getNumPlacementArgs() > 0) { // This is allowed pre-C++26, but only an std function. - if (S.Current->isStdFunction()) + if (S.getLangOpts().CPlusPlus26 || S.Current->isStdFunction()) return true; - S.FFDiag(Loc, diag::note_constexpr_new_placement) + S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_new_placement) << /*C++26 feature*/ 1 << E->getSourceRange(); - } else if (NewExpr->getNumPlacementArgs() == 1 && - !OperatorNew->isReservedGlobalPlacementOperator()) { - S.FFDiag(Loc, diag::note_constexpr_new_placement) - << /*Unsupported*/ 0 << E->getSourceRange(); } else if (!OperatorNew->isReplaceableGlobalAllocationFunction()) { - S.FFDiag(Loc, diag::note_constexpr_new_non_replaceable) + S.FFDiag(S.Current->getSource(OpPC), + diag::note_constexpr_new_non_replaceable) << isa(OperatorNew) << OperatorNew; + return false; + } else if (!S.getLangOpts().CPlusPlus26 && + NewExpr->getNumPlacementArgs() == 1 && + !OperatorNew->isReservedGlobalPlacementOperator()) { + if (!S.getLangOpts().CPlusPlus26) { + S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_new_placement) + << /*Unsupported*/ 0 << E->getSourceRange(); + return false; + } + return true; } } else { const auto *DeleteExpr = cast(E); const FunctionDecl *OperatorDelete = DeleteExpr->getOperatorDelete(); if (!OperatorDelete->isReplaceableGlobalAllocationFunction()) { - S.FFDiag(Loc, diag::note_constexpr_new_non_replaceable) + S.FFDiag(S.Current->getSource(OpPC), + diag::note_constexpr_new_non_replaceable) << isa(OperatorDelete) << OperatorDelete; + return false; } } diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 66fd31feb24f4..5cc371c7ee495 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1484,7 +1484,10 @@ bool InitThisBitField(InterpState &S, CodePtr OpPC, const Record::Field *F, template ::T> bool InitField(InterpState &S, CodePtr OpPC, uint32_t I) { const T &Value = S.Stk.pop(); - const Pointer &Field = S.Stk.peek().atField(I); + const Pointer &Ptr = S.Stk.peek(); + if (!CheckRange(S, OpPC, Ptr, CSK_Field)) + return false; + const Pointer &Field = Ptr.atField(I); Field.deref() = Value; Field.activate(); Field.initialize(); diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp index e0b86d46428a2..833c9ef88d770 100644 --- a/clang/lib/AST/ByteCode/Program.cpp +++ b/clang/lib/AST/ByteCode/Program.cpp @@ -18,14 +18,12 @@ using namespace clang; using namespace clang::interp; unsigned Program::getOrCreateNativePointer(const void *Ptr) { - auto It = NativePointerIndices.find(Ptr); - if (It != NativePointerIndices.end()) - return It->second; + auto [It, Inserted] = + NativePointerIndices.try_emplace(Ptr, NativePointers.size()); + if (Inserted) + NativePointers.push_back(Ptr); - unsigned Idx = NativePointers.size(); - NativePointers.push_back(Ptr); - NativePointerIndices[Ptr] = Idx; - return Idx; + return It->second; } const void *Program::getNativePointer(unsigned Idx) { diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp index fddedd3a31856..9658c6ab3d39d 100644 --- a/clang/lib/AST/RawCommentList.cpp +++ b/clang/lib/AST/RawCommentList.cpp @@ -287,13 +287,13 @@ void RawCommentList::addComment(const RawComment &RC, // If this is the first Doxygen comment, save it (because there isn't // anything to merge it with). - if (OrderedComments[CommentFile].empty()) { - OrderedComments[CommentFile][CommentOffset] = - new (Allocator) RawComment(RC); + auto &OC = OrderedComments[CommentFile]; + if (OC.empty()) { + OC[CommentOffset] = new (Allocator) RawComment(RC); return; } - const RawComment &C1 = *OrderedComments[CommentFile].rbegin()->second; + const RawComment &C1 = *OC.rbegin()->second; const RawComment &C2 = RC; // Merge comments only if there is only whitespace between them. diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index fa3055dd1206f..19d76df99dbe3 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() { // // Do not set ThunkInfo::Method if Idx is already in VTableThunks. This // can happen when covariant return adjustment is required too. - if (!VTableThunks.count(Idx)) { + auto [It, Inserted] = VTableThunks.try_emplace(Idx); + if (Inserted) { const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD); - VTableThunks[Idx].Method = Method; - VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr(); + It->second.Method = Method; + It->second.ThisType = Method->getThisType().getTypePtr(); } - VTableThunks[Idx].This = ThisAdjustment; + It->second.This = ThisAdjustment; }; SetThisAdjustmentThunk(VTableIndex); @@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods( // findOriginalMethod to find the method that created the entry if the // method in the entry requires adjustment. if (!ReturnAdjustment.isEmpty()) { - VTableThunks[Components.size()].Method = MD; - VTableThunks[Components.size()].ThisType = MD->getThisType().getTypePtr(); + auto &VTT = VTableThunks[Components.size()]; + VTT.Method = MD; + VTT.ThisType = MD->getThisType().getTypePtr(); } AddMethod(Overrider.Method, ReturnAdjustment); diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index bf2f730618650..3a052eb27a444 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -379,8 +379,10 @@ void ClassifyRefs::classify(const Expr *E, Class C) { } FindVarResult Var = findVar(E, DC); - if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) - Classification[DRE] = std::max(Classification[DRE], C); + if (const DeclRefExpr *DRE = Var.getDeclRefExpr()) { + auto &Class = Classification[DRE]; + Class = std::max(Class, C); + } } void ClassifyRefs::VisitDeclStmt(DeclStmt *DS) { diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp index c064aa30e8aed..c51398698922b 100644 --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -930,7 +930,7 @@ AST_MATCHER(CallExpr, hasUnsafeSnprintfBuffer) { // The array element type must be compatible with `char` otherwise an // explicit cast will be needed, which will make this check unreachable. // Therefore, the array extent is same as its' bytewise size. - if (Size->EvaluateAsConstantExpr(ER, Ctx)) { + if (Size->EvaluateAsInt(ER, Ctx)) { APSInt EVal = ER.Val.getInt(); // Size must have integer type return APSInt::compareValues(EVal, APSInt(CAT->getSize(), true)) != 0; diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb..a748ddaa110a5 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -197,10 +197,7 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { - return llvm::PointerType::get( - ElementType, - llvm::cast(Pointer.getPointer()->getType()) - ->getAddressSpace()); + return llvm::cast(Pointer.getPointer()->getType()); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 57106e4287765..1750719e17670 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -124,15 +124,25 @@ namespace clang { extern llvm::cl::opt ClSanitizeGuardChecks; } -namespace { - // Default filename used for profile generation. -std::string getDefaultProfileGenName() { +static std::string getDefaultProfileGenName() { return DebugInfoCorrelate || ProfileCorrelate != InstrProfCorrelator::NONE ? "default_%m.proflite" : "default_%m.profraw"; } +// Path and name of file used for profile generation +static std::string getProfileGenName(const CodeGenOptions &CodeGenOpts) { + std::string FileName = CodeGenOpts.InstrProfileOutput.empty() + ? getDefaultProfileGenName() + : CodeGenOpts.InstrProfileOutput; + if (CodeGenOpts.ContinuousProfileSync) + FileName = "%c" + FileName; + return FileName; +} + +namespace { + class EmitAssemblyHelper { CompilerInstance &CI; DiagnosticsEngine &Diags; @@ -551,7 +561,9 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts, return std::nullopt; InstrProfOptions Options; Options.NoRedZone = CodeGenOpts.DisableRedZone; - Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput; + Options.InstrProfileOutput = CodeGenOpts.ContinuousProfileSync + ? ("%c" + CodeGenOpts.InstrProfileOutput) + : CodeGenOpts.InstrProfileOutput; Options.Atomic = CodeGenOpts.AtomicProfileUpdate; return Options; } @@ -822,13 +834,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline( if (CodeGenOpts.hasProfileIRInstr()) // -fprofile-generate. - PGOOpt = PGOOptions( - CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName() - : CodeGenOpts.InstrProfileOutput, - "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr, - PGOOptions::NoCSAction, ClPGOColdFuncAttr, - CodeGenOpts.DebugInfoForProfiling, - /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate); + PGOOpt = PGOOptions(getProfileGenName(CodeGenOpts), "", "", + CodeGenOpts.MemoryProfileUsePath, nullptr, + PGOOptions::IRInstr, PGOOptions::NoCSAction, + ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, + /*PseudoProbeForProfiling=*/false, + CodeGenOpts.AtomicProfileUpdate); else if (CodeGenOpts.hasProfileIRUse()) { // -fprofile-use. auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse @@ -872,18 +883,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PGOOpt->Action != PGOOptions::SampleUse && "Cannot run CSProfileGen pass with ProfileGen or SampleUse " " pass"); - PGOOpt->CSProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() - ? getDefaultProfileGenName() - : CodeGenOpts.InstrProfileOutput; + PGOOpt->CSProfileGenFile = getProfileGenName(CodeGenOpts); PGOOpt->CSAction = PGOOptions::CSIRInstr; } else - PGOOpt = PGOOptions("", - CodeGenOpts.InstrProfileOutput.empty() - ? getDefaultProfileGenName() - : CodeGenOpts.InstrProfileOutput, - "", /*MemoryProfile=*/"", nullptr, - PGOOptions::NoAction, PGOOptions::CSIRInstr, - ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling); + PGOOpt = PGOOptions("", getProfileGenName(CodeGenOpts), "", + /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction, + PGOOptions::CSIRInstr, ClPGOColdFuncAttr, + CodeGenOpts.DebugInfoForProfiling); } if (TM) TM->setPGOOption(PGOOpt); diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547..faef6a5fbe1f5 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = - getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers; // !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f..668282a6ab1a8 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. - QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; - // Make a new global with the correct type / address space. - llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); - llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); + llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry @@ -2891,8 +2888,7 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { Entry->mutateType(PTy); llvm::Constant *NewPtrForOldDecl = - llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast( - Entry, DummyGV->getType()); + llvm::ConstantExpr::getAddrSpaceCast(Entry, DummyGV->getType()); // Now we have a casted version of the changed global, the dummy can be // replaced and deleted. diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac..f5950f03673a1 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -345,10 +345,7 @@ void CodeGenFunction::registerGlobalDtorWithLLVM(const VarDecl &VD, void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); - assert(dtorStub->getType() == - llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), - dtorStub->getType()->getPointerAddressSpace()) && + assert(dtorStub->getType()->isPointerTy() && "Argument to atexit has a wrong type."); llvm::FunctionType *atexitTy = @@ -372,10 +369,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // value is returned. // // extern "C" int unatexit(void (*f)(void)); - assert(dtorStub->getType() == - llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), - dtorStub->getType()->getPointerAddressSpace()) && + assert(dtorStub->getType()->isPointerTy() && "Argument to unatexit has a wrong type."); llvm::FunctionType *unatexitTy = diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 1e233c42c8782..2bbc0791c6587 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -872,7 +872,7 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *TypeHash = llvm::ConstantInt::get(Int64Ty, xxh3_64bits(Out.str())); - llvm::Type *VPtrTy = llvm::PointerType::get(IntPtrTy, 0); + llvm::Type *VPtrTy = llvm::PointerType::get(getLLVMContext(), 0); Address VPtrAddr(Ptr, IntPtrTy, getPointerAlign()); llvm::Value *VPtrVal = GetVTablePtr(VPtrAddr, VPtrTy, Ty->getAsCXXRecordDecl(), @@ -3054,7 +3054,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { getContext().getDeclAlign(VD)); llvm::Type *VarTy = getTypes().ConvertTypeForMem(VD->getType()); auto *PTy = llvm::PointerType::get( - VarTy, getTypes().getTargetAddressSpace(VD->getType())); + getLLVMContext(), getTypes().getTargetAddressSpace(VD->getType())); Addr = Builder.CreatePointerBitCastOrAddrSpaceCast(Addr, PTy, VarTy); } else { // Should we be using the alignment of the constant pointer we emitted? diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index dd900f9b32fb7..6c929a6431c0f 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -5717,7 +5717,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) IntTy = CGM.IntTy; LongTy = cast(Types.ConvertType(Ctx.LongTy)); Int8PtrTy = CGM.Int8PtrTy; - Int8PtrProgramASTy = llvm::PointerType::get(CGM.Int8Ty, ProgramAS); + Int8PtrProgramASTy = llvm::PointerType::get(CGM.getLLVMContext(), ProgramAS); Int8PtrPtrTy = CGM.Int8PtrPtrTy; // arm64 targets use "int" ivar offset variables. All others, diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 47c03ea5e72cb..7924c32fcf633 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -486,8 +486,10 @@ void CodeGenModule::createOpenMPRuntime() { case llvm::Triple::nvptx: case llvm::Triple::nvptx64: case llvm::Triple::amdgcn: - assert(getLangOpts().OpenMPIsTargetDevice && - "OpenMP AMDGPU/NVPTX is only prepared to deal with device code."); + case llvm::Triple::spirv64: + assert( + getLangOpts().OpenMPIsTargetDevice && + "OpenMP AMDGPU/NVPTX/SPIRV is only prepared to deal with device code."); OpenMPRuntime.reset(new CGOpenMPRuntimeGPU(*this)); break; default: @@ -4432,7 +4434,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { GlobalDecl ResolverGD; if (getTarget().supportsIFunc()) { ResolverType = llvm::FunctionType::get( - llvm::PointerType::get(DeclTy, + llvm::PointerType::get(getLLVMContext(), getTypes().getTargetAddressSpace(FD->getType())), false); } @@ -4604,8 +4606,8 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) { // cpu_dispatch will be emitted in this translation unit. if (ShouldReturnIFunc) { unsigned AS = getTypes().getTargetAddressSpace(FD->getType()); - llvm::Type *ResolverType = - llvm::FunctionType::get(llvm::PointerType::get(DeclTy, AS), false); + llvm::Type *ResolverType = llvm::FunctionType::get( + llvm::PointerType::get(getLLVMContext(), AS), false); llvm::Constant *Resolver = GetOrCreateLLVMFunction( MangledName + ".resolver", ResolverType, GlobalDecl{}, /*ForVTable=*/false); diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index 4922b082cf09c..dc3a1d4287be1 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -843,7 +843,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, llvm::Type *BaseTy = CGF.ConvertType(Ty); if (IsIndirect) - BaseTy = llvm::PointerType::getUnqual(BaseTy); + BaseTy = llvm::PointerType::getUnqual(BaseTy->getContext()); else if (AI.getCoerceToType()) BaseTy = AI.getCoerceToType(); @@ -961,7 +961,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, if (IsIndirect) { // If it's been passed indirectly (actually a struct), whatever we find from // stored registers or on the stack will actually be a struct **. - MemTy = llvm::PointerType::getUnqual(MemTy); + MemTy = llvm::PointerType::getUnqual(MemTy->getContext()); } const Type *Base = nullptr; diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 8fd2a81494d99..aada8d0d61303 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -336,10 +336,6 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, // Implement the block where argument is in register saved area CGF.EmitBlock(InRegBlock); - llvm::Type *PTy = CGF.ConvertType(Ty); - llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast( - __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy)); - CGF.Builder.CreateStore(__new_saved_reg_area_pointer, __current_saved_reg_area_pointer_p); @@ -388,22 +384,16 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, CGF.Builder.CreateStore(__new_overflow_area_pointer, __current_saved_reg_area_pointer_p); - // Bitcast the overflow area pointer to the type of argument. - llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty); - llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast( - __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy)); - CGF.EmitBranch(ContBlock); - // Get the correct pointer to load the variable argument // Implement the ContBlock CGF.EmitBlock(ContBlock); llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); - llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy); - llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr"); - ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock); - ArgAddr->addIncoming(__overflow_area_p, OnStackBlock); + llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( + llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); + ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); } diff --git a/clang/lib/CodeGen/Targets/SystemZ.cpp b/clang/lib/CodeGen/Targets/SystemZ.cpp index 23c96fa5cf98c..9bb8ddbc548d2 100644 --- a/clang/lib/CodeGen/Targets/SystemZ.cpp +++ b/clang/lib/CodeGen/Targets/SystemZ.cpp @@ -272,7 +272,7 @@ RValue SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, SZCGI.handleExternallyVisibleObjABI(Ty.getTypePtr(), CGT.getCGM(), /*IsParam*/true); if (IsIndirect) { - DirectTy = llvm::PointerType::getUnqual(DirectTy); + DirectTy = llvm::PointerType::getUnqual(DirectTy->getContext()); UnpaddedSize = DirectAlign = CharUnits::fromQuantity(8); } else { if (AI.getCoerceToType()) diff --git a/clang/lib/CodeGen/Targets/XCore.cpp b/clang/lib/CodeGen/Targets/XCore.cpp index ced4981fd124f..b7824bde5f55a 100644 --- a/clang/lib/CodeGen/Targets/XCore.cpp +++ b/clang/lib/CodeGen/Targets/XCore.cpp @@ -149,7 +149,7 @@ RValue XCoreABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, llvm::Type *ArgTy = CGT.ConvertType(Ty); if (AI.canHaveCoerceToType() && !AI.getCoerceToType()) AI.setCoerceToType(ArgTy); - llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy); + llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy->getContext()); Address Val = Address::invalid(); CharUnits ArgSize = CharUnits::Zero(); diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp index 9faf2a8a17341..ad2ebb6cd6e6c 100644 --- a/clang/lib/CrossTU/CrossTranslationUnit.cpp +++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp @@ -453,7 +453,8 @@ CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction( return std::move(IndexLoadError); // Check if there is an entry in the index for the function. - if (!NameFileMap.count(FunctionName)) { + auto It = NameFileMap.find(FunctionName); + if (It == NameFileMap.end()) { ++NumNotInOtherTU; return llvm::make_error(index_error_code::missing_definition); } @@ -461,7 +462,7 @@ CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction( // Search in the index for the filename where the definition of FunctionName // resides. if (llvm::Expected FoundForFile = - getASTUnitForFile(NameFileMap[FunctionName], DisplayCTUProgress)) { + getASTUnitForFile(It->second, DisplayCTUProgress)) { // Update the cache. NameASTUnitMap[FunctionName] = *FoundForFile; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 62d4336c6be59..5deafa2ad0f4a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -580,6 +580,7 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C, const ArgList &Args, SanitizerArgs &SanArgs, ArgStringList &CmdArgs) { const Driver &D = TC.getDriver(); + const llvm::Triple &T = TC.getTriple(); auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate, options::OPT_fprofile_generate_EQ, options::OPT_fno_profile_generate); @@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C, D.Diag(diag::err_drv_unsupported_option_argument) << A->getSpelling() << Val; } + if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) { + if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg) + D.Diag(clang::diag::err_drv_argument_only_allowed_with) + << A->getSpelling() + << "-fprofile-generate, -fprofile-instr-generate, or " + "-fcs-profile-generate"; + else { + CmdArgs.push_back("-fprofile-continuous"); + // Platforms that require a bias variable: + if (T.isOSBinFormatELF() || T.isOSAIX()) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-runtime-counter-relocation"); + } + // -fprofile-instr-generate does not decide the profile file name in the + // FE, and so it does not define the filename symbol + // (__llvm_profile_filename). Instead, the runtime uses the name + // "default.profraw" for the profile file. When continuous mode is ON, we + // will create the filename symbol so that we can insert the "%c" + // modifier. + if (ProfileGenerateArg && + (ProfileGenerateArg->getOption().matches( + options::OPT_fprofile_instr_generate) || + (ProfileGenerateArg->getOption().matches( + options::OPT_fprofile_instr_generate_EQ) && + strlen(ProfileGenerateArg->getValue()) == 0))) + CmdArgs.push_back("-fprofile-instrument-path=default.profraw"); + } + } int FunctionGroups = 1; int SelectedFunctionGroup = 0; @@ -1013,21 +1042,23 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, ArgM = ArgMD; if (ArgM) { - // Determine the output location. - const char *DepFile; - if (Arg *MF = Args.getLastArg(options::OPT_MF)) { - DepFile = MF->getValue(); - C.addFailureResultFile(DepFile, &JA); - } else if (Output.getType() == types::TY_Dependencies) { - DepFile = Output.getFilename(); - } else if (!ArgMD) { - DepFile = "-"; - } else { - DepFile = getDependencyFileName(Args, Inputs); - C.addFailureResultFile(DepFile, &JA); + if (!JA.isDeviceOffloading(Action::OFK_HIP)) { + // Determine the output location. + const char *DepFile; + if (Arg *MF = Args.getLastArg(options::OPT_MF)) { + DepFile = MF->getValue(); + C.addFailureResultFile(DepFile, &JA); + } else if (Output.getType() == types::TY_Dependencies) { + DepFile = Output.getFilename(); + } else if (!ArgMD) { + DepFile = "-"; + } else { + DepFile = getDependencyFileName(Args, Inputs); + C.addFailureResultFile(DepFile, &JA); + } + CmdArgs.push_back("-dependency-file"); + CmdArgs.push_back(DepFile); } - CmdArgs.push_back("-dependency-file"); - CmdArgs.push_back(DepFile); bool HasTarget = false; for (const Arg *A : Args.filtered(options::OPT_MT, options::OPT_MQ)) { @@ -1358,6 +1389,7 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) { return true; return false; + case llvm::Triple::csky: case llvm::Triple::hexagon: case llvm::Triple::msp430: case llvm::Triple::ppcle: @@ -9131,7 +9163,7 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA, SmallVector Parts{ "file=" + File.str(), "triple=" + TC->getTripleString(), - "arch=" + Arch.str(), + "arch=" + (Arch.empty() ? "generic" : Arch.str()), "kind=" + Kind.str(), }; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index e0b5d003ebb13..9a4d3f55c911c 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C, /// Add Fortran runtime libs void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, llvm::opt::ArgStringList &CmdArgs) { - // Link FortranRuntime + // Link flang_rt.runtime // These are handled earlier on Windows by telling the frontend driver to // add the correct libraries to link against as dependents in the object // file. @@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args, F128LibName.consume_front_insensitive("lib"); if (!F128LibName.empty()) { bool AsNeeded = !TC.getTriple().isOSAIX(); - CmdArgs.push_back("-lFortranFloat128Math"); + CmdArgs.push_back("-lflang_rt.quadmath"); if (AsNeeded) addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); if (AsNeeded) addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } - CmdArgs.push_back("-lFortranRuntime"); + CmdArgs.push_back("-lflang_rt.runtime"); addArchSpecificRPath(TC, Args, CmdArgs); // needs libexecinfo for backtrace functions @@ -3096,21 +3096,39 @@ bool tools::shouldRecordCommandLine(const ToolChain &TC, void tools::renderCommonIntegerOverflowOptions(const ArgList &Args, ArgStringList &CmdArgs) { - // -fno-strict-overflow implies -fwrapv if it isn't disabled, but - // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. - bool StrictOverflow = Args.hasFlag(options::OPT_fstrict_overflow, - options::OPT_fno_strict_overflow, true); - if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { - if (A->getOption().matches(options::OPT_fwrapv)) - CmdArgs.push_back("-fwrapv"); - } else if (!StrictOverflow) { - CmdArgs.push_back("-fwrapv"); + bool use_fwrapv = false; + bool use_fwrapv_pointer = false; + for (const Arg *A : Args.filtered( + options::OPT_fstrict_overflow, options::OPT_fno_strict_overflow, + options::OPT_fwrapv, options::OPT_fno_wrapv, + options::OPT_fwrapv_pointer, options::OPT_fno_wrapv_pointer)) { + A->claim(); + switch (A->getOption().getID()) { + case options::OPT_fstrict_overflow: + use_fwrapv = false; + use_fwrapv_pointer = false; + break; + case options::OPT_fno_strict_overflow: + use_fwrapv = true; + use_fwrapv_pointer = true; + break; + case options::OPT_fwrapv: + use_fwrapv = true; + break; + case options::OPT_fno_wrapv: + use_fwrapv = false; + break; + case options::OPT_fwrapv_pointer: + use_fwrapv_pointer = true; + break; + case options::OPT_fno_wrapv_pointer: + use_fwrapv_pointer = false; + break; + } } - if (Arg *A = Args.getLastArg(options::OPT_fwrapv_pointer, - options::OPT_fno_wrapv_pointer)) { - if (A->getOption().matches(options::OPT_fwrapv_pointer)) - CmdArgs.push_back("-fwrapv-pointer"); - } else if (!StrictOverflow) { + + if (use_fwrapv) + CmdArgs.push_back("-fwrapv"); + if (use_fwrapv_pointer) CmdArgs.push_back("-fwrapv-pointer"); - } } diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index c7d5893085080..d6487d4bc274d 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -639,9 +639,6 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back( Args.MakeArgString("--plugin-opt=-mattr=" + llvm::join(Features, ","))); - // Enable ctor / dtor lowering for the direct / freestanding NVPTX target. - CmdArgs.append({"-mllvm", "--nvptx-lower-global-ctor-dtor"}); - // Add paths for the default clang library path. SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(TC.getDriver().Dir); @@ -726,9 +723,8 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple, /// toolchain. NVPTXToolChain::NVPTXToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::Triple &HostTriple, - const ArgList &Args, bool Freestanding = false) - : ToolChain(D, Triple, Args), CudaInstallation(D, HostTriple, Args), - Freestanding(Freestanding) { + const ArgList &Args) + : ToolChain(D, Triple, Args), CudaInstallation(D, HostTriple, Args) { if (CudaInstallation.isValid()) getProgramPaths().push_back(std::string(CudaInstallation.getBinPath())); // Lookup binaries into the driver directory, this is used to @@ -740,8 +736,7 @@ NVPTXToolChain::NVPTXToolChain(const Driver &D, const llvm::Triple &Triple, /// system's default triple if not provided. NVPTXToolChain::NVPTXToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : NVPTXToolChain(D, Triple, llvm::Triple(LLVM_HOST_TRIPLE), Args, - /*Freestanding=*/true) {} + : NVPTXToolChain(D, Triple, llvm::Triple(LLVM_HOST_TRIPLE), Args) {} llvm::opt::DerivedArgList * NVPTXToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args, @@ -782,13 +777,7 @@ NVPTXToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args, void NVPTXToolChain::addClangTargetOptions( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, - Action::OffloadKind DeviceOffloadingKind) const { - // If we are compiling with a standalone NVPTX toolchain we want to try to - // mimic a standard environment as much as possible. So we enable lowering - // ctor / dtor functions to global symbols that can be registered. - if (Freestanding && !getDriver().isUsingLTO()) - CC1Args.append({"-mllvm", "--nvptx-lower-global-ctor-dtor"}); -} + Action::OffloadKind DeviceOffloadingKind) const {} bool NVPTXToolChain::supportsDebugInfoOption(const llvm::opt::Arg *A) const { const Option &O = A->getOption(); diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h index c2219ec47cfa9..259eda6ebcadf 100644 --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -132,8 +132,8 @@ namespace toolchains { class LLVM_LIBRARY_VISIBILITY NVPTXToolChain : public ToolChain { public: NVPTXToolChain(const Driver &D, const llvm::Triple &Triple, - const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, - bool Freestanding); + const llvm::Triple &HostTriple, + const llvm::opt::ArgList &Args); NVPTXToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); @@ -179,9 +179,6 @@ class LLVM_LIBRARY_VISIBILITY NVPTXToolChain : public ToolChain { protected: Tool *buildAssembler() const override; // ptxas. Tool *buildLinker() const override; // nvlink. - -private: - bool Freestanding = false; }; class LLVM_LIBRARY_VISIBILITY CudaToolChain : public NVPTXToolChain { diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index e7b68f4a8c60a..591003f56e8bb 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -346,11 +346,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { assert(TC.getTriple().isKnownWindowsMSVCEnvironment() && "can only add VS runtime library on Windows!"); - // if -fno-fortran-main has been passed, skip linking Fortran_main.a - if (TC.getTriple().isKnownWindowsMSVCEnvironment()) { - CmdArgs.push_back(Args.MakeArgString( - "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins"))); - } + + // Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI + // should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt + // functions in some cases like 128-bit integer math (__udivti3, __modti3, + // __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a + // dependency to Compiler-RT's builtin library where these are implemented. + CmdArgs.push_back(Args.MakeArgString( + "--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins"))); + unsigned RTOptionID = options::OPT__SLASH_MT; if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) { RTOptionID = llvm::StringSwitch(rtl->getValue()) @@ -364,26 +368,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args, case options::OPT__SLASH_MT: CmdArgs.push_back("-D_MT"); CmdArgs.push_back("--dependent-lib=libcmt"); - CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib"); + CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static.lib"); break; case options::OPT__SLASH_MTd: CmdArgs.push_back("-D_MT"); CmdArgs.push_back("-D_DEBUG"); CmdArgs.push_back("--dependent-lib=libcmtd"); - CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib"); + CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static_dbg.lib"); break; case options::OPT__SLASH_MD: CmdArgs.push_back("-D_MT"); CmdArgs.push_back("-D_DLL"); CmdArgs.push_back("--dependent-lib=msvcrt"); - CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib"); + CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic.lib"); break; case options::OPT__SLASH_MDd: CmdArgs.push_back("-D_MT"); CmdArgs.push_back("-D_DEBUG"); CmdArgs.push_back("-D_DLL"); CmdArgs.push_back("--dependent-lib=msvcrtd"); - CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib"); + CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic_dbg.lib"); break; } } diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 387daad934f67..0898b69528ebc 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -995,6 +995,7 @@ template <> struct MappingTraits { Style.AlwaysBreakBeforeMultilineStrings); IO.mapOptional("AttributeMacros", Style.AttributeMacros); IO.mapOptional("BinPackArguments", Style.BinPackArguments); + IO.mapOptional("BinPackLongBracedList", Style.BinPackLongBracedList); IO.mapOptional("BinPackParameters", Style.BinPackParameters); IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing); IO.mapOptional("BracedInitializerIndentWidth", @@ -1507,6 +1508,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.AlwaysBreakBeforeMultilineStrings = false; LLVMStyle.AttributeMacros.push_back("__capability"); LLVMStyle.BinPackArguments = true; + LLVMStyle.BinPackLongBracedList = true; LLVMStyle.BinPackParameters = FormatStyle::BPPS_BinPack; LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both; LLVMStyle.BracedInitializerIndentWidth = std::nullopt; diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 99bce1f5f0985..fb040a0043602 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -175,7 +175,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) { // have many items (20 or more) or we allow bin-packing of function call // arguments. if (Style.Cpp11BracedListStyle && !Style.BinPackArguments && - Commas.size() < 19) { + (Commas.size() < 19 || !Style.BinPackLongBracedList)) { return; } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 94fd7ba9c0e79..b3540f39e6f69 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -477,8 +477,9 @@ class AnnotatingParser { FormatToken *PossibleObjCForInToken = nullptr; while (CurrentToken) { const auto &Prev = *CurrentToken->Previous; + const auto *PrevPrev = Prev.Previous; if (Prev.is(TT_PointerOrReference) && - Prev.Previous->isOneOf(tok::l_paren, tok::coloncolon)) { + PrevPrev->isOneOf(tok::l_paren, tok::coloncolon)) { ProbablyFunctionType = true; } if (CurrentToken->is(tok::comma)) @@ -486,8 +487,10 @@ class AnnotatingParser { if (Prev.is(TT_BinaryOperator)) Contexts.back().IsExpression = true; if (CurrentToken->is(tok::r_paren)) { - if (Prev.is(TT_PointerOrReference) && Prev.Previous == &OpeningParen) + if (Prev.is(TT_PointerOrReference) && + (PrevPrev == &OpeningParen || PrevPrev->is(tok::coloncolon))) { MightBeFunctionType = true; + } if (OpeningParen.isNot(TT_CppCastLParen) && MightBeFunctionType && ProbablyFunctionType && CurrentToken->Next && (CurrentToken->Next->is(tok::l_paren) || diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h b/clang/lib/Headers/avx10_2_512convertintrin.h index 0b5fca5cda522..516ccc68672d6 100644 --- a/clang/lib/Headers/avx10_2_512convertintrin.h +++ b/clang/lib/Headers/avx10_2_512convertintrin.h @@ -213,19 +213,19 @@ _mm512_maskz_cvts2ph_hf8(__mmask64 __U, __m512h __A, __m512h __B) { (__v64qi)(__m512i)_mm512_setzero_si512()); } -static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8(__m256i __A) { +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8_ph(__m256i __A) { return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( (__v32qi)__A, (__v32hf)(__m512h)_mm512_undefined_ph(), (__mmask32)-1); } static __inline__ __m512h __DEFAULT_FN_ATTRS512 -_mm512_mask_cvthf8(__m512h __W, __mmask32 __U, __m256i __A) { +_mm512_mask_cvthf8_ph(__m512h __W, __mmask32 __U, __m256i __A) { return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( (__v32qi)__A, (__v32hf)(__m512h)__W, (__mmask32)__U); } static __inline__ __m512h __DEFAULT_FN_ATTRS512 -_mm512_maskz_cvthf8(__mmask32 __U, __m256i __A) { +_mm512_maskz_cvthf8_ph(__mmask32 __U, __m256i __A) { return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( (__v32qi)__A, (__v32hf)(__m512h)_mm512_setzero_ph(), (__mmask32)__U); } diff --git a/clang/lib/Headers/avx10_2convertintrin.h b/clang/lib/Headers/avx10_2convertintrin.h index c67a5b890f195..07722090c30ee 100644 --- a/clang/lib/Headers/avx10_2convertintrin.h +++ b/clang/lib/Headers/avx10_2convertintrin.h @@ -260,13 +260,13 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_cvt2ph_bf8(__m256h __A, static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvt2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)__W); + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)__W); } static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_cvt2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)(__m256i)_mm256_setzero_si256()); } @@ -297,13 +297,13 @@ _mm256_cvts2ph_bf8(__m256h __A, __m256h __B) { static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), (__v32qi)__W); + (__mmask32)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), (__v32qi)__W); } static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_cvts2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), + (__mmask32)__U, (__v32qi)_mm256_cvts2ph_bf8(__A, __B), (__v32qi)(__m256i)_mm256_setzero_si256()); } @@ -334,13 +334,13 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_cvt2ph_hf8(__m256h __A, static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvt2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)__W); + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)__W); } static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_cvt2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)(__m256i)_mm256_setzero_si256()); } @@ -371,47 +371,46 @@ _mm256_cvts2ph_hf8(__m256h __A, __m256h __B) { static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), (__v32qi)__W); + (__mmask32)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), (__v32qi)__W); } static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_cvts2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { return (__m256i)__builtin_ia32_selectb_256( - (__mmask16)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), + (__mmask32)__U, (__v32qi)_mm256_cvts2ph_hf8(__A, __B), (__v32qi)(__m256i)_mm256_setzero_si256()); } -static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8(__m128i __A) { +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8_ph(__m128i __A) { return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( (__v16qi)__A, (__v8hf)(__m128h)_mm_undefined_ph(), (__mmask8)-1); } -static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvthf8(__m128h __W, - __mmask8 __U, - __m128i __A) { +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvthf8_ph(__m128h __W, __mmask8 __U, __m128i __A) { return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( (__v16qi)__A, (__v8hf)(__m128h)__W, (__mmask8)__U); } -static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvthf8(__mmask8 __U, - __m128i __A) { +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvthf8_ph(__mmask8 __U, __m128i __A) { return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( (__v16qi)__A, (__v8hf)(__m128h)_mm_setzero_ph(), (__mmask8)__U); } -static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8(__m128i __A) { +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8_ph(__m128i __A) { return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( (__v16qi)__A, (__v16hf)(__m256h)_mm256_undefined_ph(), (__mmask16)-1); } static __inline__ __m256h __DEFAULT_FN_ATTRS256 -_mm256_mask_cvthf8(__m256h __W, __mmask16 __U, __m128i __A) { +_mm256_mask_cvthf8_ph(__m256h __W, __mmask16 __U, __m128i __A) { return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( (__v16qi)__A, (__v16hf)(__m256h)__W, (__mmask16)__U); } static __inline__ __m256h __DEFAULT_FN_ATTRS256 -_mm256_maskz_cvthf8(__mmask16 __U, __m128i __A) { +_mm256_maskz_cvthf8_ph(__mmask16 __U, __m128i __A) { return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( (__v16qi)__A, (__v16hf)(__m256h)_mm256_setzero_ph(), (__mmask16)__U); } diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp index c18daf7faa749..f1dc4d5831ce7 100644 --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -130,6 +130,9 @@ class BodyIndexer : public RecursiveASTVisitor { void addCallRole(SymbolRoleSet &Roles, SmallVectorImpl &Relations) { + if (isa(ParentDC)) + return; + Roles |= (unsigned)SymbolRole::Call; if (auto *FD = dyn_cast(ParentDC)) Relations.emplace_back((unsigned)SymbolRole::RelationCalledBy, FD); diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index ccf94f6345ff2..998e2b977d109 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -2928,9 +2928,10 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) { ActiveModule->InferExplicitSubmodules = Explicit; } else { // We'll be inferring framework modules for this directory. - Map.InferredDirectories[Directory].InferModules = true; - Map.InferredDirectories[Directory].Attrs = Attrs; - Map.InferredDirectories[Directory].ModuleMapFID = ModuleMapFID; + auto &InfDir = Map.InferredDirectories[Directory]; + InfDir.InferModules = true; + InfDir.Attrs = Attrs; + InfDir.ModuleMapFID = ModuleMapFID; // FIXME: Handle the 'framework' keyword. } diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 347c13da0ad21..944966a791add 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1798,54 +1798,55 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { return II && HasExtension(*this, II->getName()); }); } else if (II == Ident__has_builtin) { - EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false, - [this](Token &Tok, bool &HasLexedNextToken) -> int { - IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this, - diag::err_feature_check_malformed); - if (!II) - return false; - else if (II->getBuiltinID() != 0) { - switch (II->getBuiltinID()) { - case Builtin::BI__builtin_cpu_is: - return getTargetInfo().supportsCpuIs(); - case Builtin::BI__builtin_cpu_init: - return getTargetInfo().supportsCpuInit(); - case Builtin::BI__builtin_cpu_supports: - return getTargetInfo().supportsCpuSupports(); - case Builtin::BI__builtin_operator_new: - case Builtin::BI__builtin_operator_delete: - // denotes date of behavior change to support calling arbitrary - // usual allocation and deallocation functions. Required by libc++ - return 201802; - default: - return Builtin::evaluateRequiredTargetFeatures( - getBuiltinInfo().getRequiredFeatures(II->getBuiltinID()), - getTargetInfo().getTargetOpts().FeatureMap); + EvaluateFeatureLikeBuiltinMacro( + OS, Tok, II, *this, false, + [this](Token &Tok, bool &HasLexedNextToken) -> int { + IdentifierInfo *II = ExpectFeatureIdentifierInfo( + Tok, *this, diag::err_feature_check_malformed); + if (!II) + return false; + else if (II->getBuiltinID() != 0) { + switch (II->getBuiltinID()) { + case Builtin::BI__builtin_cpu_is: + return getTargetInfo().supportsCpuIs(); + case Builtin::BI__builtin_cpu_init: + return getTargetInfo().supportsCpuInit(); + case Builtin::BI__builtin_cpu_supports: + return getTargetInfo().supportsCpuSupports(); + case Builtin::BI__builtin_operator_new: + case Builtin::BI__builtin_operator_delete: + // denotes date of behavior change to support calling arbitrary + // usual allocation and deallocation functions. Required by libc++ + return 201802; + default: + return Builtin::evaluateRequiredTargetFeatures( + getBuiltinInfo().getRequiredFeatures(II->getBuiltinID()), + getTargetInfo().getTargetOpts().FeatureMap); + } + return true; + } else if (IsBuiltinTrait(Tok)) { + return true; + } else if (II->getTokenID() != tok::identifier && + II->getName().starts_with("__builtin_")) { + return true; + } else { + return llvm::StringSwitch(II->getName()) + // Report builtin templates as being builtins. + .Case("__make_integer_seq", getLangOpts().CPlusPlus) + .Case("__type_pack_element", getLangOpts().CPlusPlus) + .Case("__builtin_common_type", getLangOpts().CPlusPlus) + // Likewise for some builtin preprocessor macros. + // FIXME: This is inconsistent; we usually suggest detecting + // builtin macros via #ifdef. Don't add more cases here. + .Case("__is_target_arch", true) + .Case("__is_target_vendor", true) + .Case("__is_target_os", true) + .Case("__is_target_environment", true) + .Case("__is_target_variant_os", true) + .Case("__is_target_variant_environment", true) + .Default(false); } - return true; - } else if (IsBuiltinTrait(Tok)) { - return true; - } else if (II->getTokenID() != tok::identifier && - II->getName().starts_with("__builtin_")) { - return true; - } else { - return llvm::StringSwitch(II->getName()) - // Report builtin templates as being builtins. - .Case("__make_integer_seq", getLangOpts().CPlusPlus) - .Case("__type_pack_element", getLangOpts().CPlusPlus) - .Case("__builtin_common_type", getLangOpts().CPlusPlus) - // Likewise for some builtin preprocessor macros. - // FIXME: This is inconsistent; we usually suggest detecting - // builtin macros via #ifdef. Don't add more cases here. - .Case("__is_target_arch", true) - .Case("__is_target_vendor", true) - .Case("__is_target_os", true) - .Case("__is_target_environment", true) - .Case("__is_target_variant_os", true) - .Case("__is_target_variant_environment", true) - .Default(false); - } - }); + }); } else if (II == Ident__has_constexpr_builtin) { EvaluateFeatureLikeBuiltinMacro( OS, Tok, II, *this, false, diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp index 36e5b44b8b12c..c9806a77d5ef6 100644 --- a/clang/lib/Sema/HeuristicResolver.cpp +++ b/clang/lib/Sema/HeuristicResolver.cpp @@ -247,7 +247,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E, } return T; }; - while (!Type.isNull()) { + // As an additional protection against infinite loops, bound the number of + // simplification steps. + size_t StepCount = 0; + const size_t MaxSteps = 64; + while (!Type.isNull() && StepCount++ < MaxSteps) { QualType New = SimplifyOneStep(Type); if (New == Type) break; diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp index 4b92d67e49d7d..edcfffa2b3894 100644 --- a/clang/lib/Sema/JumpDiagnostics.cpp +++ b/clang/lib/Sema/JumpDiagnostics.cpp @@ -597,15 +597,6 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, LabelAndGotoScopes[S] = ParentScope; break; - case Stmt::AttributedStmtClass: { - AttributedStmt *AS = cast(S); - if (GetMustTailAttr(AS)) { - LabelAndGotoScopes[AS] = ParentScope; - MustTailStmts.push_back(AS); - } - break; - } - case Stmt::OpenACCComputeConstructClass: { unsigned NewParentScope = Scopes.size(); OpenACCComputeConstruct *CC = cast(S); @@ -649,7 +640,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, continue; } - // Cases, labels, and defaults aren't "scope parents". It's also + // Cases, labels, attributes, and defaults aren't "scope parents". It's also // important to handle these iteratively instead of recursively in // order to avoid blowing out the stack. while (true) { @@ -658,7 +649,13 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, Next = SC->getSubStmt(); else if (LabelStmt *LS = dyn_cast(SubStmt)) Next = LS->getSubStmt(); - else + else if (AttributedStmt *AS = dyn_cast(SubStmt)) { + if (GetMustTailAttr(AS)) { + LabelAndGotoScopes[AS] = ParentScope; + MustTailStmts.push_back(AS); + } + Next = AS->getSubStmt(); + } else break; LabelAndGotoScopes[SubStmt] = ParentScope; @@ -786,8 +783,7 @@ void JumpScopeChecker::VerifyIndirectJumps() { if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(TheLabel->getStmt()))) continue; unsigned LabelScope = LabelAndGotoScopes[TheLabel->getStmt()]; - if (!TargetScopes.contains(LabelScope)) - TargetScopes[LabelScope] = TheLabel; + TargetScopes.try_emplace(LabelScope, TheLabel); } // For each target scope, make sure it's trivially reachable from diff --git a/clang/lib/Sema/SemaAVR.cpp b/clang/lib/Sema/SemaAVR.cpp index 47368780b6203..389c55404fde3 100644 --- a/clang/lib/Sema/SemaAVR.cpp +++ b/clang/lib/Sema/SemaAVR.cpp @@ -30,6 +30,18 @@ void SemaAVR::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { if (!AL.checkExactlyNumArgs(SemaRef, 0)) return; + // AVR interrupt handlers must have no parameter and be void type. + if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*AVR*/ 3 << /*interrupt*/ 0 << 0; + return; + } + if (!getFunctionOrMethodResultType(D)->isVoidType()) { + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*AVR*/ 3 << /*interrupt*/ 0 << 1; + return; + } + handleSimpleAttribute(*this, D, AL); } @@ -43,6 +55,18 @@ void SemaAVR::handleSignalAttr(Decl *D, const ParsedAttr &AL) { if (!AL.checkExactlyNumArgs(SemaRef, 0)) return; + // AVR signal handlers must have no parameter and be void type. + if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*AVR*/ 3 << /*signal*/ 1 << 0; + return; + } + if (!getFunctionOrMethodResultType(D)->isVoidType()) { + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*AVR*/ 3 << /*signal*/ 1 << 1; + return; + } + handleSimpleAttribute(*this, D, AL); } diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index defdda17c32de..37c0546e321d9 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -1189,6 +1189,11 @@ void Sema::ActOnPragmaAttributePop(SourceLocation PragmaLoc, void Sema::AddPragmaAttributes(Scope *S, Decl *D) { if (PragmaAttributeStack.empty()) return; + + if (const auto *P = dyn_cast(D)) + if (P->getType()->isVoidType()) + return; + for (auto &Group : PragmaAttributeStack) { for (auto &Entry : Group.Entries) { ParsedAttr *Attribute = Entry.Attribute; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f351663c6824e..527db176cf8dd 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -7484,6 +7484,15 @@ void Sema::ProcessDeclAttributeList( } } + // Do not permit 'constructor' or 'destructor' attributes on __device__ code. + if (getLangOpts().CUDAIsDevice && D->hasAttr() && + (D->hasAttr() || D->hasAttr()) && + !getLangOpts().GPUAllowDeviceInit) { + Diag(D->getLocation(), diag::err_cuda_ctor_dtor_attrs) + << (D->hasAttr() ? "constructors" : "destructors"); + D->setInvalidDecl(); + } + // Do this check after processing D's attributes because the attribute // objc_method_family can change whether the given method is in the init // family, and it can be applied after objc_designated_initializer. This is a diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index ec6b5b45de42b..4abd870ad6aaa 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -269,8 +269,11 @@ static bool isZeroSizedArray(const ConstantArrayType *CAT) { return CAT != nullptr; } -// Returns true if the record type is an HLSL resource class -static bool isResourceRecordType(const Type *Ty) { +// Returns true if the record type is an HLSL resource class or an array of +// resource classes +static bool isResourceRecordTypeOrArrayOf(const Type *Ty) { + while (const ConstantArrayType *CAT = dyn_cast(Ty)) + Ty = CAT->getArrayElementTypeNoTypeQual(); return HLSLAttributedResourceType::findHandleTypeOnResource(Ty) != nullptr; } @@ -279,15 +282,15 @@ static bool isResourceRecordType(const Type *Ty) { // array, or a builtin intangible type. Returns false it is a valid leaf element // type or if it is a record type that needs to be inspected further. static bool isInvalidConstantBufferLeafElementType(const Type *Ty) { - if (Ty->isRecordType()) { - if (isResourceRecordType(Ty) || Ty->getAsCXXRecordDecl()->isEmpty()) - return true; - return false; - } + Ty = Ty->getUnqualifiedDesugaredType(); + if (isResourceRecordTypeOrArrayOf(Ty)) + return true; + if (Ty->isRecordType()) + return Ty->getAsCXXRecordDecl()->isEmpty(); if (Ty->isConstantArrayType() && isZeroSizedArray(cast(Ty))) return true; - if (Ty->isHLSLBuiltinIntangibleType()) + if (Ty->isHLSLBuiltinIntangibleType() || Ty->isHLSLAttributedResourceType()) return true; return false; } @@ -339,7 +342,7 @@ static IdentifierInfo *getHostLayoutStructName(Sema &S, NamedDecl *BaseDecl, ASTContext &AST = S.getASTContext(); IdentifierInfo *NameBaseII = BaseDecl->getIdentifier(); - llvm::SmallString<64> Name("__layout_"); + llvm::SmallString<64> Name("__cblayout_"); if (NameBaseII) { Name.append(NameBaseII->getName()); } else { @@ -393,7 +396,7 @@ static FieldDecl *createFieldForHostLayoutStruct(Sema &S, const Type *Ty, auto *Field = FieldDecl::Create(AST, LayoutStruct, SourceLocation(), SourceLocation(), II, QT, TSI, nullptr, false, InClassInitStyle::ICIS_NoInit); - Field->setAccess(AccessSpecifier::AS_private); + Field->setAccess(AccessSpecifier::AS_public); return Field; } @@ -417,9 +420,11 @@ static CXXRecordDecl *createHostLayoutStruct(Sema &S, if (CXXRecordDecl *RD = findRecordDeclInContext(II, DC)) return RD; - CXXRecordDecl *LS = CXXRecordDecl::Create( - AST, TagDecl::TagKind::Class, DC, SourceLocation(), SourceLocation(), II); + CXXRecordDecl *LS = + CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, DC, SourceLocation(), + SourceLocation(), II); LS->setImplicit(true); + LS->addAttr(PackedAttr::CreateImplicit(AST)); LS->startDefinition(); // copy base struct, create HLSL Buffer compatible version if needed @@ -461,25 +466,27 @@ static CXXRecordDecl *createHostLayoutStruct(Sema &S, // Creates host layout struct for HLSL Buffer. The struct will include only // fields of types that are allowed in HLSL buffer and it will filter out: -// - static variable declarations +// - static or groupshared variable declarations // - resource classes // - empty structs // - zero-sized arrays // - non-variable declarations -// The layour struct will be added to the HLSLBufferDecl declarations. +// The layout struct will be added to the HLSLBufferDecl declarations. void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) { ASTContext &AST = S.getASTContext(); IdentifierInfo *II = getHostLayoutStructName(S, BufDecl, true); CXXRecordDecl *LS = - CXXRecordDecl::Create(AST, TagDecl::TagKind::Class, BufDecl, + CXXRecordDecl::Create(AST, TagDecl::TagKind::Struct, BufDecl, SourceLocation(), SourceLocation(), II); + LS->addAttr(PackedAttr::CreateImplicit(AST)); LS->setImplicit(true); LS->startDefinition(); for (Decl *D : BufDecl->decls()) { VarDecl *VD = dyn_cast(D); - if (!VD || VD->getStorageClass() == SC_Static) + if (!VD || VD->getStorageClass() == SC_Static || + VD->getType().getAddressSpace() == LangAS::hlsl_groupshared) continue; const Type *Ty = VD->getType()->getUnqualifiedDesugaredType(); if (FieldDecl *FD = diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index f206cd57eca89..18090eb1c9e9a 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4576,7 +4576,9 @@ static void TryConstructorInitialization(Sema &S, if (!IsListInit && (Kind.getKind() == InitializationKind::IK_Default || Kind.getKind() == InitializationKind::IK_Direct) && - DestRecordDecl != nullptr && DestRecordDecl->isAggregate() && + DestRecordDecl != nullptr && + !(CtorDecl->isCopyOrMoveConstructor() && CtorDecl->isImplicit()) && + DestRecordDecl->isAggregate() && DestRecordDecl->hasUninitializedExplicitInitFields()) { S.Diag(Kind.getLocation(), diag::warn_field_requires_explicit_init) << /* Var-in-Record */ 1 << DestRecordDecl; @@ -4862,9 +4864,13 @@ static void TryListInitialization(Sema &S, assert( S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) && "Deduced to other type?"); + assert(Kind.getKind() == clang::InitializationKind::IK_DirectList && + "List-initialize structured bindings but not " + "direct-list-initialization?"); TryArrayCopy(S, - InitializationKind::CreateCopy(Kind.getLocation(), - InitList->getLBraceLoc()), + InitializationKind::CreateDirect(Kind.getLocation(), + InitList->getLBraceLoc(), + InitList->getRBraceLoc()), Entity, SubInit[0], DestType, Sequence, TreatUnavailableAsInvalid); if (Sequence) diff --git a/clang/lib/Sema/SemaMIPS.cpp b/clang/lib/Sema/SemaMIPS.cpp index 50d210e5b3814..ce6ad6d9cc3f3 100644 --- a/clang/lib/Sema/SemaMIPS.cpp +++ b/clang/lib/Sema/SemaMIPS.cpp @@ -271,14 +271,14 @@ void SemaMIPS::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { } if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*MIPS*/ 0 << 0; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*MIPS*/ 0 << /*interrupt*/ 0 << 0; return; } if (!getFunctionOrMethodResultType(D)->isVoidType()) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*MIPS*/ 0 << 1; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*MIPS*/ 0 << /*interrupt*/ 0 << 1; return; } diff --git a/clang/lib/Sema/SemaMSP430.cpp b/clang/lib/Sema/SemaMSP430.cpp index 4038a1ff61d63..5bf931e388f03 100644 --- a/clang/lib/Sema/SemaMSP430.cpp +++ b/clang/lib/Sema/SemaMSP430.cpp @@ -32,14 +32,14 @@ void SemaMSP430::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { } if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*MSP430*/ 1 << 0; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*MSP430*/ 1 << /*interrupt*/ 0 << 0; return; } if (!getFunctionOrMethodResultType(D)->isVoidType()) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*MSP430*/ 1 << 1; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*MSP430*/ 1 << /*interrupt*/ 0 << 1; return; } diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index b060039d188a1..376995d624e28 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -22819,8 +22819,12 @@ class GlobalDeclRefChecker final : public StmtVisitor { void declareTargetInitializer(Decl *TD) { A = TD->getAttr(); DeclVector.push_back(cast(TD)); + llvm::SmallDenseSet Visited; while (!DeclVector.empty()) { VarDecl *TargetVarDecl = DeclVector.pop_back_val(); + if (!Visited.insert(TargetVarDecl).second) + continue; + if (TargetVarDecl->hasAttr() && TargetVarDecl->hasInit() && TargetVarDecl->hasGlobalStorage()) { if (Expr *Ex = TargetVarDecl->getInit()) diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp index 163f7129a7b42..8a5037d045125 100644 --- a/clang/lib/Sema/SemaRISCV.cpp +++ b/clang/lib/Sema/SemaRISCV.cpp @@ -1457,14 +1457,14 @@ void SemaRISCV::handleInterruptAttr(Decl *D, const ParsedAttr &AL) { } if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*RISC-V*/ 2 << 0; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*RISC-V*/ 2 << /*interrupt*/ 0 << 0; return; } if (!getFunctionOrMethodResultType(D)->isVoidType()) { - Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) - << /*RISC-V*/ 2 << 1; + Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid) + << /*RISC-V*/ 2 << /*interrupt*/ 0 << 1; return; } diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp index 0d079677eecc5..e5931f4684a57 100644 --- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp +++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp @@ -740,6 +740,28 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, DeclContext *DC) { return false; } +// Returns all source deduction guides associated with the declared +// deduction guides that have the specified deduction guide name. +llvm::DenseSet getSourceDeductionGuides(DeclarationName Name, + DeclContext *DC) { + assert(Name.getNameKind() == + DeclarationName::NameKind::CXXDeductionGuideName && + "name must be a deduction guide name"); + llvm::DenseSet Result; + for (auto *D : DC->lookup(Name)) { + if (const auto *FTD = dyn_cast(D)) + D = FTD->getTemplatedDecl(); + + if (const auto *GD = dyn_cast(D)) { + assert(GD->getSourceDeductionGuide() && + "deduction guide for alias template must have a source deduction " + "guide"); + Result.insert(GD->getSourceDeductionGuide()); + } + } + return Result; +} + // Build the associated constraints for the alias deduction guides. // C++ [over.match.class.deduct]p3.3: // The associated constraints ([temp.constr.decl]) are the conjunction of the @@ -1191,17 +1213,14 @@ void DeclareImplicitDeductionGuidesForTypeAlias( if (AliasTemplate->isInvalidDecl()) return; auto &Context = SemaRef.Context; - // FIXME: if there is an explicit deduction guide after the first use of the - // type alias usage, we will not cover this explicit deduction guide. fix this - // case. - if (hasDeclaredDeductionGuides( - Context.DeclarationNames.getCXXDeductionGuideName(AliasTemplate), - AliasTemplate->getDeclContext())) - return; auto [Template, AliasRhsTemplateArgs] = getRHSTemplateDeclAndArgs(SemaRef, AliasTemplate); if (!Template) return; + auto SourceDeductionGuides = getSourceDeductionGuides( + Context.DeclarationNames.getCXXDeductionGuideName(AliasTemplate), + AliasTemplate->getDeclContext()); + DeclarationNameInfo NameInfo( Context.DeclarationNames.getCXXDeductionGuideName(Template), Loc); LookupResult Guides(SemaRef, NameInfo, clang::Sema::LookupOrdinaryName); @@ -1210,6 +1229,8 @@ void DeclareImplicitDeductionGuidesForTypeAlias( for (auto *G : Guides) { if (auto *DG = dyn_cast(G)) { + if (SourceDeductionGuides.contains(DG)) + continue; // The deduction guide is a non-template function decl, we just clone it. auto *FunctionType = SemaRef.Context.getTrivialTypeSourceInfo(DG->getType()); @@ -1252,7 +1273,7 @@ void DeclareImplicitDeductionGuidesForTypeAlias( continue; } FunctionTemplateDecl *F = dyn_cast(G); - if (!F) + if (!F || SourceDeductionGuides.contains(F->getTemplatedDecl())) continue; // The **aggregate** deduction guides are handled in a different code path // (DeclareAggregateDeductionGuideFromInitList), which involves the tricky diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index fd1b73de912e5..6f30a36621601 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -5183,6 +5183,11 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (ParamTy.hasQualifiers()) S.Diag(DeclType.Loc, diag::err_void_param_qualified); + for (const auto *A : Param->attrs()) { + S.Diag(A->getLoc(), diag::warn_attribute_on_void_param) + << A << A->getRange(); + } + // Reject, but continue to parse 'float(this void)' as // 'float(void)'. if (Param->isExplicitObjectParameter()) { diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index b74bd586e74d7..3c64b67503195 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -645,10 +645,11 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts, // For an #undef'd macro, we only care about the name. if (IsUndef) { - if (MacroNames && !Macros.count(MacroName)) + auto [It, Inserted] = Macros.try_emplace(MacroName); + if (MacroNames && Inserted) MacroNames->push_back(MacroName); - Macros[MacroName] = std::make_pair("", true); + It->second = std::make_pair("", true); continue; } @@ -661,9 +662,10 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroBody = MacroBody.substr(0, End); } - if (MacroNames && !Macros.count(MacroName)) + auto [It, Inserted] = Macros.try_emplace(MacroName); + if (MacroNames && Inserted) MacroNames->push_back(MacroName); - Macros[MacroName] = std::make_pair(MacroBody, false); + It->second = std::make_pair(MacroBody, false); } } diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index df834cd862f73..17a41fff2267c 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -3753,6 +3753,13 @@ void ASTDeclReader::checkMultipleDefinitionInNamedModules(ASTReader &Reader, if (D->getFriendObjectKind() || Previous->getFriendObjectKind()) return; + // Skip diagnosing in-class declarations. + if (!Previous->getLexicalDeclContext() + ->getNonTransparentContext() + ->isFileContext() || + !D->getLexicalDeclContext()->getNonTransparentContext()->isFileContext()) + return; + Module *M = Previous->getOwningModule(); if (!M) return; diff --git a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp similarity index 98% rename from clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp rename to clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp index 6f8d6dbd573f4..109faacf1726a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp @@ -1,4 +1,4 @@ -//== ArrayBoundCheckerV2.cpp ------------------------------------*- C++ -*--==// +//== ArrayBoundChecker.cpp -------------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,12 +11,6 @@ // //===----------------------------------------------------------------------===// -// NOTE: The name of this file ends with "V2" because previously -// "ArrayBoundChecker.cpp" contained the implementation of another (older and -// simpler) checker that was called `alpha.security.ArrayBound`. -// TODO: Rename this file to "ArrayBoundChecker.cpp" when it won't be confused -// with that older file. - #include "clang/AST/CharUnits.h" #include "clang/AST/ParentMapContext.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" @@ -297,7 +291,8 @@ static std::pair compareValueToThreshold(ProgramStateRef State, NonLoc Value, NonLoc Threshold, SValBuilder &SVB, bool CheckEquality = false) { if (auto ConcreteThreshold = Threshold.getAs()) { - std::tie(Value, Threshold) = getSimplifiedOffsets(Value, *ConcreteThreshold, SVB); + std::tie(Value, Threshold) = + getSimplifiedOffsets(Value, *ConcreteThreshold, SVB); } // We want to perform a _mathematical_ comparison between the numbers `Value` diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt index ccff5d0ac3b96..5910043440987 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -7,7 +7,7 @@ set(LLVM_LINK_COMPONENTS add_clang_library(clangStaticAnalyzerCheckers AnalysisOrderChecker.cpp AnalyzerStatsChecker.cpp - ArrayBoundCheckerV2.cpp + ArrayBoundChecker.cpp BasicObjCFoundationChecks.cpp BitwiseShiftChecker.cpp BlockInCriticalSectionChecker.cpp diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp index f4de3b500499c..c9df15ceb3b40 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -54,8 +54,8 @@ class StackAddrEscapeChecker CheckerContext &C) const; void checkAsyncExecutedBlockCaptures(const BlockDataRegion &B, CheckerContext &C) const; - void EmitStackError(CheckerContext &C, const MemRegion *R, - const Expr *RetE) const; + void EmitReturnLeakError(CheckerContext &C, const MemRegion *LeakedRegion, + const Expr *RetE) const; bool isSemaphoreCaptured(const BlockDecl &B) const; static SourceRange genName(raw_ostream &os, const MemRegion *R, ASTContext &Ctx); @@ -147,9 +147,22 @@ StackAddrEscapeChecker::getCapturedStackRegions(const BlockDataRegion &B, return Regions; } -void StackAddrEscapeChecker::EmitStackError(CheckerContext &C, - const MemRegion *R, - const Expr *RetE) const { +static void EmitReturnedAsPartOfError(llvm::raw_ostream &OS, SVal ReturnedVal, + const MemRegion *LeakedRegion) { + if (const MemRegion *ReturnedRegion = ReturnedVal.getAsRegion()) { + if (isa(ReturnedRegion)) { + OS << " is captured by a returned block"; + return; + } + } + + // Generic message + OS << " returned to caller"; +} + +void StackAddrEscapeChecker::EmitReturnLeakError(CheckerContext &C, + const MemRegion *R, + const Expr *RetE) const { ExplodedNode *N = C.generateNonFatalErrorNode(); if (!N) return; @@ -157,11 +170,15 @@ void StackAddrEscapeChecker::EmitStackError(CheckerContext &C, BT_returnstack = std::make_unique( CheckNames[CK_StackAddrEscapeChecker], "Return of address to stack-allocated memory"); + // Generate a report for this bug. SmallString<128> buf; llvm::raw_svector_ostream os(buf); + + // Error message formatting SourceRange range = genName(os, R, C.getASTContext()); - os << " returned to caller"; + EmitReturnedAsPartOfError(os, C.getSVal(RetE), R); + auto report = std::make_unique(*BT_returnstack, os.str(), N); report->addRange(RetE->getSourceRange()); @@ -209,30 +226,6 @@ void StackAddrEscapeChecker::checkAsyncExecutedBlockCaptures( } } -void StackAddrEscapeChecker::checkReturnedBlockCaptures( - const BlockDataRegion &B, CheckerContext &C) const { - for (const MemRegion *Region : getCapturedStackRegions(B, C)) { - if (isNotInCurrentFrame(Region, C)) - continue; - ExplodedNode *N = C.generateNonFatalErrorNode(); - if (!N) - continue; - if (!BT_capturedstackret) - BT_capturedstackret = std::make_unique( - CheckNames[CK_StackAddrEscapeChecker], - "Address of stack-allocated memory is captured"); - SmallString<128> Buf; - llvm::raw_svector_ostream Out(Buf); - SourceRange Range = genName(Out, Region, C.getASTContext()); - Out << " is captured by a returned block"; - auto Report = std::make_unique(*BT_capturedstackret, - Out.str(), N); - if (Range.isValid()) - Report->addRange(Range); - C.emitReport(std::move(Report)); - } -} - void StackAddrEscapeChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const { if (!ChecksEnabled[CK_StackAddrAsyncEscapeChecker]) @@ -247,45 +240,128 @@ void StackAddrEscapeChecker::checkPreCall(const CallEvent &Call, } } -void StackAddrEscapeChecker::checkPreStmt(const ReturnStmt *RS, - CheckerContext &C) const { - if (!ChecksEnabled[CK_StackAddrEscapeChecker]) - return; +/// A visitor made for use with a ScanReachableSymbols scanner, used +/// for finding stack regions within an SVal that live on the current +/// stack frame of the given checker context. This visitor excludes +/// NonParamVarRegion that data is bound to in a BlockDataRegion's +/// bindings, since these are likely uninteresting, e.g., in case a +/// temporary is constructed on the stack, but it captures values +/// that would leak. +class FindStackRegionsSymbolVisitor final : public SymbolVisitor { + CheckerContext &Ctxt; + const StackFrameContext *PoppedStackFrame; + SmallVectorImpl &EscapingStackRegions; - const Expr *RetE = RS->getRetValue(); - if (!RetE) - return; - RetE = RetE->IgnoreParens(); +public: + explicit FindStackRegionsSymbolVisitor( + CheckerContext &Ctxt, + SmallVectorImpl &StorageForStackRegions) + : Ctxt(Ctxt), PoppedStackFrame(Ctxt.getStackFrame()), + EscapingStackRegions(StorageForStackRegions) {} - SVal V = C.getSVal(RetE); - const MemRegion *R = V.getAsRegion(); - if (!R) - return; + bool VisitSymbol(SymbolRef sym) override { return true; } - if (const BlockDataRegion *B = dyn_cast(R)) - checkReturnedBlockCaptures(*B, C); + bool VisitMemRegion(const MemRegion *MR) override { + SaveIfEscapes(MR); - if (!isa(R->getMemorySpace()) || isNotInCurrentFrame(R, C)) - return; + if (const BlockDataRegion *BDR = MR->getAs()) + return VisitBlockDataRegionCaptures(BDR); + + return true; + } + +private: + void SaveIfEscapes(const MemRegion *MR) { + const StackSpaceRegion *SSR = + MR->getMemorySpace()->getAs(); + if (SSR && SSR->getStackFrame() == PoppedStackFrame) + EscapingStackRegions.push_back(MR); + } + + bool VisitBlockDataRegionCaptures(const BlockDataRegion *BDR) { + for (auto Var : BDR->referenced_vars()) { + SVal Val = Ctxt.getState()->getSVal(Var.getCapturedRegion()); + const MemRegion *Region = Val.getAsRegion(); + if (Region) { + SaveIfEscapes(Region); + VisitMemRegion(Region); + } + } + + return false; + } +}; + +/// Given some memory regions that are flagged by FindStackRegionsSymbolVisitor, +/// this function filters out memory regions that are being returned that are +/// likely not true leaks: +/// 1. If returning a block data region that has stack memory space +/// 2. If returning a constructed object that has stack memory space +static SmallVector FilterReturnExpressionLeaks( + const SmallVectorImpl &MaybeEscaped, CheckerContext &C, + const Expr *RetE, SVal &RetVal) { + + SmallVector WillEscape; + + const MemRegion *RetRegion = RetVal.getAsRegion(); // Returning a record by value is fine. (In this case, the returned // expression will be a copy-constructor, possibly wrapped in an // ExprWithCleanups node.) if (const ExprWithCleanups *Cleanup = dyn_cast(RetE)) RetE = Cleanup->getSubExpr(); - if (isa(RetE) && RetE->getType()->isRecordType()) - return; + bool IsConstructExpr = + isa(RetE) && RetE->getType()->isRecordType(); // The CK_CopyAndAutoreleaseBlockObject cast causes the block to be copied // so the stack address is not escaping here. + bool IsCopyAndAutoreleaseBlockObj = false; if (const auto *ICE = dyn_cast(RetE)) { - if (isa(R) && - ICE->getCastKind() == CK_CopyAndAutoreleaseBlockObject) { - return; - } + IsCopyAndAutoreleaseBlockObj = + isa_and_nonnull(RetRegion) && + ICE->getCastKind() == CK_CopyAndAutoreleaseBlockObject; + } + + for (const MemRegion *MR : MaybeEscaped) { + if (RetRegion == MR && (IsCopyAndAutoreleaseBlockObj || IsConstructExpr)) + continue; + + WillEscape.push_back(MR); } - EmitStackError(C, R, RetE); + return WillEscape; +} + +/// For use in finding regions that live on the checker context's current +/// stack frame, deep in the SVal representing the return value. +static SmallVector +FindEscapingStackRegions(CheckerContext &C, const Expr *RetE, SVal RetVal) { + SmallVector FoundStackRegions; + + FindStackRegionsSymbolVisitor Finder(C, FoundStackRegions); + ScanReachableSymbols Scanner(C.getState(), Finder); + Scanner.scan(RetVal); + + return FilterReturnExpressionLeaks(FoundStackRegions, C, RetE, RetVal); +} + +void StackAddrEscapeChecker::checkPreStmt(const ReturnStmt *RS, + CheckerContext &C) const { + if (!ChecksEnabled[CK_StackAddrEscapeChecker]) + return; + + const Expr *RetE = RS->getRetValue(); + if (!RetE) + return; + RetE = RetE->IgnoreParens(); + + SVal V = C.getSVal(RetE); + + SmallVector EscapedStackRegions = + FindEscapingStackRegions(C, RetE, V); + + for (const MemRegion *ER : EscapedStackRegions) + EmitReturnLeakError(C, ER, RetE); } static const MemSpaceRegion *getStackOrGlobalSpaceRegion(const MemRegion *R) { diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 5487fea1b956c..d40b4b4dbb560 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -636,6 +636,11 @@ class TrivialFunctionAnalysisVisitor return true; } + bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *IVIE) { + // An implicit value initialization is trvial. + return true; + } + private: CacheTy &Cache; CacheTy RecursiveFn; diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 7034e8c56bd62..d51b039d40043 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1272,6 +1272,22 @@ namespace BuiltinMemcpy { return arr[0] * 1000 + arr[1] * 100 + arr[2] * 10 + arr[3]; } static_assert(test_incomplete_array_type() == 1234); // both-error {{constant}} both-note {{in call}} + + + /// FIXME: memmove needs to support overlapping memory regions. + constexpr bool memmoveOverlapping() { + char s1[] {1, 2, 3}; + __builtin_memmove(s1, s1 + 1, 2 * sizeof(char)); + // Now: 2, 3, 3 + bool Result1 = (s1[0] == 2 && s1[1] == 3 && s1[2]== 3); + + __builtin_memmove(s1 + 1, s1, 2 * sizeof(char)); + // Now: 2, 2, 3 + bool Result2 = (s1[0] == 2 && s1[1] == 2 && s1[2]== 3); + + return Result1 && Result2; + } + static_assert(memmoveOverlapping()); // expected-error {{failed}} } namespace Memcmp { diff --git a/clang/test/AST/ByteCode/cxx26.cpp b/clang/test/AST/ByteCode/cxx26.cpp index 0b0e2b21e8201..cd6b533065010 100644 --- a/clang/test/AST/ByteCode/cxx26.cpp +++ b/clang/test/AST/ByteCode/cxx26.cpp @@ -1,10 +1,33 @@ // RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=ref,both %s // RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=expected,both %s -fexperimental-new-constant-interpreter -// both-no-diagnostics +namespace std { + using size_t = decltype(sizeof(0)); +} namespace VoidCast { constexpr void* p = nullptr; constexpr int* q = static_cast(p); static_assert(q == nullptr); } + +namespace ReplaceableAlloc { + struct F { + static void* operator new(std::size_t n) { + return nullptr; // both-warning {{should not return a null pointer}} + } + }; + + constexpr F *createF() { + return new F(); // both-note {{call to class-specific 'operator new'}} + } + + constexpr bool foo() { + F *f = createF(); // both-note {{in call to}} + + delete f; + return true; + } + static_assert(foo()); // both-error {{not an integral constant expression}} \ + // both-note {{in call to}} +} diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp index a8f073aa03fc1..e60ff894c9715 100644 --- a/clang/test/AST/ByteCode/new-delete.cpp +++ b/clang/test/AST/ByteCode/new-delete.cpp @@ -268,11 +268,10 @@ namespace NowThrowNew { delete[] p; return result; } - /// This needs support for CXXConstrucExprs with non-constant array sizes. - static_assert(erroneous_array_bound_nothrow2(3)); // expected-error {{not an integral constant expression}} - static_assert(erroneous_array_bound_nothrow2(0));// expected-error {{not an integral constant expression}} - static_assert(erroneous_array_bound_nothrow2(-1) == 0);// expected-error {{not an integral constant expression}} - static_assert(!erroneous_array_bound_nothrow2(1LL << 62));// expected-error {{not an integral constant expression}} + static_assert(erroneous_array_bound_nothrow2(3)); + static_assert(erroneous_array_bound_nothrow2(0)); + static_assert(erroneous_array_bound_nothrow2(-1) == 0); + static_assert(!erroneous_array_bound_nothrow2(1LL << 62)); constexpr bool erroneous_array_bound(long long n) { delete[] new int[n]; // both-note {{array bound -1 is negative}} both-note {{array bound 4611686018427387904 is too large}} @@ -857,6 +856,54 @@ struct SS { }; constexpr unsigned short ssmall = SS(100)[42]; + + +namespace IncompleteArray { + struct A { + int b = 10; + }; + constexpr int test1() { + int n = 5; + int* a = new int[n]; + int c = a[0]; // both-note {{read of uninitialized object}} + delete[] a; + return c; + } + static_assert(test1() == 10); // both-error {{not an integral constant expression}} \ + // both-note {{in call to}} + + constexpr int test2() { + int n = 0; + int* a = new int[n]; + delete[] a; + return 10; + } + static_assert(test2() == 10); + + /// In this case, the type of the initializer is A[2], while the full size of the + /// allocated array is of course 5. The remaining 3 elements need to be initialized + /// using A's constructor. + constexpr int test3() { + int n = 3; + A* a = new A[n]{5, 1}; + int c = a[0].b + a[1].b + a[2].b; + delete[] a; + return c; + } + static_assert(test3() == (5 + 1 + 10)); + + constexpr int test4() { + auto n = 3; + int *a = new int[n]{12}; + int c = a[0] + a[1]; + delete[] a; + return c; + } + static_assert(test4() == 12); + + +} + #else /// Make sure we reject this prior to C++20 constexpr int a() { // both-error {{never produces a constant expression}} diff --git a/clang/test/AST/HLSL/TypdefArrayParam.hlsl b/clang/test/AST/HLSL/TypdefArrayParam.hlsl new file mode 100644 index 0000000000000..c6ae168f84064 --- /dev/null +++ b/clang/test/AST/HLSL/TypdefArrayParam.hlsl @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -finclude-default-header -x hlsl -ast-dump %s | FileCheck %s + +typedef uint4 uint32_t4; +typedef uint32_t4 uint32_t8[2]; + +// CHECK-LABEL: FunctionDecl {{.*}} used Accumulate 'uint32_t (uint32_t4[2])' +// CHECK-NEXT: ParmVarDecl {{.*}} used V 'uint32_t4[2]' +uint32_t Accumulate(uint32_t8 V) { + uint32_t4 SumVec = V[0] + V[1]; + return SumVec.x + SumVec.y + SumVec.z + SumVec.w; +} + +// CHECK-LABEL: FunctionDecl {{.*}} used InOutAccu 'void (inout uint32_t4[2])' +// CHECK-NEXT: ParmVarDecl {{.*}} used V 'uint32_t4[2]' +// CHECK-NEXT: HLSLParamModifierAttr {{.*}} inout +void InOutAccu(inout uint32_t8 V) { + uint32_t4 SumVec = V[0] + V[1]; + V[0] = SumVec; +} + +// CHECK-LABEL: call1 +// CHECK: CallExpr {{.*}} 'void' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(inout uint32_t4[2])' +// CHECK-NEXT: DeclRefExpr {{.*}} 'void (inout uint32_t4[2])' lvalue Function {{.*}} 'InOutAccu' 'void (inout uint32_t4[2])' +// CHECK-NEXT: HLSLOutArgExpr {{.*}} 'uint32_t4[2]' lvalue inout +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue Var {{.*}} 'B' 'uint32_t8':'uint32_t4[2]' +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t4[2]' lvalue +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint32_t4[2]' +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue Var {{.*}} 'B' 'uint32_t8':'uint32_t4[2]' +// CHECK-NEXT: BinaryOperator {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue '=' +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue Var {{.*}} 'B' 'uint32_t8':'uint32_t4[2]' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint32_t4[2]' +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t4[2]' lvalue +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint32_t4[2]' +// CHECK-NEXT: OpaqueValueExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t8':'uint32_t4[2]' lvalue Var {{.*}} 'B' 'uint32_t8':'uint32_t4[2]' +void call1() { + uint32_t4 A = {1,2,3,4}; + uint32_t8 B = {A,A}; + InOutAccu(B); +} + +// CHECK-LABEL: call2 +// CHECK: VarDecl {{.*}} D 'uint32_t':'unsigned int' cinit +// CHECK-NEXT: CallExpr {{.*}} 'uint32_t':'unsigned int' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint32_t (*)(uint32_t4[2])' +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t (uint32_t4[2])' lvalue Function {{.*}} 'Accumulate' 'uint32_t (uint32_t4[2])' +// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint4[2]' +// CHECK-NEXT: DeclRefExpr {{.*}} 'uint4[2]' lvalue Var {{.*}} 'C' 'uint4[2]' +void call2() { + uint4 A = {1,2,3,4}; + uint4 C[2] = {A,A}; + uint32_t D = Accumulate(C); +} diff --git a/clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl b/clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl index b2b3e13308da3..eca2ed0211d1b 100644 --- a/clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl +++ b/clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl @@ -27,6 +27,3 @@ cbuffer A { // AST-NEXT: TextComment {{.*}} Text=" CBuffer decl." // AST-NEXT: VarDecl {{.*}} a 'hlsl_constant float' // AST-NEXT: VarDecl {{.*}} b 'hlsl_constant int' -// AST-NEXT: CXXRecordDecl {{.*}} implicit class __layout_A definition -// AST: FieldDecl {{.*}} a 'float' -// AST-NEXT: FieldDecl {{.*}} b 'int' diff --git a/clang/test/AST/HLSL/cbuffer.hlsl b/clang/test/AST/HLSL/cbuffer.hlsl index f516cf5099e82..9946fda2355b2 100644 --- a/clang/test/AST/HLSL/cbuffer.hlsl +++ b/clang/test/AST/HLSL/cbuffer.hlsl @@ -48,75 +48,87 @@ struct TwoFloats { // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { - // CHECK: VarDecl {{.*}} col:9 used a1 'hlsl_constant float' + // CHECK: VarDecl {{.*}} used a1 'hlsl_constant float' float a1; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB definition - // CHECK: FieldDecl {{.*}} a1 'float' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} a1 'float' } -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_CB), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_CB), ""); // Check that buffer layout struct does not include resources or empty types -// CHECK: HLSLBufferDecl {{.*}} line:62:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { - // CHECK: VarDecl {{.*}} col:9 used a2 'hlsl_constant float' + // CHECK: VarDecl {{.*}} used a2 'hlsl_constant float' float a2; - // CHECK: VarDecl {{.*}} col:19 b2 'RWBuffer':'hlsl::RWBuffer' + // CHECK: VarDecl {{.*}} b2 'RWBuffer':'hlsl::RWBuffer' RWBuffer b2; - // CHECK: VarDecl {{.*}} col:15 c2 'EmptyStruct' + // CHECK: VarDecl {{.*}} c2 'EmptyStruct' EmptyStruct c2; - // CHECK: VarDecl {{.*}} col:9 d2 'float[0]' + // CHECK: VarDecl {{.*}} d2 'float[0]' float d2[0]; - // CHECK: VarDecl {{.*}} col:9 e2 'hlsl_constant float' + // CHECK: VarDecl {{.*}} f2 'RWBuffer[2]' + RWBuffer f2[2]; + // CHECK: VarDecl {{.*}} g2 'groupshared float' + groupshared float g2; + // CHECK: VarDecl {{.*}} h2 '__hlsl_resource_t' + __hlsl_resource_t h2; + // CHECK: VarDecl {{.*}} e2 'hlsl_constant float' float e2; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_1 definition - // CHECK: FieldDecl {{.*}} a2 'float' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_1 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} a2 'float' // CHECK-NEXT: FieldDecl {{.*}} e2 'float' } -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_1), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_1), ""); // Check that layout struct is created for B and the empty struct C is removed -// CHECK: HLSLBufferDecl {{.*}} line:83:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { - // CHECK: VarDecl {{.*}} col:5 used s1 'hlsl_constant A' + // CHECK: VarDecl {{.*}} used s1 'hlsl_constant A' A s1; - // CHECK: VarDecl {{.*}} col:5 s2 'hlsl_constant B' + // CHECK: VarDecl {{.*}} s2 'hlsl_constant B' B s2; - // CHECK: VarDecl {{.*}} col:12 s3 'CTypedef':'C' + // CHECK: VarDecl {{.*}} s3 'CTypedef':'C' CTypedef s3; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_2 definition - // CHECK: FieldDecl {{.*}} s1 'A' - // CHECK: FieldDecl {{.*}} s2 '__layout_B' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_2 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} s1 'A' + // CHECK-NEXT: FieldDecl {{.*}} s2 '__cblayout_B' } -// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_B definition -// CHECK: FieldDecl {{.*}} a 'float' +// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_B definition +// CHECK: PackedAttr +// CHECK-NEXT: FieldDecl {{.*}} a 'float' -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_B), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_2), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_B), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_2), ""); // check that layout struct is created for D because of its base struct -// CHECK: HLSLBufferDecl {{.*}} line:104:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { // CHECK: VarDecl {{.*}} s4 'hlsl_constant D' D s4; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_3 definition - // CHECK: FieldDecl {{.*}} s4 '__layout_D' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_3 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} s4 '__cblayout_D' } - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_D definition - // CHECK: public '__layout_B' - // CHECK: FieldDecl {{.*}} b 'float' -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_D), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_3), ""); + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_D definition + // CHECK: public '__cblayout_B' + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} b 'float' +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_D), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_3), ""); // check that layout struct is created for E because because its base struct // is empty and should be eliminated, and BTypedef should reuse the previously -// defined '__layout_B' -// CHECK: HLSLBufferDecl {{.*}} line:122:9 cbuffer CB +// defined '__cblayout_B' +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { @@ -124,18 +136,20 @@ cbuffer CB { E s5; // CHECK: VarDecl {{.*}} s6 'hlsl_constant BTypedef':'hlsl_constant B' BTypedef s6; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_4 definition - // CHECK: FieldDecl {{.*}} s5 '__layout_E' - // CHECK: FieldDecl {{.*}} s6 '__layout_B' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_4 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} s5 '__cblayout_E' + // CHECK-NEXT: FieldDecl {{.*}} s6 '__cblayout_B' } - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_E definition - // CHECK: FieldDecl {{.*}} c 'float' - // CHECK-NOT: CXXRecordDecl {{.*}} class __layout_B definition -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_E), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_4), ""); +// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_E definition +// CHECK: PackedAttr +// CHECK-NEXT: FieldDecl {{.*}} c 'float' +// CHECK-NOT: CXXRecordDecl {{.*}} struct __cblayout_B definition +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_E), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_4), ""); // check that this produces empty layout struct -// CHECK: HLSLBufferDecl {{.*}} line:141:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { @@ -149,27 +163,30 @@ cbuffer CB { RWBuffer Buf; // CHECK: VarDecl {{.*}} ea 'EmptyArrayTypedef':'float[10][0]' EmptyArrayTypedef ea; - // CHECK: CXXRecordDecl {{.*}} implicit class __layout_CB_5 definition + // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_CB_5 definition + // CHECK: PackedAttr // CHECK-NOT: FieldDecl } // check host layout struct with compatible base struct -// CHECK: HLSLBufferDecl {{.*}} line:160:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { // CHECK: VarDecl {{.*}} s8 'hlsl_constant F' F s8; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_6 definition - // CHECK: FieldDecl {{.*}} s8 '__layout_F' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_6 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} s8 '__cblayout_F' } - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_F definition - // CHECK: public 'A' -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_F), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_CB_6), ""); +// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_F definition +// CHECK: public 'A' +// CHECK: PackedAttr +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_F), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_CB_6), ""); // anonymous structs -// CHECK: HLSLBufferDecl {{.*}} line:175:9 cbuffer CB +// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 3]]:9 cbuffer CB // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer cbuffer CB { @@ -182,7 +199,7 @@ cbuffer CB { // CHECK: FieldDecl {{.*}} f 'RWBuffer':'hlsl::RWBuffer' RWBuffer f; } s9; - // CHECK: VarDecl {{.*}} s9 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:177:3 + // CHECK: VarDecl {{.*}} s9 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:[[# @LINE - 8]]:3 // CHECK: CXXRecordDecl {{.*}} struct definition struct { // CHECK: FieldDecl {{.*}} g 'float' @@ -190,18 +207,21 @@ cbuffer CB { // CHECK: FieldDecl {{.*}} f 'RWBuffer':'hlsl::RWBuffer' RWBuffer f; } s10; - // CHECK: VarDecl {{.*}} s10 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:187:3 - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon definition - // CHECK: FieldDecl {{.*}} e 'float' - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon_1 definition - // CHECK: FieldDecl {{.*}} g 'float' - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_7 definition - // CHECK: FieldDecl {{.*}} s9 '__layout_anon' - // CHECK: FieldDecl {{.*}} s10 '__layout_anon_1' + // CHECK: VarDecl {{.*}} s10 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:[[# @LINE - 6]]:3 + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_anon definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} e 'float' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_anon_1 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} g 'float' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_7 definition + // CHECK: PackedAttr + // CHECK-NEXT: FieldDecl {{.*}} s9 '__cblayout_anon' + // CHECK-NEXT: FieldDecl {{.*}} s10 '__cblayout_anon_1' } -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_anon), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout_anon_1), ""); -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layout_CB_7), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_anon), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_anon_1), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblayout_CB_7), ""); // Add uses for the constant buffer declarations so they are not optimized away export float foo() { diff --git a/clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl b/clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl index 12ce327d8be02..09596eda90b6a 100644 --- a/clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl +++ b/clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl @@ -19,10 +19,10 @@ namespace NS1 { int b; EmptyStruct es; }; - // CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition + // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition // CHECK: FieldDecl {{.*}} b 'int' }; - // CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition + // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition // CHECK: FieldDecl {{.*}} a 'float' } @@ -41,12 +41,12 @@ cbuffer CB1 { NS1::Foo foo2; // CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo' NS1::Bar::Foo foo3; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB1 definition - // CHECK: FieldDecl {{.*}} foo1 '__layout_Foo' - // CHECK: FieldDecl {{.*}} foo2 'NS1::__layout_Foo' - // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__layout_Foo' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB1 definition + // CHECK: FieldDecl {{.*}} foo1 '__cblayout_Foo' + // CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo' + // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo' } -// CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition +// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition // CHECK: FieldDecl {{.*}} c 'double' struct CB1ExpectedShape { @@ -54,7 +54,7 @@ struct CB1ExpectedShape { float a2; int a; }; -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __layout_CB1), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __cblayout_CB1), ""); namespace NS2 { struct Foo { @@ -73,13 +73,13 @@ namespace NS2 { NS1::Foo foo2; // CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo' NS1::Bar::Foo foo3; - // CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB2 definition - // CHECK: FieldDecl {{.*}} foo0 '__layout_Foo' - // CHECK: FieldDecl {{.*}} foo1 'NS2::__layout_Foo' - // CHECK: FieldDecl {{.*}} foo2 'NS1::__layout_Foo' - // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__layout_Foo' + // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB2 definition + // CHECK: FieldDecl {{.*}} foo0 '__cblayout_Foo' + // CHECK: FieldDecl {{.*}} foo1 'NS2::__cblayout_Foo' + // CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo' + // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo' } - // CHECK: CXXRecordDecl {{.*}} implicit class __layout_Foo definition + // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition // CHECK: FieldDecl {{.*}} d 'float[4]' } @@ -89,7 +89,7 @@ struct CB2ExpectedShape { float a2; int a; }; -_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB2ExpectedShape, NS2::__layout_CB2), ""); +_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB2ExpectedShape, NS2::__cblayout_CB2), ""); // Add uses for the constant buffer declarations so they are not optimized away // CHECK: ExportDecl diff --git a/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl b/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl index 98d7aba397852..754948931ee53 100644 --- a/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl +++ b/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl @@ -21,14 +21,14 @@ float foo() { // CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit CBuffer // CHECK-NEXT: HLSLResourceAttr {{.*}} Implicit CBuffer // CHECK-NEXT: VarDecl 0x[[A:[0-9a-f]+]] {{.*}} imported used a 'hlsl_constant float' -// CHECK-NEXT: CXXRecordDecl {{.*}} imported implicit class __layout_A definition +// CHECK-NEXT: CXXRecordDecl {{.*}} imported implicit struct __cblayout_A definition // CHECK: FieldDecl {{.*}} imported a 'float' // CHECK: HLSLBufferDecl {{.*}} line:11:9 imported tbuffer B // CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit SRV // CHECK-NEXT: HLSLResourceAttr {{.*}} Implicit TBuffer // CHECK-NEXT: VarDecl 0x[[B:[0-9a-f]+]] {{.*}} imported used b 'hlsl_constant float' -// CHECK-NEXT: CXXRecordDecl 0x{{[0-9a-f]+}} {{.*}} imported implicit class __layout_B definition +// CHECK-NEXT: CXXRecordDecl 0x{{[0-9a-f]+}} {{.*}} imported implicit struct __cblayout_B definition // CHECK: FieldDecl 0x{{[0-9a-f]+}} {{.*}} imported b 'float' // CHECK-NEXT: FunctionDecl {{.*}} line:15:7 imported foo 'float ()' diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp index d654d963a4fae..ffeecbf87c451 100644 --- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp +++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp @@ -368,6 +368,11 @@ class RefCounted { } RefPtr trivial66() { return children[0]; } Ref trivial67() { return *children[0]; } + struct point { + double x; + double y; + }; + void trivial68() { point pt = { 1.0 }; } static RefCounted& singleton() { static RefCounted s_RefCounted; @@ -554,6 +559,7 @@ class UnrelatedClass { getFieldTrivial().trivial65(); // no-warning getFieldTrivial().trivial66()->trivial6(); // no-warning getFieldTrivial().trivial67()->trivial6(); // no-warning + getFieldTrivial().trivial68(); // no-warning RefCounted::singleton().trivial18(); // no-warning RefCounted::singleton().someFunction(); // no-warning diff --git a/clang/test/Analysis/copy-elision.cpp b/clang/test/Analysis/copy-elision.cpp index cd941854fc7f1..e69f52f351f1b 100644 --- a/clang/test/Analysis/copy-elision.cpp +++ b/clang/test/Analysis/copy-elision.cpp @@ -154,20 +154,26 @@ class ClassWithoutDestructor { void push() { v.push(this); } }; +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithoutDestructor make1(AddressVector &v) { - return ClassWithoutDestructor(v); + return ClassWithoutDestructor(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithoutDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithoutDestructor' is still \ referred to by the caller variable 'v' upon returning to the caller}} } +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithoutDestructor make2(AddressVector &v) { - return make1(v); + return make1(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithoutDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithoutDestructor' is still \ referred to by the caller variable 'v' upon returning to the caller}} } +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithoutDestructor make3(AddressVector &v) { - return make2(v); + return make2(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithoutDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithoutDestructor' is still \ referred to by the caller variable 'v' upon returning to the caller}} @@ -298,21 +304,26 @@ to by the caller variable 'v' upon returning to the caller}} #endif } - +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithDestructor make1(AddressVector &v) { - return ClassWithDestructor(v); + return ClassWithDestructor(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithDestructor' is still referred \ to by the caller variable 'v' upon returning to the caller}} } +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithDestructor make2(AddressVector &v) { - return make1(v); + return make1(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithDestructor' is still referred \ to by the caller variable 'v' upon returning to the caller}} } +// Two warnings on no-elide: arg v holds the address of the temporary, and we +// are returning an object which holds v which holds the address of the temporary ClassWithDestructor make3(AddressVector &v) { - return make2(v); + return make2(v); // no-elide-warning{{Address of stack memory associated with temporary object of type 'ClassWithDestructor' returned to caller}} // no-elide-warning@-1 {{Address of stack memory associated with temporary \ object of type 'ClassWithDestructor' is still referred \ to by the caller variable 'v' upon returning to the caller}} diff --git a/clang/test/Analysis/live-stmts.cpp b/clang/test/Analysis/live-stmts.cpp index c60f522588e39..33b8d59305d3d 100644 --- a/clang/test/Analysis/live-stmts.cpp +++ b/clang/test/Analysis/live-stmts.cpp @@ -1,3 +1,6 @@ +// Flaky on aarch64: http://llvm.org/PR126619 +// UNSUPPORTED: target=aarch64{{.*}} + // RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\ // RUN: | FileCheck %s diff --git a/clang/test/Analysis/no-outofbounds.c b/clang/test/Analysis/no-outofbounds.c deleted file mode 100644 index c6219ae74ab42..0000000000000 --- a/clang/test/Analysis/no-outofbounds.c +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,alpha.unix,security.ArrayBound -verify %s -// expected-no-diagnostics - -//===----------------------------------------------------------------------===// -// This file tests cases where we should not flag out-of-bounds warnings. -//===----------------------------------------------------------------------===// - -void f(void) { - long x = 0; - char *y = (char*) &x; - char c = y[0] + y[1] + y[2]; // no-warning - short *z = (short*) &x; - short s = z[0] + z[1]; // no-warning -} - -void g(void) { - int a[2]; - char *b = (char*)a; - b[3] = 'c'; // no-warning -} - -typedef typeof(sizeof(int)) size_t; -void *malloc(size_t); -void free(void *); - -void field(void) { - struct vec { size_t len; int data[0]; }; - struct vec *a = malloc(sizeof(struct vec) + 10*sizeof(int)); - a->len = 10; - a->data[1] = 5; // no-warning - free(a); -} diff --git a/clang/test/Analysis/out-of-bounds-diagnostics.c b/clang/test/Analysis/out-of-bounds-diagnostics.c index 1db01251148e1..524fa4e2aaaf7 100644 --- a/clang/test/Analysis/out-of-bounds-diagnostics.c +++ b/clang/test/Analysis/out-of-bounds-diagnostics.c @@ -231,7 +231,16 @@ int arrayOfStructsArrow(void) { // expected-note@-2 {{Access of 'itemArray' at index 35, while it holds only 20 'struct item' elements}} } +char convertedScalar(long long var) { + char *p = ((char*)&var); + (void) p[3]; // no-warning + return p[13]; + // expected-warning@-1 {{Out of bound access to memory after the end of 'var'}} + // expected-note@-2 {{Access of 'var' at index 13, while it holds only 8 'char' elements}} +} + short convertedArray(void) { + (void) ((short*)TenElements)[17]; // no-warning return ((short*)TenElements)[47]; // expected-warning@-1 {{Out of bound access to memory after the end of 'TenElements'}} // expected-note@-2 {{Access of 'TenElements' at index 47, while it holds only 20 'short' elements}} @@ -268,23 +277,41 @@ int intFromStringDivisible(void) { typedef __typeof(sizeof(int)) size_t; void *malloc(size_t size); +void free(void *mem); int *mallocRegion(void) { int *mem = (int*)malloc(2*sizeof(int)); + mem[1] = 48; // no-warning + mem[3] = -2; // expected-warning@-1 {{Out of bound access to memory after the end of the heap area}} // expected-note@-2 {{Access of the heap area at index 3, while it holds only 2 'int' elements}} return mem; } +typedef struct { size_t len; int data[0]; } vec_t; + +void mallocFlexibleArray(void) { + vec_t *v = malloc(sizeof(vec_t) + 10 * sizeof(int)); + v->len = 10; + v->data[1] = 5; // no-warning + v->data[11] = 99; + // TODO: Here ideally we would expect + // {{Out of bound access to memory after the end of the heap area}} + // {{Access of the heap area at index 11, while it holds only 10 'int' elements}} + // but the analyzer cannot (yet) deduce the size of the flexible array member + // from the size of the whole allocated area. + free(v); +} + int *custom_calloc(size_t a, size_t b) { size_t res; return __builtin_mul_overflow(a, b, &res) ? 0 : malloc(res); } -int *mallocRegionOverflow(void) { +int *mallocMulOverflow(void) { int *mem = (int*)custom_calloc(10, sizeof(int)); mem[20] = 10; diff --git a/clang/test/Analysis/out-of-bounds.c b/clang/test/Analysis/out-of-bounds.c index 734a56602e2aa..923797200d0b4 100644 --- a/clang/test/Analysis/out-of-bounds.c +++ b/clang/test/Analysis/out-of-bounds.c @@ -153,7 +153,7 @@ void test_assume_after_access(unsigned long x) { int *get_symbolic(void); void test_underflow_symbolic(void) { int *buf = get_symbolic(); - buf[-1] = 0; // no-warning; + buf[-1] = 0; // no-warning } // But warn if we understand the internal memory layout of a symbolic region. diff --git a/clang/test/Analysis/stack-addr-ps.cpp b/clang/test/Analysis/stack-addr-ps.cpp index 73e9dbeca460f..bf988d0a16959 100644 --- a/clang/test/Analysis/stack-addr-ps.cpp +++ b/clang/test/Analysis/stack-addr-ps.cpp @@ -90,6 +90,18 @@ int *mf() { return &x; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{address of stack memory associated with local variable 's1' returned}} } +int *return_assign_expr_leak() { + int x = 1; + int *y; + return y = &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned}} +} + +// Additional diagnostic from -Wreturn-stack-address in the simple case? +int *return_comma_separated_expressions_leak() { + int x = 1; + return (x=14), &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning{{address of stack memory associated with local variable 'x' returned}} +} + void *lf() { label: void *const &x = &&label; // expected-note {{binding reference variable 'x' here}} @@ -152,6 +164,18 @@ namespace rdar13296133 { } } // namespace rdar13296133 +void* ret_cpp_static_cast(short x) { + return static_cast(&x); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory}} +} + +int* ret_cpp_reinterpret_cast(double x) { + return reinterpret_cast(&x); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack me}} +} + +int* ret_cpp_const_cast(const int x) { + return const_cast(&x); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory}} +} + void write_stack_address_to(char **q) { char local; *q = &local; @@ -178,6 +202,11 @@ void test_copy_elision() { C c1 = make1(); } +C&& return_bind_rvalue_reference_to_temporary() { + return C(); // expected-warning{{Address of stack memory associated with temporary object of type 'C' returned to caller}} + // expected-warning@-1{{returning reference to local temporary object}} -Wreturn-stack-address +} + namespace leaking_via_direct_pointer { void* returned_direct_pointer_top() { int local = 42; @@ -251,7 +280,7 @@ void* lambda_to_context_direct_pointer_uncalled() { int local = 42; p = &local; // no-warning: analyzed only as top-level, ignored explicitly by the checker }; - return new MyFunction(&lambda); + return new MyFunction(&lambda); // expected-warning{{Address of stack memory associated with local variable 'lambda' returned to caller}} } void lambda_to_context_direct_pointer_lifetime_extended() { @@ -340,6 +369,13 @@ void param_ptr_to_ptr_to_ptr_callee(void*** ppp) { **ppp = &local; // expected-warning{{local variable 'local' is still referred to by the caller variable 'pp'}} } +void ***param_ptr_to_ptr_to_ptr_return(void ***ppp) { + int local = 0; + **ppp = &local; + return ppp; + // expected-warning@-1 {{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 'ppp' upon returning to the caller. This will be a dangling reference}} +} + void param_ptr_to_ptr_to_ptr_caller(void** pp) { param_ptr_to_ptr_to_ptr_callee(&pp); } @@ -410,16 +446,16 @@ void** returned_arr_of_ptr_top() { int* p = &local; void** arr = new void*[2]; arr[1] = p; - return arr; -} // no-warning False Negative + return arr; // expected-warning{{Address of stack memory associated with local variable 'local' returned to caller}} +} void** returned_arr_of_ptr_callee() { int local = 42; int* p = &local; void** arr = new void*[2]; arr[1] = p; - return arr; -} // no-warning False Negative + return arr; // expected-warning{{Address of stack memory associated with local variable 'local' returned to caller}} +} void returned_arr_of_ptr_caller() { void** arr = returned_arr_of_ptr_callee(); @@ -466,16 +502,16 @@ void** returned_arr_of_ptr_top(int idx) { int* p = &local; void** arr = new void*[2]; arr[idx] = p; - return arr; -} // no-warning False Negative + return arr; // expected-warning{{Address of stack memory associated with local variable 'local' returned to caller}} +} void** returned_arr_of_ptr_callee(int idx) { int local = 42; int* p = &local; void** arr = new void*[2]; arr[idx] = p; - return arr; -} // no-warning False Negative + return arr; // expected-warning{{Address of stack memory associated with local variable 'local' returned to caller}} +} void returned_arr_of_ptr_caller(int idx) { void** arr = returned_arr_of_ptr_callee(idx); @@ -525,14 +561,25 @@ S returned_struct_with_ptr_top() { int local = 42; S s; s.p = &local; - return s; -} // no-warning False Negative, requires traversing returned LazyCompoundVals + return s; // expected-warning{{Address of stack memory associated with local variable 'local' returned to caller}} +} S returned_struct_with_ptr_callee() { int local = 42; S s; s.p = &local; - return s; // expected-warning{{'local' is still referred to by the caller variable 's'}} + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'local' is still referred to by the caller variable 's' upon returning to the caller. This will be a dangling reference}} +} + +S leak_through_field_of_returned_object() { + int local = 14; + S s{&local}; + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} + +S leak_through_compound_literal() { + int local = 0; + return (S) { &local }; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} } void returned_struct_with_ptr_caller() { @@ -555,6 +602,30 @@ void static_struct_with_ptr() { } } // namespace leaking_via_struct_with_ptr +namespace leaking_via_nested_structs_with_ptr { +struct Inner { + int *ptr; +}; + +struct Outer { + Inner I; +}; + +struct Deriving : public Outer {}; + +Outer leaks_through_nested_objects() { + int local = 0; + Outer O{&local}; + return O; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} + +Deriving leaks_through_base_objects() { + int local = 0; + Deriving D{&local}; + return D; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} +} // namespace leaking_via_nested_structs_with_ptr + namespace leaking_via_ref_to_struct_with_ptr { struct S { int* p; @@ -613,15 +684,15 @@ S* returned_ptr_to_struct_with_ptr_top() { int local = 42; S* s = new S; s->p = &local; - return s; -} // no-warning False Negative + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} S* returned_ptr_to_struct_with_ptr_callee() { int local = 42; S* s = new S; s->p = &local; - return s; -} // no-warning False Negative + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} void returned_ptr_to_struct_with_ptr_caller() { S* s = returned_ptr_to_struct_with_ptr_callee(); @@ -676,15 +747,15 @@ S* returned_ptr_to_struct_with_ptr_top() { int local = 42; S* s = new S[2]; s[1].p = &local; - return s; -} // no-warning False Negative + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} S* returned_ptr_to_struct_with_ptr_callee() { int local = 42; S* s = new S[2]; s[1].p = &local; - return s; -} // no-warning False Negative + return s; // expected-warning {{Address of stack memory associated with local variable 'local' returned to caller}} +} void returned_ptr_to_struct_with_ptr_caller() { S* s = returned_ptr_to_struct_with_ptr_callee(); @@ -877,3 +948,137 @@ void top_malloc_no_crash_fn() { free(pptr); } } // namespace alloca_region_pointer + +// These all warn with -Wreturn-stack-address also +namespace return_address_of_true_positives { +int* ret_local_addrOf() { + int x = 1; + return &*&x; // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +int* ret_local_addrOf_paren() { + int x = 1; + return (&(*(&x))); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +int* ret_local_addrOf_ptr_arith() { + int x = 1; + return &*(&x+1); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +int* ret_local_addrOf_ptr_arith2() { + int x = 1; + return &*(&x+1); // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +int* ret_local_field() { + struct { int x; } a; + return &a.x; // expected-warning {{Address of stack memory associated with local variable 'a' returned to caller}} expected-warning {{address of stack memory associated with local variable 'a' returned}} +} + +int& ret_local_field_ref() { + struct { int x; } a; + return a.x; // expected-warning {{Address of stack memory associated with local variable 'a' returned to caller}} expected-warning {{reference to stack memory associated with local variable 'a' returned}} +} +} //namespace return_address_of_true_positives + +namespace true_negatives_return_expressions { +struct Container { int *x; }; + +int test2() { + int x = 14; + return x; // no-warning +} + +void return_void() { + return void(); // no-warning +} + +int return_assign_expr_safe() { + int y, x = 14; + return y = x; // no-warning +} + +int return_comma_separated_expressions_safe() { + int x = 1; + int *y; + return (y=&x), (x=15); // no-warning +} + +int return_comma_separated_expressions_container_safe() { + int x = 1; + Container Other; + return Other = Container{&x}, x = 14; // no-warning +} + +int make_x(); +int return_symbol_safe() { + int x = make_x(); + clang_analyzer_dump(x); // expected-warning-re {{conj_$2{int, {{.+}}}}} + return x; // no-warning +} + +int *return_symbolic_region_safe(int **ptr) { + return *ptr; // no-warning +} + +int *return_arg_ptr(int *arg) { + return arg; // no-warning +} + +// This has a false positive with -Wreturn-stack-address, but CSA should not +// warn on this +int *return_conditional_never_false(int *arg) { + int x = 14; + return true ? arg : &x; // expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +// This has a false positive with -Wreturn-stack-address, but CSA should not +// warn on this +int *return_conditional_never_true(int *arg) { + int x = 14; + return false ? &x : arg; // expected-warning {{address of stack memory associated with local variable 'x' returned}} +} + +int *return_conditional_path_split(int *arg, bool b) { + int x = 14; + return b ? arg : &x; // expected-warning {{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning {{address of stack memory associated with local variable 'x' returned}} -Wreturn-stack-address +} + +// compare of two symbolic regions +// maybe in some implementation, make_ptr returns interior pointers that are comparable +int *make_ptr(); +bool return_symbolic_exxpression() { + int *a = make_ptr(); + int *b = make_ptr(); + return a < b; // no-warning +} + +int *return_static() { + static int x = 0; + return &x; // no-warning +} + +int* return_cpp_reinterpret_cast_no_warning(long x) { + return reinterpret_cast(x); // no-warning +} +} + +// TODO: The tail call expression tree must not hold a reference to an arg or stack local: +// "The lifetimes of all local variables and function parameters end immediately before the +// [tail] call to the function. This means that it is undefined behaviour to pass a pointer or +// reference to a local variable to the called function, which is not the case without the +// attribute." +// These only warn from -Wreturn-stack-address for now +namespace with_attr_musttail { +void TakesIntAndPtr(int, int *); +void PassAddressOfLocal(int a, int *b) { + int c; + [[clang::musttail]] return TakesIntAndPtr(0, &c); // expected-warning {{address of stack memory associated with local variable 'c' pass\ +ed to musttail function}} False-negative on CSA +} +void PassAddressOfParam(int a, int *b) { + [[clang::musttail]] return TakesIntAndPtr(0, &a); // expected-warning {{address of stack memory associated with parameter 'a' passed to\ + musttail function}} False-negative on CSA +} +} // namespace with_attr_musttail diff --git a/clang/test/Analysis/stackaddrleak.c b/clang/test/Analysis/stackaddrleak.c index 5f508275ba9c8..f8101525401b0 100644 --- a/clang/test/Analysis/stackaddrleak.c +++ b/clang/test/Analysis/stackaddrleak.c @@ -56,3 +56,15 @@ void assignAsBool(void) { int x; b = &x; } // no-warning + +int *f(int* p __attribute__((lifetimebound))); +int *g() { + int i; + return f(&i); // expected-warning {{address of stack memory associated with local variable 'i' returned}} +} + +int *f_no_lifetime_bound(int *p); +int *g_no_lifetime_bound() { + int i = 0; + return f_no_lifetime_bound(&i); // no-warning +} diff --git a/clang/test/Analysis/stackaddrleak.cpp b/clang/test/Analysis/stackaddrleak.cpp index 3daffb35a6cd9..df202a2fee776 100644 --- a/clang/test/Analysis/stackaddrleak.cpp +++ b/clang/test/Analysis/stackaddrleak.cpp @@ -18,7 +18,7 @@ struct myfunction { myfunction create_func() { int n; auto c = [&n] {}; - return c; // expected-warning {{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}} + return c; // expected-warning {{Address of stack memory associated with local variable 'n' returned to caller}} expected-warning{{Address of stack memory associated with local variable 'n' is still referred to by a temporary object on the stack upon returning to the caller. This will be a dangling reference}} } void gh_66221() { create_func()(); diff --git a/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p4.cpp b/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p4.cpp new file mode 100644 index 0000000000000..e816da1803694 --- /dev/null +++ b/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p4.cpp @@ -0,0 +1,11 @@ +// RUN: %clang -fsyntax-only -std=c++20 -Xclang -verify %s + +void Func(int x) { + switch (x) { + [[likely]] case 0: + case 1: + int i = 3; // expected-note {{jump bypasses variable initialization}} + case 2: // expected-error {{cannot jump from switch statement to this case label}} + break; + } +} diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c index 22503c640a727..dcf7bbc005a7c 100644 --- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c +++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c @@ -201,22 +201,22 @@ __m512i test_mm512_maskz_cvts2ph_hf8(__mmask64 __U, __m512h __A, __m512h __B) { return _mm512_maskz_cvts2ph_hf8(__U, __A, __B); } -__m512h test_mm512_cvthf8(__m256i __A) { - // CHECK-LABEL: @test_mm512_cvthf8( +__m512h test_mm512_cvthf8_ph(__m256i __A) { + // CHECK-LABEL: @test_mm512_cvthf8_ph( // CHECK: call <32 x half> @llvm.x86.avx10.mask.vcvthf82ph512( - return _mm512_cvthf8(__A); + return _mm512_cvthf8_ph(__A); } -__m512h test_mm512_mask_cvthf8(__m512h __A, __mmask32 __B, __m256i __C) { - // CHECK-LABEL: @test_mm512_mask_cvthf8( +__m512h test_mm512_mask_cvthf8_ph(__m512h __A, __mmask32 __B, __m256i __C) { + // CHECK-LABEL: @test_mm512_mask_cvthf8_ph( // CHECK: call <32 x half> @llvm.x86.avx10.mask.vcvthf82ph512( - return _mm512_mask_cvthf8(__A, __B, __C); + return _mm512_mask_cvthf8_ph(__A, __B, __C); } -__m512h test_mm512_maskz_cvthf8(__mmask32 __A, __m256i __B) { - // CHECK-LABEL: @test_mm512_maskz_cvthf8( +__m512h test_mm512_maskz_cvthf8_ph(__mmask32 __A, __m256i __B) { + // CHECK-LABEL: @test_mm512_maskz_cvthf8_ph( // CHECK: call <32 x half> @llvm.x86.avx10.mask.vcvthf82ph512( - return _mm512_maskz_cvthf8(__A, __B); + return _mm512_maskz_cvthf8_ph(__A, __B); } __m256i test_mm512_cvtph_bf8(__m512h __A) { diff --git a/clang/test/CodeGen/X86/avx10_2convert-builtins.c b/clang/test/CodeGen/X86/avx10_2convert-builtins.c index efd9a31c40875..87fc6ffd7bc17 100644 --- a/clang/test/CodeGen/X86/avx10_2convert-builtins.c +++ b/clang/test/CodeGen/X86/avx10_2convert-builtins.c @@ -231,7 +231,7 @@ __m256i test_mm256_cvt2ph_bf8(__m256h __A, __m256h __B) { return _mm256_cvt2ph_bf8(__A, __B); } -__m256i test_mm256_mask_cvt2ph_bf8(__m256i __W, __mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_mask_cvt2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_mask_cvt2ph_bf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2bf8256( // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} @@ -239,7 +239,7 @@ __m256i test_mm256_mask_cvt2ph_bf8(__m256i __W, __mmask16 __U, __m256h __A, __m2 return _mm256_mask_cvt2ph_bf8(__W, __U, __A, __B); } -__m256i test_mm256_maskz_cvt2ph_bf8(__mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_maskz_cvt2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_maskz_cvt2ph_bf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2bf8256( // CHECK: zeroinitializer @@ -275,7 +275,7 @@ __m256i test_mm256_cvts2ph_bf8(__m256h __A, __m256h __B) { return _mm256_cvts2ph_bf8(__A, __B); } -__m256i test_mm256_mask_cvts2ph_bf8(__m256i __W, __mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_mask_cvts2ph_bf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_mask_cvts2ph_bf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2bf8s256( // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} @@ -283,7 +283,7 @@ __m256i test_mm256_mask_cvts2ph_bf8(__m256i __W, __mmask16 __U, __m256h __A, __m return _mm256_mask_cvts2ph_bf8(__W, __U, __A, __B); } -__m256i test_mm256_maskz_cvts2ph_bf8(__mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_maskz_cvts2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_maskz_cvts2ph_bf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2bf8s256( // CHECK: zeroinitializer @@ -319,7 +319,7 @@ __m256i test_mm256_cvt2ph_hf8(__m256h __A, __m256h __B) { return _mm256_cvt2ph_hf8(__A, __B); } -__m256i test_mm256_mask_cvt2ph_hf8(__m256i __W, __mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_mask_cvt2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_mask_cvt2ph_hf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2hf8256( // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} @@ -327,7 +327,7 @@ __m256i test_mm256_mask_cvt2ph_hf8(__m256i __W, __mmask16 __U, __m256h __A, __m2 return _mm256_mask_cvt2ph_hf8(__W, __U, __A, __B); } -__m256i test_mm256_maskz_cvt2ph_hf8(__mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_maskz_cvt2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_maskz_cvt2ph_hf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2hf8256( // CHECK: zeroinitializer @@ -363,7 +363,7 @@ __m256i test_mm256_cvts2ph_hf8(__m256h __A, __m256h __B) { return _mm256_cvts2ph_hf8(__A, __B); } -__m256i test_mm256_mask_cvts2ph_hf8(__m256i __W, __mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_mask_cvts2ph_hf8(__m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_mask_cvts2ph_hf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2hf8s256( // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} @@ -371,7 +371,7 @@ __m256i test_mm256_mask_cvts2ph_hf8(__m256i __W, __mmask16 __U, __m256h __A, __m return _mm256_mask_cvts2ph_hf8(__W, __U, __A, __B); } -__m256i test_mm256_maskz_cvts2ph_hf8(__mmask16 __U, __m256h __A, __m256h __B) { +__m256i test_mm256_maskz_cvts2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { // CHECK-LABEL: @test_mm256_maskz_cvts2ph_hf8( // CHECK: call <32 x i8> @llvm.x86.avx10.vcvt2ph2hf8s256( // CHECK: zeroinitializer @@ -379,40 +379,40 @@ __m256i test_mm256_maskz_cvts2ph_hf8(__mmask16 __U, __m256h __A, __m256h __B) { return _mm256_maskz_cvts2ph_hf8(__U, __A, __B); } -__m128h test_mm_cvthf8(__m128i __A) { - // CHECK-LABEL: @test_mm_cvthf8( +__m128h test_mm_cvthf8_ph(__m128i __A) { + // CHECK-LABEL: @test_mm_cvthf8_ph( // CHECK: call <8 x half> @llvm.x86.avx10.mask.vcvthf82ph128( - return _mm_cvthf8(__A); + return _mm_cvthf8_ph(__A); } -__m128h test_mm_mask_cvthf8(__m128h __A, __mmask8 __B, __m128i __C) { - // CHECK-LABEL: @test_mm_mask_cvthf8( +__m128h test_mm_mask_cvthf8_ph(__m128h __A, __mmask8 __B, __m128i __C) { + // CHECK-LABEL: @test_mm_mask_cvthf8_ph( // CHECK: call <8 x half> @llvm.x86.avx10.mask.vcvthf82ph128( - return _mm_mask_cvthf8(__A, __B, __C); + return _mm_mask_cvthf8_ph(__A, __B, __C); } -__m128h test_mm_maskz_cvthf8(__mmask8 __A, __m128i __B) { - // CHECK-LABEL: @test_mm_maskz_cvthf8( +__m128h test_mm_maskz_cvthf8_ph(__mmask8 __A, __m128i __B) { + // CHECK-LABEL: @test_mm_maskz_cvthf8_ph( // CHECK: call <8 x half> @llvm.x86.avx10.mask.vcvthf82ph128( - return _mm_maskz_cvthf8(__A, __B); + return _mm_maskz_cvthf8_ph(__A, __B); } -__m256h test_mm256_cvthf8(__m128i __A) { - // CHECK-LABEL: @test_mm256_cvthf8( +__m256h test_mm256_cvthf8_ph(__m128i __A) { + // CHECK-LABEL: @test_mm256_cvthf8_ph( // CHECK: call <16 x half> @llvm.x86.avx10.mask.vcvthf82ph256( - return _mm256_cvthf8(__A); + return _mm256_cvthf8_ph(__A); } -__m256h test_mm256_mask_cvthf8(__m256h __A, __mmask16 __B, __m128i __C) { - // CHECK-LABEL: @test_mm256_mask_cvthf8( +__m256h test_mm256_mask_cvthf8_ph(__m256h __A, __mmask16 __B, __m128i __C) { + // CHECK-LABEL: @test_mm256_mask_cvthf8_ph( // CHECK: call <16 x half> @llvm.x86.avx10.mask.vcvthf82ph256( - return _mm256_mask_cvthf8(__A, __B, __C); + return _mm256_mask_cvthf8_ph(__A, __B, __C); } -__m256h test_mm256_maskz_cvthf8(__mmask16 __A, __m128i __B) { - // CHECK-LABEL: @test_mm256_maskz_cvthf8( +__m256h test_mm256_maskz_cvthf8_ph(__mmask16 __A, __m128i __B) { + // CHECK-LABEL: @test_mm256_maskz_cvthf8_ph( // CHECK: call <16 x half> @llvm.x86.avx10.mask.vcvthf82ph256( - return _mm256_maskz_cvthf8(__A, __B); + return _mm256_maskz_cvthf8_ph(__A, __B); } __m128i test_mm_cvtph_bf8(__m128h __A) { diff --git a/clang/test/CodeGen/profile-continuous.c b/clang/test/CodeGen/profile-continuous.c new file mode 100644 index 0000000000000..86fa1d149b971 --- /dev/null +++ b/clang/test/CodeGen/profile-continuous.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -fprofile-instrument=llvm -fprofile-continuous %s -o - | FileCheck %s --check-prefix=IRPGO +// RUN: %clang_cc1 -emit-llvm -fprofile-instrument=llvm -fprofile-continuous -fprofile-instrument-path=mydir/default_%m.profraw -mllvm -runtime-counter-relocation %s -o - \ +// RUN: | FileCheck %s --check-prefix=IRPGO_EQ +// RUN: %clang_cc1 -emit-llvm -O2 -fprofile-instrument=csllvm -fprofile-continuous %s -o - | FileCheck %s --check-prefix=CSIRPGO +// RUN: %clang_cc1 -emit-llvm -fprofile-instrument=clang -fprofile-continuous -fprofile-instrument-path=default.profraw %s -o - | FileCheck %s --check-prefix=CLANG_PGO + +// IRPGO: @__llvm_profile_filename = {{.*}} c"%cdefault_%m.profraw\00" +// IRPGO_EQ: @__llvm_profile_filename = {{.*}} c"%cmydir/default_%m.profraw\00" +// CSIRPGO: @__llvm_profile_filename = {{.*}} c"%cdefault_%m.profraw\00" +// CLANG_PGO: @__llvm_profile_filename = {{.*}} c"%cdefault.profraw\00" +void foo(){} diff --git a/clang/test/CodeGenHLSL/resource-bindings.hlsl b/clang/test/CodeGenHLSL/resource-bindings.hlsl index bfa7896bd9811..57e8cc29572b1 100644 --- a/clang/test/CodeGenHLSL/resource-bindings.hlsl +++ b/clang/test/CodeGenHLSL/resource-bindings.hlsl @@ -2,14 +2,17 @@ // CHECK: define internal void @_init_resource_U0S0() // CHECK: %U0S0_h = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0t(i32 0, i32 0, i32 1, i32 0, i1 false) +// CHECK: store target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %U0S0_h, ptr @U0S0, align 4 RWBuffer U0S0 : register(u0); // CHECK: define internal void @_init_resource_U5S3() // CHECK: %U5S3_h = call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(i32 3, i32 5, i32 1, i32 0, i1 false) +// CHECK: store target("dx.TypedBuffer", float, 1, 0, 0) %U5S3_h, ptr @U5S3, align 4 RWBuffer U5S3 : register(u5, space3); // CHECK: define internal void @_init_resource_T2S2() // CHECK: %T2S2_h = call target("dx.RawBuffer", i32, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_0_0t(i32 2, i32 2, i32 1, i32 0, i1 false) +// CHECK: store target("dx.RawBuffer", i32, 0, 0) %T2S2_h, ptr @T2S2, align 4 StructuredBuffer T2S2 : register(t2, space2); struct S { float4 f; @@ -18,6 +21,7 @@ struct S { // CHECK: define internal void @_init_resource_T3S0() // CHECK: %T3S0_h = call target("dx.RawBuffer", %struct.S, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_s_struct.Ss_0_0t(i32 0, i32 3, i32 1, i32 0, i1 false) +// CHECK: store target("dx.RawBuffer", %struct.S, 0, 0) %T3S0_h, ptr @T3S0, align 4 StructuredBuffer T3S0 : register(t3); // CHECK: define void @main() diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 29a0fcbc17ac6..9f9ca1bf1a8fd 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -738,9 +738,13 @@ // RUN: -fno-modules-search-all \ // RUN: -fimplicit-modules \ // RUN: -fno-implicit-modules \ +// RUN: -fstrict-overflow \ +// RUN: -fno-strict-overflow \ // RUN: -ftrivial-auto-var-init=zero \ // RUN: -fwrapv \ // RUN: -fno-wrapv \ +// RUN: -fwrapv-pointer \ +// RUN: -fno-wrapv-pointer \ // RUN: --version \ // RUN: -Werror /Zs -- %s 2>&1 diff --git a/clang/test/Driver/clang_wrapv_opts.c b/clang/test/Driver/clang_wrapv_opts.c index 9f3a884324dcd..295d8deb0d99d 100644 --- a/clang/test/Driver/clang_wrapv_opts.c +++ b/clang/test/Driver/clang_wrapv_opts.c @@ -1,20 +1,20 @@ // RUN: %clang -### -S -fwrapv -fno-wrapv -fwrapv -Werror %s 2>&1 | FileCheck -check-prefix=CHECK1 %s // CHECK1: "-fwrapv" -// + // RUN: %clang -### -S -fwrapv-pointer -fno-wrapv-pointer -fwrapv-pointer -Werror %s 2>&1 | FileCheck -check-prefix=CHECK1-POINTER %s // CHECK1-POINTER: "-fwrapv-pointer" -// + // RUN: %clang -### -S -fstrict-overflow -fno-strict-overflow -Werror %s 2>&1 | FileCheck -check-prefix=CHECK2 %s // CHECK2: "-fwrapv"{{.*}}"-fwrapv-pointer" -// + // RUN: %clang -### -S -fwrapv -fstrict-overflow -Werror -Werror %s 2>&1 | FileCheck -check-prefix=CHECK3 %s --implicit-check-not="-fwrapv-pointer" -// CHECK3: "-fwrapv" -// +// CHECK3-NOT: "-fwrapv" + // RUN: %clang -### -S -fwrapv-pointer -fstrict-overflow -Werror %s 2>&1 | FileCheck -check-prefix=CHECK3-POINTER %s --implicit-check-not="-fwrapv" -// CHECK3-POINTER: "-fwrapv-pointer" -// -// RUN: %clang -### -S -fno-wrapv -fno-strict-overflow -Werror %s 2>&1 | FileCheck -check-prefix=CHECK4 %s --implicit-check-not="-fwrapv" -// CHECK4: "-fwrapv-pointer" -// -// RUN: %clang -### -S -fno-wrapv-pointer -fno-strict-overflow -Werror %s 2>&1 | FileCheck -check-prefix=CHECK4-POINTER %s --implicit-check-not="-fwrapv-pointer" -// CHECK4-POINTER: "-fwrapv" +// CHECK3-POINTER-NOT: "-fwrapv-pointer" + +// RUN: %clang -### -S -fno-wrapv -fno-strict-overflow -fno-wrapv-pointer -Werror %s 2>&1 | FileCheck -check-prefix=CHECK4 %s --implicit-check-not="-fwrapv-pointer" +// CHECK4: "-fwrapv" + +// RUN: %clang -### -S -fno-wrapv-pointer -fno-strict-overflow -fno-wrapv -Werror %s 2>&1 | FileCheck -check-prefix=CHECK4-POINTER %s --implicit-check-not="-fwrapv" +// CHECK4-POINTER: "-fwrapv-pointer" diff --git a/clang/test/Driver/csky-toolchain.c b/clang/test/Driver/csky-toolchain.c index 66485464652ac..638ce64ec98cd 100644 --- a/clang/test/Driver/csky-toolchain.c +++ b/clang/test/Driver/csky-toolchain.c @@ -3,6 +3,7 @@ // RUN: %clang -### %s --target=csky 2>&1 | FileCheck -check-prefix=CC1 %s // CC1: "-cc1" "-triple" "csky" +// CC1: "-fno-signed-char" // In the below tests, --rtlib=platform is used so that the driver ignores // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib diff --git a/clang/test/Driver/cuda-cross-compiling.c b/clang/test/Driver/cuda-cross-compiling.c index 7817e462c47be..1df231ecb4479 100644 --- a/clang/test/Driver/cuda-cross-compiling.c +++ b/clang/test/Driver/cuda-cross-compiling.c @@ -57,19 +57,6 @@ // LINK: clang-nvlink-wrapper{{.*}}"-o" "a.out" "-arch" "sm_61"{{.*}}[[CUBIN:.+]].o -// -// Test to ensure that we enable handling global constructors in a freestanding -// Nvidia compilation. -// -// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_70 %s -### 2>&1 \ -// RUN: | FileCheck -check-prefix=LOWERING %s -// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_70 -flto -c %s -### 2>&1 \ -// RUN: | FileCheck -check-prefix=LOWERING-LTO %s - -// LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" "--nvptx-lower-global-ctor-dtor" -// LOWERING: clang-nvlink-wrapper{{.*}} "-mllvm" "--nvptx-lower-global-ctor-dtor" -// LOWERING-LTO-NOT: "--nvptx-lower-global-ctor-dtor" - // // Test passing arguments directly to nvlink. // diff --git a/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip b/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip new file mode 100644 index 0000000000000..79a52f0bc8981 --- /dev/null +++ b/clang/test/Driver/dep-file-flag-with-multiple-offload-archs.hip @@ -0,0 +1,13 @@ +// RUN: %clang -### -nogpuinc -nogpulib --offload-arch=gfx1030 --offload-arch=gfx1100 --offload-arch=gfx1101 -MD -MF tmp.d %s 2>&1 | FileCheck %s + +// CHECK: Build config: +// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1030"{{.*}}"-dependency-file" "tmp.d" +// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1030" +// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1100"{{.*}}"-dependency-file" "tmp.d" +// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1100" +// CHECK-NOT: {{.*}}clang{{.*}}"-target-cpu" "gfx1101"{{.*}}"-dependency-file" "tmp.d" +// CHECK: {{.*}}lld{{.*}}"-plugin-opt=mcpu=gfx1101" +// CHECK: {{.*}}clang-offload-bundler +// CHECK: {{.*}}clang{{.*}}"-target-cpu"{{.*}}"-dependency-file" "tmp.d" + +void main(){} diff --git a/clang/test/Driver/fprofile-continuous.c b/clang/test/Driver/fprofile-continuous.c new file mode 100644 index 0000000000000..81719fb70cb1e --- /dev/null +++ b/clang/test/Driver/fprofile-continuous.c @@ -0,0 +1,21 @@ +// 1) test on platforms that (do or do not) require runtime relocation + +// RUN: %clang --target=x86_64-darwin -fprofile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=NO_RELOC +// NO_RELOC: "-cc1" {{.*}} "-fprofile-continuous" +// NO_RELOC-NOT: "-mllvm" "-runtime-counter-relocation" + +// RUN: %clang --target=powerpc64-ibm-aix -fprofile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC +// RUN: %clang --target=x86_64-unknown-fuchsia -fprofile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC +// RELOC: "-cc1" {{.*}} "-fprofile-continuous" "-mllvm" "-runtime-counter-relocation" + +// 2) test -fprofile-continuous with cs-profile-generate and -fprofile-instr-generate + +// RUN: %clang --target=powerpc-ibm-aix -fprofile-instr-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=CLANG_PGO +// RUN: %clang --target=powerpc64le-unknown-linux -fprofile-instr-generate= -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=CLANG_PGO +// CLANG_PGO: "-cc1" {{.*}} "-fprofile-continuous" "-mllvm" "-runtime-counter-relocation" "-fprofile-instrument-path=default.profraw" + +// RUN: %clang --target=x86_64-unknown-fuchsia -fcs-profile-generate -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=RELOC + +// RUN: not %clang -fprofile-continuous -### -c %s 2>&1 | FileCheck %s --check-prefix=ERROR +// ERROR: error: invalid argument '-fprofile-continuous' only allowed with '-fprofile-generate, -fprofile-instr-generate, or -fcs-profile-generate' +void foo(){} diff --git a/clang/test/Driver/linker-wrapper.c b/clang/test/Driver/linker-wrapper.c index f416ee5f4463b..df0a1d1e9a84d 100644 --- a/clang/test/Driver/linker-wrapper.c +++ b/clang/test/Driver/linker-wrapper.c @@ -59,7 +59,7 @@ __attribute__((visibility("protected"), used)) int x; // RUN: --linker-path=/usr/bin/ld.lld --whole-archive %t.a --no-whole-archive \ // RUN: %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=CPU-LINK -// CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -march=native -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive +// CPU-LINK: clang{{.*}} -o {{.*}}.img --target=x86_64-unknown-linux-gnu -O2 -flto -Wl,--no-undefined {{.*}}.o {{.*}}.o -Wl,-Bsymbolic -shared -Wl,--whole-archive {{.*}}.a -Wl,--no-whole-archive // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o // RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu -mllvm -openmp-opt-disable \ diff --git a/clang/test/Driver/offload-Xarch.c b/clang/test/Driver/offload-Xarch.c index 18c68f2acc884..0f8f40a5cbd74 100644 --- a/clang/test/Driver/offload-Xarch.c +++ b/clang/test/Driver/offload-Xarch.c @@ -1,3 +1,5 @@ +// UNSUPPORTED: target={{.*darwin.*}} + // RUN: %clang --target=x86_64-unknown-linux-gnu -x cuda %s -Xarch_nvptx64 -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s // RUN: %clang -x cuda %s -Xarch_device -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s // RUN: %clang -x hip %s -Xarch_amdgcn -O3 -S -nogpulib -nogpuinc -### 2>&1 | FileCheck -check-prefix=O3ONCE %s @@ -35,7 +37,7 @@ // Make sure that `-Xarch_amdgcn` forwards libraries to the device linker. // RUN: %clang -fopenmp=libomp --offload-arch=gfx90a -nogpulib -nogpuinc \ -// RUN: -Xarch_amdgcn -Wl,-lfoo -### %s 2>&1 \ +// RUN: --target=x86_64-unknown-linux-gnu -Xarch_amdgcn -Wl,-lfoo -### %s 2>&1 \ // RUN: | FileCheck -check-prefix=LIBS %s // RUN: %clang -fopenmp=libomp --offload-arch=gfx90a -nogpulib -nogpuinc \ // RUN: -Xoffload-linker-amdgcn-amd-amdhsa -lfoo -### %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-jit.cpp b/clang/test/Driver/sycl-offload-jit.cpp index eb192e08a3bc0..e040f4ded18e9 100644 --- a/clang/test/Driver/sycl-offload-jit.cpp +++ b/clang/test/Driver/sycl-offload-jit.cpp @@ -27,7 +27,7 @@ // CHK-DEVICE-TRIPLE-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHK-DEVICE-TRIPLE-SAME: "-fsycl-is-device" // CHK-DEVICE-TRIPLE-SAME: "-O2" -// CHK-DEVICE-TRIPLE: clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=spirv64-unknown-unknown,arch=,kind=sycl" +// CHK-DEVICE-TRIPLE: clang-offload-packager{{.*}} "--image=file={{.*}}.bc,triple=spirv64-unknown-unknown,arch=generic,kind=sycl" /// Check -fsycl-is-device is passed when compiling for the device. /// Check -fsycl-is-host is passed when compiling for host. diff --git a/clang/test/ExtractAPI/typedef_underscore.c b/clang/test/ExtractAPI/typedef_underscore.c new file mode 100644 index 0000000000000..a42046907b46d --- /dev/null +++ b/clang/test/ExtractAPI/typedef_underscore.c @@ -0,0 +1,69 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \ +// RUN: --product-name=TypedefChain -triple arm64-apple-macosx -x c-header %s -o %t/typedefchain-c.symbols.json -verify +// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \ +// RUN: --product-name=TypedefChain -triple arm64-apple-macosx -x c++-header %s -o %t/typedefchain-cxx.symbols.json -verify + +// RUN: FileCheck %s --input-file %t/typedefchain-c.symbols.json --check-prefix MYSTRUCT +// RUN: FileCheck %s --input-file %t/typedefchain-cxx.symbols.json --check-prefix MYSTRUCT +typedef struct _MyStruct { } MyStruct; + +// MYSTRUCT-LABEL: "!testLabel": "c:@S@_MyStruct" +// MYSTRUCT: "accessLevel": "public", +// MYSTRUCT: "declarationFragments": [ +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "keyword", +// MYSTRUCT-NEXT: "spelling": "typedef" +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "text", +// MYSTRUCT-NEXT: "spelling": " " +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "keyword", +// MYSTRUCT-NEXT: "spelling": "struct" +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "text", +// MYSTRUCT-NEXT: "spelling": " " +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "identifier", +// MYSTRUCT-NEXT: "spelling": "_MyStruct" +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "text", +// MYSTRUCT-NEXT: "spelling": " { ... } " +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "identifier", +// MYSTRUCT-NEXT: "spelling": "MyStruct" +// MYSTRUCT-NEXT: }, +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "text", +// MYSTRUCT-NEXT: "spelling": ";" +// MYSTRUCT-NEXT: } +// MYSTRUCT-NEXT: ], +// MYSTRUCT: "kind": { +// MYSTRUCT-NEXT: "displayName": "Structure", +// MYSTRUCT-NEXT: "identifier": "c{{(\+\+)?}}.struct" +// MYSTRUCT: "names": { +// MYSTRUCT-NEXT: "navigator": [ +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "identifier", +// MYSTRUCT-NEXT: "spelling": "MyStruct" +// MYSTRUCT-NEXT: } +// MYSTRUCT-NEXT: ], +// MYSTRUCT-NEXT: "subHeading": [ +// MYSTRUCT-NEXT: { +// MYSTRUCT-NEXT: "kind": "identifier", +// MYSTRUCT-NEXT: "spelling": "MyStruct" +// MYSTRUCT-NEXT: } +// MYSTRUCT-NEXT: ], +// MYSTRUCT-NEXT: "title": "MyStruct" +// MYSTRUCT-NEXT: }, +// MYSTRUCT: "pathComponents": [ +// MYSTRUCT-NEXT: "MyStruct" +// MYSTRUCT-NEXT: ] + +// expected-no-diagnostics diff --git a/clang/test/Index/index-deduction-guide.cpp b/clang/test/Index/index-deduction-guide.cpp new file mode 100644 index 0000000000000..a29162e8588e8 --- /dev/null +++ b/clang/test/Index/index-deduction-guide.cpp @@ -0,0 +1,10 @@ +// RUN: c-index-test core -print-source-symbols -- %s -std=gnu++17 | FileCheck %s + +template +typename T::type declval() {} +template struct Test; +template ().d())> Test(C &) -> Test; +// CHECK: [[@LINE-1]]:45 | function/C | declval +// CHECK-NOT: RelCall +// CHECK: [[@LINE-3]]:77 | struct(Gen)/C++ | Test +// CHECK: [[@LINE-4]]:64 | struct(Gen)/C++ | Test diff --git a/clang/test/Modules/pr120277-2.cpp b/clang/test/Modules/pr120277-2.cpp new file mode 100644 index 0000000000000..f3a7e47431848 --- /dev/null +++ b/clang/test/Modules/pr120277-2.cpp @@ -0,0 +1,66 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \ +// RUN: -o %t/hu-01.pcm + +// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \ +// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm + +// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \ +// RUN: -Wno-experimental-header-units \ +// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm + +// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \ +// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-02.pcm \ +// RUN: -fmodule-file=%t/hu-03.pcm -o %t/hu-04.pcm + +// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \ +// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-04.pcm +//--- hu-01.h +template +struct A { + ~A() { f(); } + auto f() const { return 0; } +}; + +template +struct B { + int g() const { return a.f(); } + A a; +}; + +//--- hu-02.h +import "hu-01.h"; + +template +struct C { + void h() { + B().g(); + } +}; + +template struct A; + +//--- hu-03.h +import "hu-01.h"; + +inline B b() { + return {}; +} + +//--- hu-04.h +import "hu-02.h"; +import "hu-03.h"; + +inline void f4() { + C{}.h(); +} + +//--- main.cpp +import "hu-04.h"; + +int main() { + f4(); +} diff --git a/clang/test/Modules/pr126373.cppm b/clang/test/Modules/pr126373.cppm new file mode 100644 index 0000000000000..f176a587b51ce --- /dev/null +++ b/clang/test/Modules/pr126373.cppm @@ -0,0 +1,34 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/module1.cppm -emit-module-interface -o %t/module1.pcm +// RUN: %clang_cc1 -std=c++20 -fmodule-file=module1=%t/module1.pcm %t/module2.cppm \ +// RUN: -emit-module-interface -o %t/module2.pcm +// RUN: %clang_cc1 -std=c++20 %t/module2.pcm -fmodule-file=module1=%t/module1.pcm \ +// RUN: -emit-llvm -o - | FileCheck %t/module2.cppm + +//--- test.h +template +struct Test { + template + friend class Test; +}; + +//--- module1.cppm +module; +#include "test.h" +export module module1; +export void f1(Test) {} + +//--- module2.cppm +module; +#include "test.h" +export module module2; +import module1; +export void f2(Test) {} + +extern "C" void func() {} + +// Fine enough to check the IR is emitted correctly. +// CHECK: define{{.*}}@func diff --git a/clang/test/OpenMP/declare_target_messages.cpp b/clang/test/OpenMP/declare_target_messages.cpp index ce5a833b3866a..3c0e766cf72ca 100644 --- a/clang/test/OpenMP/declare_target_messages.cpp +++ b/clang/test/OpenMP/declare_target_messages.cpp @@ -33,6 +33,11 @@ // RUN: %clang_cc1 %{common_opts_mac} -verify=expected,omp51,ompvar,omp45-to-51,omp5-and-51,omp5-or-later,omp5-or-later-var,omp45-to-51-var,omp45-to-51-clause,host-5-and-51,no-host5-and-51 -fopenmp %{limit} -o - %s // RUN: %clang_cc1 %{common_opts_mac} -verify=expected,omp52,ompvar,omp5-or-later,omp5-or-later-var %{openmp60} %{limit} -o - %s +#pragma omp begin declare target +static int gg; +// expected-warning@+1 {{variable 'recursive' is uninitialized when used within its own initialization}} +int recursive = recursive ^ 3 + gg; +#pragma omp end declare target // expected-error@+1 {{unexpected OpenMP directive '#pragma omp end declare target'}} #pragma omp end declare target diff --git a/clang/test/OpenMP/spirv_target_codegen_basic.cpp b/clang/test/OpenMP/spirv_target_codegen_basic.cpp new file mode 100644 index 0000000000000..fb2810e88c063 --- /dev/null +++ b/clang/test/OpenMP/spirv_target_codegen_basic.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=spirv64-intel -emit-llvm-bc %s -o %t-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple spirv64-intel -fopenmp-targets=spirv64-intel -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s + +// expected-no-diagnostics + +// CHECK: @__omp_offloading_{{.*}}_dynamic_environment = weak_odr protected addrspace(1) global %struct.DynamicEnvironmentTy zeroinitializer +// CHECK: @__omp_offloading_{{.*}}_kernel_environment = weak_odr protected addrspace(1) constant %struct.KernelEnvironmentTy + +// CHECK: define weak_odr protected spir_kernel void @__omp_offloading_{{.*}} + +int main() { + int ret = 0; + #pragma omp target + for(int i = 0; i < 5; i++) + ret++; + return ret; +} diff --git a/clang/test/Sema/avr-interript-signal-attr.c b/clang/test/Sema/avr-interript-signal-attr.c new file mode 100644 index 0000000000000..7360dbdedb695 --- /dev/null +++ b/clang/test/Sema/avr-interript-signal-attr.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only +struct a { int b; }; + +struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} + +__attribute__((interrupt(12))) void foo(void) { } // expected-error {{'interrupt' attribute takes no arguments}} + +__attribute__((interrupt)) int fooa(void) { return 0; } // expected-warning {{'interrupt' attribute only applies to functions that have a 'void' return type}} + +__attribute__((interrupt)) void foob(int a) {} // expected-warning {{'interrupt' attribute only applies to functions that have no parameters}} + +__attribute__((signal)) int fooc(void) { return 0; } // expected-warning {{'signal' attribute only applies to functions that have a 'void' return type}} + +__attribute__((signal)) void food(int a) {} // expected-warning {{'signal' attribute only applies to functions that have no parameters}} + +__attribute__((interrupt)) void fooe(void) {} + +__attribute__((interrupt)) void foof() {} + +__attribute__((signal)) void foog(void) {} + +__attribute__((signal)) void fooh() {} diff --git a/clang/test/Sema/avr-interrupt-attr.c b/clang/test/Sema/avr-interrupt-attr.c deleted file mode 100644 index 7aee7babcbe16..0000000000000 --- a/clang/test/Sema/avr-interrupt-attr.c +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only -struct a { int b; }; - -struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions}} - -__attribute__((interrupt(12))) void foo(void) { } // expected-error {{'interrupt' attribute takes no arguments}} - -__attribute__((interrupt)) void food(void) {} diff --git a/clang/test/Sema/avr-signal-attr.c b/clang/test/Sema/avr-signal-attr.c deleted file mode 100644 index 1ec36c74a25eb..0000000000000 --- a/clang/test/Sema/avr-signal-attr.c +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -triple avr-unknown-unknown -verify -fsyntax-only -struct a { int b; }; - -struct a test __attribute__((signal)); // expected-warning {{'signal' attribute only applies to functions}} - -__attribute__((signal(12))) void foo(void) { } // expected-error {{'signal' attribute takes no arguments}} - -__attribute__((signal)) void food(void) {} diff --git a/clang/test/SemaCUDA/device-var-init.cu b/clang/test/SemaCUDA/device-var-init.cu index 1555d151c2590..a9e3557c20ebf 100644 --- a/clang/test/SemaCUDA/device-var-init.cu +++ b/clang/test/SemaCUDA/device-var-init.cu @@ -485,3 +485,12 @@ void instantiate() { bar<<<1, 1>>>(); // expected-note@-1 {{in instantiation of function template specialization 'bar' requested here}} } + +__device__ void *ptr1 = nullptr; +__device__ void *ptr2 = ptr1; +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}} + +__device__ [[gnu::constructor(101)]] void ctor() {} +// expected-error@-1 {{CUDA does not support global constructors for __device__ functions}} +__device__ [[gnu::destructor(101)]] void dtor() {} +// expected-error@-1 {{CUDA does not support global destructors for __device__ functions}} diff --git a/clang/test/SemaCXX/attr-cxx0x.cpp b/clang/test/SemaCXX/attr-cxx0x.cpp index 4d64d2b0cd8c6..58180a21ca8e9 100644 --- a/clang/test/SemaCXX/attr-cxx0x.cpp +++ b/clang/test/SemaCXX/attr-cxx0x.cpp @@ -53,3 +53,26 @@ alignas(4) auto PR19252 = 0; // Check the diagnostic message class alignas(void) AlignasVoid {}; // expected-error {{invalid application of 'alignas' to an incomplete type 'void'}} + +namespace GH108819 { +void a([[maybe_unused]] void) {} // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}}\ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} +void b([[deprecated, maybe_unused]] void) {} // expected-warning {{attribute 'deprecated' cannot be applied to a 'void' parameter}} \ + // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \ + // expected-warning {{use of the 'deprecated' attribute is a C++14 extension}} \ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} +void c([[clang::lifetimebound]] void) {} // expected-warning {{attribute 'lifetimebound' cannot be applied to a 'void' parameter}} +void d([[clang::annotate("a", "b", 1)]] void) {} // expected-warning {{attribute 'annotate' cannot be applied to a 'void' parameter}} + +struct S { + void e([[maybe_unused]] void) {} // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} +}; + +template +void f([[maybe_unused]] void) {} // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} + +auto g = []([[maybe_unused]] void) { }; // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \ + // expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}} +} diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp b/clang/test/SemaCXX/cxx1z-decomposition.cpp index a8914fe4e9cd8..95c64bc3b8bff 100644 --- a/clang/test/SemaCXX/cxx1z-decomposition.cpp +++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp @@ -200,38 +200,32 @@ namespace lambdas { namespace by_value_array_copy { struct explicit_copy { - explicit_copy() = default; // expected-note 2{{candidate constructor not viable: requires 0 arguments, but 1 was provided}} - explicit explicit_copy(const explicit_copy&) = default; // expected-note 2{{explicit constructor is not a candidate}} + explicit_copy() = default; // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} + explicit explicit_copy(const explicit_copy&) = default; // expected-note {{explicit constructor is not a candidate}} }; - constexpr int direct_initialization_for_elements() { - explicit_copy ec_arr[2]; - auto [a1, b1](ec_arr); + constexpr int simple_array_elements() { + int arr[2]{1, 2}; - int arr[3]{1, 2, 3}; - auto [a2, b2, c2](arr); - arr[0]--; - return a2 + b2 + c2 + arr[0]; - } - static_assert(direct_initialization_for_elements() == 6); + auto [a1, a2] = arr; + auto [b1, b2](arr); + auto [c1, c2]{arr}; // GH31813 - constexpr int copy_initialization_for_elements() { - int arr[2]{4, 5}; - auto [a1, b1] = arr; - auto [a2, b2]{arr}; // GH31813 arr[0] = 0; - return a1 + b1 + a2 + b2 + arr[0]; + return arr[0] + a1 + a2 + b1 + b2 + c1 + c2; } - static_assert(copy_initialization_for_elements() == 18); + static_assert(simple_array_elements() == 9); + + void explicit_copy_ctor_array_elements() { + explicit_copy ec_arr[1]; - void copy_initialization_for_elements_with_explicit_copy_ctor() { - explicit_copy ec_arr[2]; - auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}} - auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}} + auto [a] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[1]'}} + auto [b](ec_arr); + auto [c]{ec_arr}; // Test prvalue - using T = explicit_copy[2]; - auto [a3, b3] = T{}; - auto [a4, b4]{T{}}; + using T = explicit_copy[1]; + auto [d] = T{}; } + } // namespace by_value_array_copy diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp index 2d43e46b9e3d7..37dca2215af6b 100644 --- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp +++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp @@ -234,11 +234,23 @@ int i = 0; AFoo s{i}; static_assert(__is_same(decltype(s.t), int)); +template +using BFoo = AFoo; + +// template explicit deduction guide. +template +Foo(T) -> Foo; +static_assert(__is_same(decltype(AFoo(i).t), float)); +static_assert(__is_same(decltype(BFoo(i).t), float)); + // explicit deduction guide. Foo(int) -> Foo; -AFoo s2{i}; -// FIXME: the type should be X because of the above explicit deduction guide. -static_assert(__is_same(decltype(s2.t), int)); +static_assert(__is_same(decltype(AFoo(i).t), X)); +static_assert(__is_same(decltype(BFoo(i).t), X)); + +Foo(double) -> Foo; +static_assert(__is_same(decltype(AFoo(1.0).t), int)); +static_assert(__is_same(decltype(BFoo(1.0).t), int)); } // namespace test16 namespace test17 { diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp index 7578b288d7b3f..4af2c998f082e 100644 --- a/clang/test/SemaCXX/uninitialized.cpp +++ b/clang/test/SemaCXX/uninitialized.cpp @@ -1542,9 +1542,15 @@ void aggregate() { }; }; + struct CopyAndMove { + CopyAndMove() = default; + CopyAndMove(const CopyAndMove &) {} + CopyAndMove(CopyAndMove &&) {} + }; struct Embed { int embed1; // #FIELD_EMBED1 int embed2 [[clang::require_explicit_initialization]]; // #FIELD_EMBED2 + CopyAndMove force_separate_move_ctor; }; struct EmbedDerived : Embed {}; struct F { @@ -1582,7 +1588,33 @@ void aggregate() { F("___"), F("____") }; - (void)ctors; + + struct MoveOrCopy { + Embed e; + EmbedDerived ed; + F f; + // no-error + MoveOrCopy(const MoveOrCopy &c) : e(c.e), ed(c.ed), f(c.f) {} + // no-error + MoveOrCopy(MoveOrCopy &&c) + : e(std::move(c.e)), ed(std::move(c.ed)), f(std::move(c.f)) {} + }; + F copy1(ctors[0]); // no-error + (void)copy1; + F move1(std::move(ctors[0])); // no-error + (void)move1; + F copy2{ctors[0]}; // no-error + (void)copy2; + F move2{std::move(ctors[0])}; // no-error + (void)move2; + F copy3 = ctors[0]; // no-error + (void)copy3; + F move3 = std::move(ctors[0]); // no-error + (void)move3; + F copy4 = {ctors[0]}; // no-error + (void)copy4; + F move4 = {std::move(ctors[0])}; // no-error + (void)move4; S::foo(S{1, 2, 3, 4}); S::foo(S{.s1 = 100, .s4 = 100}); diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index b189cfee674dd..aa43b2f5f2a1b 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -474,8 +474,6 @@ Expected clang(ArrayRef InputFiles, const ArgList &Args) { const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); StringRef Arch = Args.getLastArgValue(OPT_arch_EQ); - if (Arch.empty()) - Arch = "native"; // Create a new file to write the linked device image to. Assume that the // input filename already has the device and architecture. auto TempFileOrErr = @@ -492,11 +490,14 @@ Expected clang(ArrayRef InputFiles, const ArgList &Args) { "-o", *TempFileOrErr, Args.MakeArgString("--target=" + Triple.getTriple()), - Triple.isAMDGPU() ? Args.MakeArgString("-mcpu=" + Arch) - : Args.MakeArgString("-march=" + Arch), - Args.MakeArgString("-" + OptLevel), }; + if (!Arch.empty()) + Triple.isAMDGPU() ? CmdArgs.push_back(Args.MakeArgString("-mcpu=" + Arch)) + : CmdArgs.push_back(Args.MakeArgString("-march=" + Arch)); + + CmdArgs.push_back(Args.MakeArgString("-" + OptLevel)); + // Forward all of the `--offload-opt` and similar options to the device. CmdArgs.push_back("-flto"); for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) @@ -826,8 +827,9 @@ DerivedArgList getLinkerArgs(ArrayRef Input, // Set the subarchitecture and target triple for this compilation. const OptTable &Tbl = getOptTable(); + StringRef Arch = Args.MakeArgString(Input.front().getBinary()->getArch()); DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_arch_EQ), - Args.MakeArgString(Input.front().getBinary()->getArch())); + Arch == "generic" ? "" : Arch); DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_triple_EQ), Args.MakeArgString(Input.front().getBinary()->getTriple())); diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index 0cb2a1288bfd7..9cd262960b724 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -168,6 +168,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) { CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine); CHECK_PARSE_BOOL(AllowShortNamespacesOnASingleLine); CHECK_PARSE_BOOL(BinPackArguments); + CHECK_PARSE_BOOL(BinPackLongBracedList); CHECK_PARSE_BOOL(BreakAdjacentStringLiterals); CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations); CHECK_PARSE_BOOL(BreakBeforeTemplateCloser); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a9fddc3275aed..9b9ce35f83bc5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14420,6 +14420,51 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { "};", NoBinPacking); + NoBinPacking.BinPackLongBracedList = false; + verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n" + " bbbbb,\n" + " ccccc,\n" + " ddddd,\n" + " eeeee,\n" + " ffffff,\n" + " ggggg,\n" + " hhhhhh,\n" + " iiiiii,\n" + " jjjjjj,\n" + " kkkkkk,\n" + " aaaaa,\n" + " bbbbb,\n" + " ccccc,\n" + " ddddd,\n" + " eeeee,\n" + " ffffff,\n" + " ggggg,\n" + " hhhhhh,\n" + " iiiiii};", + NoBinPacking); + verifyFormat("const Aaaaaa aaaaa = {\n" + " aaaaa,\n" + " bbbbb,\n" + " ccccc,\n" + " ddddd,\n" + " eeeee,\n" + " ffffff,\n" + " ggggg,\n" + " hhhhhh,\n" + " iiiiii,\n" + " jjjjjj,\n" + " kkkkkk,\n" + " aaaaa,\n" + " bbbbb,\n" + " ccccc,\n" + " ddddd,\n" + " eeeee,\n" + " ffffff,\n" + " ggggg,\n" + " hhhhhh,\n" + "};", + NoBinPacking); + NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; verifyFormat("static uint8 CddDp83848Reg[] = {\n" " CDDDP83848_BMCR_REGISTER,\n" diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 1b09c45703456..54d8ff0571ca6 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -874,6 +874,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) { EXPECT_TOKEN(Tokens[14], tok::r_paren, TT_CastRParen); EXPECT_TOKEN(Tokens[15], tok::amp, TT_UnaryOperator); + Tokens = annotate("return (Foo (Bar::*)())&Bar::foo;"); + ASSERT_EQ(Tokens.size(), 17u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_FunctionTypeLParen); + EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_CastRParen); + EXPECT_TOKEN(Tokens[11], tok::amp, TT_UnaryOperator); + auto Style = getLLVMStyle(); Style.TypeNames.push_back("Foo"); Tokens = annotate("#define FOO(bar) foo((Foo)&bar)", Style); diff --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/clang/utils/TableGen/ClangOptionDocEmitter.cpp index e08fb11df3100..b6c1aad90b5cb 100644 --- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp +++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp @@ -109,13 +109,17 @@ Documentation extractDocumentation(const RecordKeeper &Records, // Pretend no-X and Xno-Y options are aliases of X and XY. std::string Name = std::string(R->getValueAsString("Name")); if (Name.size() >= 4) { - if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) { - Aliases[OptionsByName[Name.substr(3)]].push_back(R); - continue; + if (Name.substr(0, 3) == "no-") { + if (const Record *Opt = OptionsByName[Name.substr(3)]) { + Aliases[Opt].push_back(R); + continue; + } } - if (Name.substr(1, 3) == "no-" && OptionsByName[Name[0] + Name.substr(4)]) { - Aliases[OptionsByName[Name[0] + Name.substr(4)]].push_back(R); - continue; + if (Name.substr(1, 3) == "no-") { + if (const Record *Opt = OptionsByName[Name[0] + Name.substr(4)]) { + Aliases[Opt].push_back(R); + continue; + } } } diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 014b20667e03e..7bee2996382c1 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -1629,17 +1629,10 @@ void EmitterBase::EmitBuiltinCG(raw_ostream &OS) { for (const auto &OI : kv.second) key.push_back(OI.ParamValues[i]); - auto Found = ParamNumberMap.find(key); - if (Found != ParamNumberMap.end()) { - // Yes, an existing parameter variable can be reused for this. - ParamNumbers.push_back(Found->second); - continue; - } - - // No, we need a new parameter variable. - int ExistingIndex = ParamNumberMap.size(); - ParamNumberMap[key] = ExistingIndex; - ParamNumbers.push_back(ExistingIndex); + // Obtain a new parameter variable if we don't have one. + int ParamNum = + ParamNumberMap.try_emplace(key, ParamNumberMap.size()).first->second; + ParamNumbers.push_back(ParamNum); } // Now we're ready to do the pass 2 code generation, which will emit the diff --git a/compiler-rt/lib/builtins/cpu_model/riscv.c b/compiler-rt/lib/builtins/cpu_model/riscv.c index 74534896057ef..6879c2ad48264 100644 --- a/compiler-rt/lib/builtins/cpu_model/riscv.c +++ b/compiler-rt/lib/builtins/cpu_model/riscv.c @@ -14,12 +14,6 @@ struct { unsigned long long features[RISCV_FEATURE_BITS_LENGTH]; } __riscv_feature_bits __attribute__((visibility("hidden"), nocommon)); -#define RISCV_VENDOR_FEATURE_BITS_LENGTH 1 -struct { - unsigned length; - unsigned long long features[RISCV_VENDOR_FEATURE_BITS_LENGTH]; -} __riscv_vendor_feature_bits __attribute__((visibility("hidden"), nocommon)); - struct { unsigned mvendorid; unsigned long long marchid; @@ -338,11 +332,11 @@ static int FeaturesBitCached = 0; void __init_riscv_feature_bits(void *); static void __init_riscv_feature_bits_ctor(void) CONSTRUCTOR_ATTRIBUTE; -// A constructor function that sets __riscv_feature_bits, and -// __riscv_vendor_feature_bits to the right values. This needs to run -// only once. This constructor is given the highest priority and it should -// run before constructors without the priority set. However, it still runs -// after ifunc initializers and needs to be called explicitly there. +// A constructor function that sets __riscv_feature_bits +// to the right values. This needs to run only once. This constructor is given +// the highest priority and it should run before constructors without the +// priority set. However, it still runs after ifunc initializers and needs to +// be called explicitly there. static void CONSTRUCTOR_ATTRIBUTE __init_riscv_feature_bits_ctor(void) { __init_riscv_feature_bits(0); @@ -357,7 +351,6 @@ void __init_riscv_feature_bits(void *PlatformArgs) { return; __riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH; - __riscv_vendor_feature_bits.length = RISCV_VENDOR_FEATURE_BITS_LENGTH; #if defined(__linux__) struct riscv_hwprobe Hwprobes[] = { diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp index 83e6cdd4a0094..410da0748b433 100644 --- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp +++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp @@ -254,6 +254,27 @@ INTERCEPTOR(int, fchdir, int fd) { return REAL(fchdir)(fd); } +#if SANITIZER_INTERCEPT_READLINK +INTERCEPTOR(ssize_t, readlink, const char *pathname, char *buf, size_t size) { + __rtsan_notify_intercepted_call("readlink"); + return REAL(readlink)(pathname, buf, size); +} +#define RTSAN_MAYBE_INTERCEPT_READLINK INTERCEPT_FUNCTION(readlink) +#else +#define RTSAN_MAYBE_INTERCEPT_READLINK +#endif + +#if SANITIZER_INTERCEPT_READLINKAT +INTERCEPTOR(ssize_t, readlinkat, int dirfd, const char *pathname, char *buf, + size_t size) { + __rtsan_notify_intercepted_call("readlinkat"); + return REAL(readlinkat)(dirfd, pathname, buf, size); +} +#define RTSAN_MAYBE_INTERCEPT_READLINKAT INTERCEPT_FUNCTION(readlinkat) +#else +#define RTSAN_MAYBE_INTERCEPT_READLINKAT +#endif + // Streams INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) { @@ -1402,6 +1423,8 @@ void __rtsan::InitializeInterceptors() { INTERCEPT_FUNCTION(close); INTERCEPT_FUNCTION(chdir); INTERCEPT_FUNCTION(fchdir); + RTSAN_MAYBE_INTERCEPT_READLINK; + RTSAN_MAYBE_INTERCEPT_READLINKAT; INTERCEPT_FUNCTION(fopen); RTSAN_MAYBE_INTERCEPT_FOPEN64; RTSAN_MAYBE_INTERCEPT_FREOPEN64; diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp index 075f5974b7562..98d27caae94b8 100644 --- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp +++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp @@ -457,6 +457,24 @@ TEST(TestRtsanInterceptors, FchdirDiesWhenRealtime) { ExpectNonRealtimeSurvival(Func); } +#if SANITIZER_INTERCEPT_READLINK +TEST(TestRtsanInterceptors, ReadlinkDiesWhenRealtime) { + char buf[1024]; + auto Func = [&buf]() { readlink("/proc/self", buf, sizeof(buf)); }; + ExpectRealtimeDeath(Func, "readlink"); + ExpectNonRealtimeSurvival(Func); +} +#endif + +#if SANITIZER_INTERCEPT_READLINKAT +TEST(TestRtsanInterceptors, ReadlinkatDiesWhenRealtime) { + char buf[1024]; + auto Func = [&buf]() { readlinkat(0, "/proc/self", buf, sizeof(buf)); }; + ExpectRealtimeDeath(Func, "readlinkat"); + ExpectNonRealtimeSurvival(Func); +} +#endif + TEST_F(RtsanFileTest, FopenDiesWhenRealtime) { auto Func = [this]() { FILE *f = fopen(GetTemporaryFilePath(), "w"); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp index 945da99d41f4e..b05c67e354418 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp @@ -37,25 +37,28 @@ # include #endif #include // for user_regs_struct -#if SANITIZER_ANDROID && SANITIZER_MIPS -# include // for mips SP register in sys/user.h -#endif -#include // for signal-related stuff - -#ifdef sa_handler -# undef sa_handler -#endif - -#ifdef sa_sigaction -# undef sa_sigaction -#endif - -#include "sanitizer_common.h" -#include "sanitizer_flags.h" -#include "sanitizer_libc.h" -#include "sanitizer_linux.h" -#include "sanitizer_mutex.h" -#include "sanitizer_placement_new.h" +# if SANITIZER_MIPS +// clang-format off +# include // must be included before +# include // for mips SP register +// clang-format on +# endif +# include // for signal-related stuff + +# ifdef sa_handler +# undef sa_handler +# endif + +# ifdef sa_sigaction +# undef sa_sigaction +# endif + +# include "sanitizer_common.h" +# include "sanitizer_flags.h" +# include "sanitizer_libc.h" +# include "sanitizer_linux.h" +# include "sanitizer_mutex.h" +# include "sanitizer_placement_new.h" // Sufficiently old kernel headers don't provide this value, but we can still // call prctl with it. If the runtime kernel is new enough, the prctl call will @@ -510,11 +513,7 @@ typedef pt_regs regs_struct; #elif defined(__mips__) typedef struct user regs_struct; -# if SANITIZER_ANDROID -# define REG_SP regs[EF_R29] -# else -# define REG_SP regs[EF_REG29] -# endif +# define REG_SP regs[EF_R29] #elif defined(__aarch64__) typedef struct user_pt_regs regs_struct; diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp index 272520fa51f01..1bec83be4c80b 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp @@ -352,6 +352,7 @@ TEST(SanitizerCommon, ReportFile) { // This will close tmpfile. report_file.SetReportPath("stderr"); Unlink(tmpfile); + Unlink(path); } TEST(SanitizerCommon, FileExists) { diff --git a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp index 71291e8a53158..1b79016988260 100644 --- a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp @@ -4,6 +4,7 @@ // RUN: %env_asan_opts=coverage=1 %run ./test.exe // // RUN: %sancov print *.sancov | FileCheck %s +// XFAIL: msvc #include diff --git a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp index 74200cca1521b..bafc40c2c5665 100644 --- a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp @@ -2,12 +2,13 @@ // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=READ // RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE -#include +#include "../defines.h" #include +#include static volatile int sink; -__attribute__((noinline)) void Read(int *ptr) { sink = *ptr; } -__attribute__((noinline)) void Write(int *ptr) { *ptr = 0; } +ATTRIBUTE_NOINLINE void Read(int *ptr) { sink = *ptr; } +ATTRIBUTE_NOINLINE void Write(int *ptr) { *ptr = 0; } int main(int argc, char **argv) { // Writes to shadow are detected as reads from shadow gap (because of how the // shadow mapping works). This is kinda hard to fix. Test a random address in diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp index 85b7967e86b51..773482783823f 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp @@ -1,4 +1,5 @@ // UNSUPPORTED: target={{.*-windows-gnu}} +// XFAIL: msvc // This is a host program for DLL tests. // diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp index 0a96752f9d0bf..4fa437960f126 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp @@ -1,9 +1,9 @@ // RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t -// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll +// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %LD %Od %s %Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s // Test that it works correctly even with ICF enabled. -// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \ +// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %LD %Od %s %Fe%t.dll \ // RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \ // RUN: %else %{ -link /OPT:REF /OPT:ICF %} // RUN: not %run %t %t.dll 2>&1 | FileCheck %s @@ -23,12 +23,12 @@ int test_function() { // CHECK: Initial test OK memcpy(buff2, buff1, 6); -// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] -// CHECK: WRITE of size 6 at [[ADDR]] thread T0 -// CHECK-NEXT: __asan_{{.*}}memcpy -// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cpp:[[@LINE-4]] -// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame -// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cpp -// CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable + // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] + // CHECK: WRITE of size 6 at [[ADDR]] thread T0 + // CHECK-NEXT: __asan_{{.*}}{{(memcpy|memmove)}} + // CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cpp:[[@LINE-4]] + // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame + // CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cpp + // CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable return 0; } diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp index 27b343f439cb5..948a429e8c1a6 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp @@ -1,9 +1,9 @@ -// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t -// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll +// RUN: %clang_cl_asan %Od %Oy- %p/dll_host.cpp %Fe%t +// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %Oy- %LD %Od %s %Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s // Test that it works correctly even with ICF enabled. -// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \ +// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %Oy- %LD %Od %s %Fe%t.dll \ // RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \ // RUN: %else %{ -link /OPT:REF /OPT:ICF %} // RUN: not %run %t %t.dll 2>&1 | FileCheck %s diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp index b65926941cd78..d0d9a8ff0f516 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp @@ -2,7 +2,9 @@ // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s -__attribute__((noinline)) +#include "../defines.h" + +ATTRIBUTE_NOINLINE static void NullDeref(int *ptr) { // CHECK: ERROR: AddressSanitizer: access-violation on unknown address // CHECK: {{0x0*000.. .*pc 0x.*}} diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp index ca6b256654a23..1d279f279d768 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp @@ -2,12 +2,20 @@ // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s +#include "../defines.h" + struct C { int x; ~C() {} }; -int __attribute__((noinline, optnone)) hide(int x) { return x; } +int ATTRIBUTE_NOINLINE +#if defined(__clang__) || !defined(_MSC_VER) + __attribute__((optnone)) +#endif + hide(int x) { + return x; +} extern "C" __declspec(dllexport) int test_function() { diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp index be237044bb340..3a09566eb873f 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp @@ -4,6 +4,8 @@ // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll -fsanitize-address-use-after-return=always // RUN: not %run %t %t.dll 2>&1 | FileCheck %s +// UNSUPPORTED: msvc + #include char *x; diff --git a/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp index 9788609773644..9615ccfc2aa0e 100644 --- a/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp @@ -13,7 +13,7 @@ int main(void) { // CHECK: AddressSanitizer: global-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: READ of size 1 at [[ADDR]] thread T0 // CHECK-NEXT: {{#0 .* main .*global_const_string_oob.cpp:}}[[@LINE-5]] - // CHECK: [[ADDR]] is located 5 bytes after global variable [[STR:.*]] defined in {{'.*global_const_string_oob.cpp' .*}} of size 11 + // CHECK: [[ADDR]] is located 5 bytes after global variable [[STR:.*]] defined in {{'.*global_const_string_oob.cpp.*}} of size 11 // CHECK: [[STR]] is ascii string 'foobarspam' return 0; } diff --git a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp index 9b902c7536ca9..5c71c38a5113b 100644 --- a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cl_asan %Od %s %Fe%t // RUN: %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s +// msvc doesn't have a __builtin_trap equivalent +// XFAIL: msvc // Test the error output from an illegal instruction. diff --git a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp index b1b6e42148cb6..5222ec6e08191 100644 --- a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp @@ -1,9 +1,13 @@ // Repro for the issue #64990: Asan with Windows EH generates __asan_xxx runtime calls without required funclet tokens -// RUN: %clang_cl_asan %Od %s -EHsc %Fe%t +// RUN: %clang_cl_asan %Od %if MSVC %{ /Oi %} %s -EHsc %Fe%t // RUN: not %run %t 2>&1 | FileCheck %s // UNSUPPORTED: target={{.*-windows-gnu}} +#if defined(_MSC_VER) && !defined(__clang__) +# include +#endif + char buff1[6] = "hello"; char buff2[6] = "hello"; @@ -12,7 +16,11 @@ int main(int argc, char **argv) { throw 1; } catch (...) { // Make asan generate call to __asan_memcpy inside the EH pad. +#if defined(_MSC_VER) && !defined(__clang__) + memcpy(buff1, buff2 + 3, 6); +#else __builtin_memcpy(buff1, buff2 + 3, 6); +#endif } return 0; } diff --git a/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp b/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp index 4cb0c55bc7730..f3c7e1a33a568 100644 --- a/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp @@ -2,15 +2,15 @@ // different EH personality depending on the -GS setting, so test both -GS+ and // -GS-. // -// RUN: cl -c %s -Fo%t.obj -DCOMPILE_SEH -// RUN: %clangxx_asan -o %t.exe %s %t.obj +// RUN: cl /EHa %MD -c %s -Fo%t.obj -DCOMPILE_SEH +// RUN: %clangxx_asan -o %t.exe %s %t.obj -DCOMPILE_MAIN // RUN: %run %t.exe // -// RUN: cl -GS- -c %s -Fo%t.obj -DCOMPILE_SEH -// RUN: %clangxx_asan -o %t.exe %s %t.obj +// RUN: cl /EHa %MD -GS- -c %s -Fo%t.obj -DCOMPILE_SEH +// RUN: %clangxx_asan -o %t.exe %s %t.obj -DCOMPILE_MAIN // RUN: %run %t.exe // -// RUN: %clang_cl_asan %s -DCOMPILE_SEH -Fe%t.exe +// RUN: %clang_cl_asan /EHa %MD %s -DCOMPILE_SEH -Fe%t.exe -DCOMPILE_MAIN // RUN: %run %t.exe #include @@ -42,7 +42,7 @@ void ThrowAndCatch() { } #endif -#if defined(__clang__) +#if defined(COMPILE_MAIN) int main() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp b/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp deleted file mode 100644 index 6582bac9e69e3..0000000000000 --- a/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s -// FIXME: merge this with the common null_deref test when we can run common -// tests on Windows. - -__attribute__((noinline)) -static void NullDeref(int *ptr) { - // CHECK: ERROR: AddressSanitizer: access-violation on unknown address - // CHECK: {{0x0*000.. .*pc 0x.*}} - ptr[10]++; // BOOM -} -int main() { - NullDeref((int*)0); - // CHECK: {{ #1 0x.* in main.*null_deref.cpp:}}[[@LINE-1]]:3 - // CHECK: AddressSanitizer can not provide additional info. -} diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp index ea5140a13dc88..19e3beefa4e0f 100644 --- a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp @@ -9,6 +9,7 @@ // RUN: %clang_cl_asan %Od -DEXE %s %t1.lib %t2.lib %Fe%t // RUN: not %run %t 2>&1 | FileCheck %s +#include "../defines.h" #include #include @@ -28,7 +29,8 @@ __declspec(dllexport) void foo1() {} } #elif defined(DLL2) extern "C" { -__attribute__((noinline)) static void NullDeref(int *ptr) { +ATTRIBUTE_NOINLINE +static void NullDeref(int *ptr) { // CHECK: ERROR: AddressSanitizer: access-violation on unknown address // CHECK: {{0x0*000.. .*pc 0x.*}} ptr[10]++; // BOOM diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp index cad28ae8ace21..c66b201500e36 100644 --- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp @@ -1,13 +1,21 @@ // RUN: %clang_cl_asan %Od %s %Fe%t // RUN: not %run %t 2>&1 | FileCheck %s +#include "../defines.h" + struct C { int x; ~C() {} }; - -int __attribute__((noinline, optnone)) hide(int x) { return x; } - +#if defined(_MSC_VER) && !defined(__clang__) +# pragma optimize("", off) +#else +__attribute__((optnone)) +#endif +int ATTRIBUTE_NOINLINE hide(int x) { return x; } +#if defined(_MSC_VER) && !defined(__clang__) +# pragma optimize("", on) +#endif int main() { C *buffer = new C[42]; buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42; diff --git a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp index 1424ee88129f6..ee953cd6e4bfe 100644 --- a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp @@ -3,6 +3,7 @@ // FIXME: On MinGW frame #0 does not include the line number? // XFAIL: target={{.*-windows-gnu}} +// XFAIL: msvc // Test the error output from misaligned SSE2 memory access. This is a READ // memory access. Windows appears to always provide an address of -1 for these diff --git a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp index 9385e36a37b67..0b33ff3340cf6 100644 --- a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp @@ -3,7 +3,7 @@ // RUN: %clang_cl_asan %Od %s %Fe%t -fsanitize-address-use-after-return=always // RUN: not %run %t 2>&1 | FileCheck %s - +// XFAIL: msvc char *x; void foo() { diff --git a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp index 00428b809fccd..ade5e5b914be8 100644 --- a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp +++ b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp @@ -8,9 +8,10 @@ // RUN: not %run %t.exe 2>&1 | FileCheck %s // REQUIRES: lld-available -#include +#include "../defines.h" #include -int __attribute__((noinline)) do_uaf(void); +#include +int ATTRIBUTE_NOINLINE do_uaf(void); int main() { int r = do_uaf(); printf("r: %d\n", r); diff --git a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp index a451e873f2e42..5ef52e7b6e0dd 100644 --- a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp @@ -1,12 +1,14 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // +// XFAIL: msvc +#include "defines.h" #include #include -__attribute__((noinline)) void foo(int index, int len) { - volatile char str[len] __attribute__((aligned(128))); +ATTRIBUTE_NOINLINE void foo(int index, int len) { + volatile char str[len] ATTRIBUTE_ALIGNED(128); assert(!(reinterpret_cast(str) & 127L)); str[index] = '1'; // BOOM // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] diff --git a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp index 8910ea9f8d8e2..91c3ca296ac1e 100644 --- a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp @@ -7,6 +7,9 @@ #include #include #include +#ifdef _MSC_VER +# include +#endif // MSVC provides _alloca instead of alloca. #if defined(_MSC_VER) && !defined(alloca) diff --git a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp index 8b207aa07f2eb..e8e73d46f8a73 100644 --- a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp @@ -2,16 +2,24 @@ // RUN: not %run %t 2>&1 | FileCheck %s // +#include "defines.h" #include #include +#if defined(_MSC_VER) && !defined(__clang__) +# include +#endif struct A { char a[3]; int b[3]; }; -__attribute__((noinline)) void foo(int index, int len) { - volatile struct A str[len] __attribute__((aligned(32))); +ATTRIBUTE_NOINLINE void foo(int index, int len) { +#if !defined(_MSC_VER) || defined(__clang__) + volatile struct A str[len] ATTRIBUTE_ALIGNED(32); +#else + volatile struct A *str = (volatile struct A *)_alloca(len * sizeof(struct A)); +#endif assert(!(reinterpret_cast(str) & 31L)); str[index].a[0] = '1'; // BOOM // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] diff --git a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp index 912c8b0abaabd..4688079dfe6fb 100644 --- a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp @@ -2,6 +2,8 @@ // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: %run %t 2>&1 // +// MSVC does not support asan-instrament-dynamic-allocas yet +// UNSUPPORTED: msvc #include "sanitizer/asan_interface.h" #include diff --git a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp index 0967b34dc7dbf..7e77d963c1e65 100644 --- a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp @@ -5,10 +5,14 @@ // This testcase checks that allocas and VLAs inside loop are correctly unpoisoned. +// MSVC doesn't support VLAs in the first place. +// UNSUPPORTED: msvc + +#include "defines.h" +#include "sanitizer/asan_interface.h" #include #include #include -#include "sanitizer/asan_interface.h" // MSVC provides _alloca instead of alloca. #if defined(_MSC_VER) && !defined(alloca) @@ -21,7 +25,7 @@ void *top, *bot; -__attribute__((noinline)) void foo(int len) { +ATTRIBUTE_NOINLINE void foo(int len) { char x; top = &x; volatile char array[len]; diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp index 25c6d75be7a53..f06195bb7793f 100644 --- a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp @@ -1,6 +1,8 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp index 7ec4b86cdc715..626c12488858d 100644 --- a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp @@ -1,6 +1,8 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp index 98e31769812bf..8979b6ca726ee 100644 --- a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp @@ -1,6 +1,8 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: %run %t 2>&1 // +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp index 52cd781c4bb88..532344319b019 100644 --- a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp @@ -1,6 +1,8 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp index b98bb726dcebc..e83812242f88b 100644 --- a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp +++ b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp @@ -8,6 +8,9 @@ // This testcase checks correct interaction between VLAs and allocas. +// MSVC doesn't support VLA's +// UNSUPPORTED: msvc + #include #include #include diff --git a/compiler-rt/test/asan/TestCases/contiguous_container.cpp b/compiler-rt/test/asan/TestCases/contiguous_container.cpp index 6288e752fd4ba..a2adb1951dde6 100644 --- a/compiler-rt/test/asan/TestCases/contiguous_container.cpp +++ b/compiler-rt/test/asan/TestCases/contiguous_container.cpp @@ -2,6 +2,7 @@ // // Test __sanitizer_annotate_contiguous_container. +#include "defines.h" #include #include #include @@ -247,9 +248,9 @@ void TestDoubleEndedContainer(size_t capacity, size_t off_begin, delete[] buffer; } -__attribute__((noinline)) void Throw() { throw 1; } +ATTRIBUTE_NOINLINE void Throw() { throw 1; } -__attribute__((noinline)) void ThrowAndCatch() { +ATTRIBUTE_NOINLINE void ThrowAndCatch() { try { Throw(); } catch (...) { diff --git a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp index c03a6f02f7719..e55c3acce9af3 100644 --- a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp +++ b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp @@ -2,6 +2,8 @@ // RUN: %clangxx_asan -O0 -DTRACE_RT %s -o %t-rt.o -c // RUN: %clangxx_asan -O0 -fsanitize-coverage=edge,trace-pc,indirect-calls %s -o %t %t-rt.o // RUN: %run %t +// XFAIL: msvc + #ifdef TRACE_RT int pc_count; void *last_callee; @@ -12,13 +14,14 @@ extern "C" void __sanitizer_cov_trace_pc_indir(void *callee) { last_callee = callee; } #else -#include -#include +# include "defines.h" +# include +# include extern int pc_count; extern void *last_callee; -__attribute__((noinline)) void foo() { printf("foo\n"); } -__attribute__((noinline)) void bar() { printf("bar\n"); } +ATTRIBUTE_NOINLINE void foo() { printf("foo\n"); } +ATTRIBUTE_NOINLINE void bar() { printf("bar\n"); } int main(int argc, char **argv) { void (*f)(void) = argc ? foo : bar; diff --git a/compiler-rt/test/asan/TestCases/debug_locate.cpp b/compiler-rt/test/asan/TestCases/debug_locate.cpp index 93d1af8b83916..2ccddd4739d4a 100644 --- a/compiler-rt/test/asan/TestCases/debug_locate.cpp +++ b/compiler-rt/test/asan/TestCases/debug_locate.cpp @@ -3,7 +3,7 @@ // that it correctly finds out which region (and name and size) the address // belongs to. // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 - +// UNSUPPORTED: msvc #include #include #include diff --git a/compiler-rt/test/asan/TestCases/debug_stacks.cpp b/compiler-rt/test/asan/TestCases/debug_stacks.cpp index 67a9ac849c3aa..391e241023462 100644 --- a/compiler-rt/test/asan/TestCases/debug_stacks.cpp +++ b/compiler-rt/test/asan/TestCases/debug_stacks.cpp @@ -1,6 +1,6 @@ // Check that the stack trace debugging API works and returns correct // malloc and free stacks. -// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O0 %if MSVC %{ /wd4477 %} %s -o %t && not %run %t 2>&1 | FileCheck %s // FIXME: Figure out why allocation/free stack traces may be too short on ARM. // REQUIRES: stable-runtime diff --git a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp index 628ef06db1447..772fa48bab7dc 100644 --- a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp +++ b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp @@ -4,15 +4,16 @@ // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s // CHECK: AddressSanitizer: global-buffer-overflow +#include "defines.h" int global[10]; // CHECK: {{#0.*call4}} -void __attribute__((noinline)) call4(int i) { global[i+10]++; } +void ATTRIBUTE_NOINLINE call4(int i) { global[i + 10]++; } // CHECK: {{#1.*call3}} -void __attribute__((noinline)) call3(int i) { call4(i); } +void ATTRIBUTE_NOINLINE call3(int i) { call4(i); } // CHECK: {{#2.*call2}} -void __attribute__((noinline)) call2(int i) { call3(i); } +void ATTRIBUTE_NOINLINE call2(int i) { call3(i); } // CHECK: {{#3.*call1}} -void __attribute__((noinline)) call1(int i) { call2(i); } +void ATTRIBUTE_NOINLINE call1(int i) { call2(i); } // CHECK: {{#4.*main}} int main(int argc, char **argv) { call1(argc); diff --git a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp index 8297b51e7680e..c1277394680f1 100644 --- a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp +++ b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp @@ -1,5 +1,5 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 -// XFAIL: android +// XFAIL: android, msvc // UNSUPPORTED: ios // // Test that ASan uses the default ignorelist from resource directory. diff --git a/compiler-rt/test/asan/TestCases/default_options.cpp b/compiler-rt/test/asan/TestCases/default_options.cpp index 845e8a5f1793e..33507f3c82ef1 100644 --- a/compiler-rt/test/asan/TestCases/default_options.cpp +++ b/compiler-rt/test/asan/TestCases/default_options.cpp @@ -1,13 +1,14 @@ // RUN: %clangxx_asan -O2 %s -o %t // RUN: %run %t 2>&1 | FileCheck %s +#include "defines.h" + const char *kAsanDefaultOptions = "verbosity=1 help=1"; // Required for dyld macOS 12.0+ #if (__APPLE__) __attribute__((weak)) #endif -__attribute__((no_sanitize_address)) -extern "C" const char * +ATTRIBUTE_NO_SANITIZE_ADDRESS extern "C" const char * __asan_default_options() { // CHECK: Available flags for AddressSanitizer: return kAsanDefaultOptions; diff --git a/compiler-rt/test/asan/TestCases/defines.h b/compiler-rt/test/asan/TestCases/defines.h new file mode 100644 index 0000000000000..db6e374d2a031 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/defines.h @@ -0,0 +1,34 @@ +#ifndef SANITIZER_TEST_DEFINES_H +#define SANITIZER_TEST_DEFINES_H + +#if defined(_MSC_VER) && !defined(__clang__) +# include + +# define ATTRIBUTE_NOINLINE __declspec(noinline) +# define ATTRIBUTE_ALIGNED(x) __declspec(align(x)) +# define ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address) +# define ATTRIBUTE_USED /* FIXME: Is there a __declspec used? */ +# define ATTRIBUTE_ALWAYS_INLINE __forceinline +# define VOLATILE volatile +# define EXTRACT_RETURN_ADDRESS _ReturnAddress() +# define ASM_CAUSE_SIDE_EFFECT(dest) __asm { mov eax, dest} +# define MULTIPLE_ATTRIBUTE_DECL(a, b) __declspec(a b) + +#else + +# define ATTRIBUTE_NOINLINE __attribute__((noinline)) +# define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x))) +# define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +# define ATTRIBUTE_USED __attribute__((used)) +# define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) +# define INLINE_ASM(x) __asm__(x) +# define VOLATILE __volatile__ +# define EXTRACT_RETURN_ADDRESS \ + __builtin_extract_return_addr(__builtin_return_address(0)) +# define ASM_CAUSE_SIDE_EFFECT(dest) \ + __asm__ __volatile__("" : : "r"(dest) : "memory"); +# define MULTIPLE_ATTRIBUTE_DECL(a, b) __attribute__((a, b)) + +#endif // _MSC_VER + +#endif // SANITIZER_TEST_DEFINES diff --git a/compiler-rt/test/asan/TestCases/error_report_callback.cpp b/compiler-rt/test/asan/TestCases/error_report_callback.cpp index 8c5bbe418fc52..903947e729fb2 100644 --- a/compiler-rt/test/asan/TestCases/error_report_callback.cpp +++ b/compiler-rt/test/asan/TestCases/error_report_callback.cpp @@ -1,6 +1,7 @@ // RUN: %clangxx_asan -O0 %s -o %t // RUN: not %run %t 0 2>&1 | FileCheck %s +#include "defines.h" #include #include @@ -11,9 +12,7 @@ static void ErrorReportCallbackOneToZ(const char *report) { int main(int argc, char **argv) { __asan_set_error_report_callback(ErrorReportCallbackOneToZ); - __asan_report_error( - (void *)__builtin_extract_return_addr(__builtin_return_address(0)), 0, 0, - 0, true, 1); + __asan_report_error((void *)EXTRACT_RETURN_ADDRESS, 0, 0, 0, true, 1); // CHECK: ABCDEF // CHECK: ERROR: AddressSanitizer // CHECK: GHIJKL diff --git a/compiler-rt/test/asan/TestCases/exitcode.cpp b/compiler-rt/test/asan/TestCases/exitcode.cpp index e949436e1909c..21743bfbd7b8d 100644 --- a/compiler-rt/test/asan/TestCases/exitcode.cpp +++ b/compiler-rt/test/asan/TestCases/exitcode.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx_asan -g -Wno-deprecated-declarations %s -o %t +// RUN: %clangxx_asan -g %if !MSVC %{ -Wno-deprecated-declarations %} %s -o %t // RUN: %env_asan_opts=exitcode=42 %run %t | FileCheck %s // Android doesn't have spawn.h or posix_spawn. diff --git a/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp b/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp index e6e5d26c7998e..0c721bcc5c809 100644 --- a/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp +++ b/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp @@ -1,8 +1,11 @@ // This test checks that we are no instrumenting a memory access twice // (before and after inlining) -// RUN: %clangxx_asan -O1 %s -o %t && %run %t -// RUN: %clangxx_asan -O0 %s -o %t && %run %t -__attribute__((always_inline)) +// RUN: %clangxx_asan -O1 %if MSVC %{ /Ob1 %} %s -o %t && %run %t +// RUN: %clangxx_asan -O0 %if MSVC %{ /Ob1 %} %s -o %t && %run %t + +#include "defines.h" + +ATTRIBUTE_ALWAYS_INLINE void foo(int *x) { *x = 0; } diff --git a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp index 07c8e63f439da..199816b8036ab 100644 --- a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp +++ b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp @@ -11,7 +11,7 @@ /// Solaris ld -S has different semantics, so enforce -fuse-ld= for /// configurations that default to GNU ld. // XFAIL: target={{.*solaris.*}} - +// XFAIL: msvc // CHECK: AddressSanitizer: global-buffer-overflow // CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 // GLOB-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40 diff --git a/compiler-rt/test/asan/TestCases/global-underflow.cpp b/compiler-rt/test/asan/TestCases/global-underflow.cpp index 32b4ce82f9b04..fc9b14628aece 100644 --- a/compiler-rt/test/asan/TestCases/global-underflow.cpp +++ b/compiler-rt/test/asan/TestCases/global-underflow.cpp @@ -1,3 +1,4 @@ +// XFAIL: msvc // RUN: %clangxx_asan -O0 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s // RUN: %clangxx_asan -O1 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s // RUN: %clangxx_asan -O2 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s diff --git a/compiler-rt/test/asan/TestCases/halt_on_error-1.c b/compiler-rt/test/asan/TestCases/halt_on_error-1.c index 63c65e58bb71b..d40a281987133 100644 --- a/compiler-rt/test/asan/TestCases/halt_on_error-1.c +++ b/compiler-rt/test/asan/TestCases/halt_on_error-1.c @@ -5,7 +5,7 @@ // RUN: env not %run %t 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=true not %run %t 2>&1 | FileCheck %s // RUN: %env_asan_opts=halt_on_error=false %run %t 2>&1 | FileCheck %s --check-prefix CHECK-RECOVER - +// XFAIL: msvc #include volatile int ten = 10; diff --git a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp index 661867260d260..200d19cdbaf8a 100644 --- a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp +++ b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp @@ -15,29 +15,29 @@ // UNSUPPORTED: ios +#include "defines.h" #include -#include #include +#include #ifdef _WIN32 # include #endif -__attribute__((noinline)) +ATTRIBUTE_NOINLINE char *pretend_to_do_something(char *x) { __asm__ __volatile__("" : : "r" (x) : "memory"); return x; } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE char *LeakStack() { char x[1024]; memset(x, 0, sizeof(x)); return pretend_to_do_something(x); } -template -__attribute__((noinline)) -void RecursiveFunctionWithStackFrame(int depth) { +template +ATTRIBUTE_NOINLINE void RecursiveFunctionWithStackFrame(int depth) { if (depth <= 0) return; char x[kFrameSize]; x[0] = depth; diff --git a/compiler-rt/test/asan/TestCases/ignorelist.cpp b/compiler-rt/test/asan/TestCases/ignorelist.cpp index 348ea5d350bf1..5fe728bfe9c21 100644 --- a/compiler-rt/test/asan/TestCases/ignorelist.cpp +++ b/compiler-rt/test/asan/TestCases/ignorelist.cpp @@ -15,7 +15,10 @@ // badGlobal is accessed improperly, but we ignorelisted it. Align // it to make sure memory past the end of badGlobal will be in // the same page. -__attribute__((aligned(16))) int badGlobal; + +// XFAIL: msvc +#include "defines.h" +ATTRIBUTE_ALIGNED(16) int badGlobal; int readBadGlobal() { return (&badGlobal)[1]; } diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp index d7b5350916719..da457d6737dbd 100644 --- a/compiler-rt/test/asan/TestCases/ill.cpp +++ b/compiler-rt/test/asan/TestCases/ill.cpp @@ -2,12 +2,18 @@ // // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0 // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 -// REQUIRES: x86-target-arch +// REQUIRES: x86-target-arch && (!MSVC || asan-32-bits) #ifdef _WIN32 #include #endif +// note: test is limited to i386 only ("asan-32-bits") when using "real" MSVC +// see the requires clause above +#if defined(_MSC_VER) && !defined(__clang__) +# define __builtin_trap() __asm ud2; +#endif + int main(int argc, char **argv) { #ifdef _WIN32 // Sometimes on Windows this test generates a WER fault dialog. Suppress that. diff --git a/compiler-rt/test/asan/TestCases/initialization-bug.cpp b/compiler-rt/test/asan/TestCases/initialization-bug.cpp index 2775f6ce356dd..1af6e256f0c24 100644 --- a/compiler-rt/test/asan/TestCases/initialization-bug.cpp +++ b/compiler-rt/test/asan/TestCases/initialization-bug.cpp @@ -8,6 +8,7 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=186 // XFAIL: target={{.*windows-msvc.*}} +#include "defines.h" #include // The structure of the test is: @@ -27,7 +28,7 @@ int z = initZ(); // result is undefined behavior, which should be caught by initialization order // checking. extern int y; -int __attribute__((noinline)) initX() { +int ATTRIBUTE_NOINLINE initX() { return y + 1; // CHECK: {{AddressSanitizer: initialization-order-fiasco}} // CHECK: {{READ of size .* at 0x.* thread T0}} diff --git a/compiler-rt/test/asan/TestCases/inline.cpp b/compiler-rt/test/asan/TestCases/inline.cpp index 12bd27e675844..42779a07ae2e6 100644 --- a/compiler-rt/test/asan/TestCases/inline.cpp +++ b/compiler-rt/test/asan/TestCases/inline.cpp @@ -2,10 +2,15 @@ // Test that no_sanitize_address attribute applies even when the function would // be normally inlined. +// +// MSVC doesn't apply __declspec(no_sanitize_address) to inlined functions +// (i.e. it contains this bug) +// XFAIL: msvc +#include "defines.h" #include -__attribute__((no_sanitize_address)) +ATTRIBUTE_NO_SANITIZE_ADDRESS int f(int *p) { return *p; // BOOOM?? Nope! } diff --git a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp index bf51eed41fddf..24b93c56e730c 100644 --- a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp +++ b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp @@ -15,6 +15,7 @@ // https://reviews.llvm.org/D111703 made compiler incompatible with released NDK. // UNSUPPORTED: android && arm-target-arch +#include "defines.h" #include #include #include @@ -28,7 +29,7 @@ namespace { // [[noreturn]] because the scenario we're emulating doesn't always throw. If it // were [[noreturn]], the calling code would emit a call to // __asan_handle_no_return. -void __attribute__((no_sanitize("address"))) +void ATTRIBUTE_NO_SANITIZE_ADDRESS uninstrumented_rethrow_exception(std::exception_ptr const &exc_ptr) { std::rethrow_exception(exc_ptr); } diff --git a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp index 918fa8e82bf74..bdaf3eb3178f2 100644 --- a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp +++ b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp @@ -18,6 +18,10 @@ // it works with the dynamic runtime. // XFAIL: target={{.*netbsd.*}} && !asan-dynamic-runtime +#if defined(_MSC_VER) && !defined(__clang__) +# pragma warning(disable : 4273) +#endif + #include #include #include diff --git a/compiler-rt/test/asan/TestCases/interface_test.cpp b/compiler-rt/test/asan/TestCases/interface_test.cpp index 9419f07e91eae..bc347807bcc3a 100644 --- a/compiler-rt/test/asan/TestCases/interface_test.cpp +++ b/compiler-rt/test/asan/TestCases/interface_test.cpp @@ -1,8 +1,8 @@ // Check that user may include ASan interface header. // RUN: %clang_asan %s -o %t && %run %t // RUN: %clang_asan -x c %s -o %t && %run %t -// RUN: %clang %s -pie -o %t && %run %t -// RUN: %clang -x c %s -pie -o %t && %run %t +// RUN: %clang %s %pie -o %t && %run %t +// RUN: %clang -x c %s %pie -o %t && %run %t #include int main() { diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp index 7b1479e2d05bd..84c264b305692 100644 --- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp +++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s - +// XFAIL: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp index 535833d05c89a..80742cddc0460 100644 --- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp +++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s - +// XFAIL: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp index accd9b7704d51..061a0a7b2b861 100644 --- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp +++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp @@ -4,7 +4,7 @@ // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t g 2>&1 | FileCheck %s -check-prefix=CMP -check-prefix=ALL-ERRORS // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t s 2>&1 | FileCheck %s -check-prefix=SUB -check-prefix=ALL-ERRORS // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t f 2>&1 | FileCheck %s -check-prefix=FREE -check-prefix=ALL-ERRORS - +// XFAIL: msvc #include #include diff --git a/compiler-rt/test/asan/TestCases/large_func_test.cpp b/compiler-rt/test/asan/TestCases/large_func_test.cpp index c64fc7d3c7aa7..1c25d345cb5c4 100644 --- a/compiler-rt/test/asan/TestCases/large_func_test.cpp +++ b/compiler-rt/test/asan/TestCases/large_func_test.cpp @@ -7,8 +7,9 @@ // Issue #108194: Incomplete .debug_line at -O1 and above. // XFAIL: target={{.*sparc.*}} +#include "defines.h" #include -__attribute__((noinline)) +ATTRIBUTE_NOINLINE static void LargeFunction(int *x, int zero) { x[0]++; x[1]++; @@ -29,7 +30,7 @@ static void LargeFunction(int *x, int zero) { // Darwin. // CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-3]] // CHECK-SunOS: {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-4]] - // CHECK-Windows:{{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-5]] + // CHECK-Windows:{{#[0-1] 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-5]] // CHECK-FreeBSD:{{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-6]] // CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cpp}}:[[@LINE-7]] @@ -48,7 +49,7 @@ static void LargeFunction(int *x, int zero) { int main(int argc, char **argv) { int *x = new int[100]; LargeFunction(x, argc - 1); - // CHECK: {{ #1 0x.* in main .*large_func_test.cpp:}}[[@LINE-1]] + // CHECK: {{ #[1-2] 0x.* in main .*large_func_test.cpp:}}[[@LINE-1]] // CHECK: {{0x.* is located 12 bytes after 400-byte region}} // CHECK: {{allocated by thread T0 here:}} // CHECK-Linux: {{ #0 0x.* in operator new}} diff --git a/compiler-rt/test/asan/TestCases/null_deref.cpp b/compiler-rt/test/asan/TestCases/null_deref.cpp index a8947a4378032..3ccb475326369 100644 --- a/compiler-rt/test/asan/TestCases/null_deref.cpp +++ b/compiler-rt/test/asan/TestCases/null_deref.cpp @@ -3,7 +3,9 @@ // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s -__attribute__((noinline)) +#include "defines.h" + +ATTRIBUTE_NOINLINE // FIXME: Static symbols don't show up in PDBs. We can remove this once we start // using DWARF. #ifndef _MSC_VER diff --git a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp index ba49eccf41cab..69409bc6ace6b 100644 --- a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp +++ b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp @@ -1,6 +1,6 @@ // RUN: %clangxx_asan -O0 %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s - +// XFAIL: msvc struct A { int a[8]; }; diff --git a/compiler-rt/test/asan/TestCases/report_error_summary.cpp b/compiler-rt/test/asan/TestCases/report_error_summary.cpp index 9e024e35bed86..e10def7218634 100644 --- a/compiler-rt/test/asan/TestCases/report_error_summary.cpp +++ b/compiler-rt/test/asan/TestCases/report_error_summary.cpp @@ -2,8 +2,10 @@ #include +#if !defined(_MSC_VER) || defined(__clang__) // Required for ld64 macOS 12.0+ __attribute__((weak)) extern "C" void foo() {} +#endif extern "C" void __sanitizer_report_error_summary(const char *summary) { fprintf(stderr, "test_report_error_summary\n"); diff --git a/compiler-rt/test/asan/TestCases/speculative_load.cpp b/compiler-rt/test/asan/TestCases/speculative_load.cpp index fdf70eb39767a..27bd293d28a39 100644 --- a/compiler-rt/test/asan/TestCases/speculative_load.cpp +++ b/compiler-rt/test/asan/TestCases/speculative_load.cpp @@ -4,6 +4,9 @@ // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 +// MSVC doesn't support GCC style inline assembly +// UNSUPPORTED: msvc + #include struct S { diff --git a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp index 0077663d6a176..d33c6246fd4fb 100644 --- a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp +++ b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp @@ -13,6 +13,7 @@ // RUN: not %run %t 63 2>&1 | FileCheck --check-prefix=CHECK-63 %s // RUN: not %run %t 73 2>&1 | FileCheck --check-prefix=CHECK-73 %s // RUN: not %run %t 74 2>&1 | FileCheck --check-prefix=CHECK-74 %s +// XFAIL: msvc #include #include #include diff --git a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp index 3b5d511b26818..1e077513c2168 100644 --- a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp +++ b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp @@ -4,6 +4,9 @@ // RUN: not %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK2 // RUN: not %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK3 +// MSVC doesn't support GCC style inline ASM +// UNSUPPORTED: msvc + #define NOINLINE __attribute__((noinline)) inline void break_optimization(void *arg) { __asm__ __volatile__("" : : "r" (arg) : "memory"); diff --git a/compiler-rt/test/asan/TestCases/strcat-overlap.cpp b/compiler-rt/test/asan/TestCases/strcat-overlap.cpp index 76fd3e1f11d14..af78bc4440549 100644 --- a/compiler-rt/test/asan/TestCases/strcat-overlap.cpp +++ b/compiler-rt/test/asan/TestCases/strcat-overlap.cpp @@ -34,11 +34,12 @@ // UNSUPPORTED: target={{.*windows-msvc.*}} // UNSUPPORTED: android +#include "defines.h" #include // Don't inline function otherwise stacktrace changes. -__attribute__((noinline)) void bad_function() { +ATTRIBUTE_NOINLINE void bad_function() { char buffer[] = "hello\0XXX"; // CHECK: strcat-param-overlap: memory ranges // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap diff --git a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp index efd2e6b7521ef..89ac7a39b33ca 100644 --- a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp +++ b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp @@ -26,13 +26,14 @@ // RUN: echo "interceptor_name:strcpy" > %t.supp // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t -// UNSUPPORTED: android +// UNSUPPORTED: android, MSVC +#include "defines.h" #include // Don't inline function otherwise stacktrace changes. -__attribute__((noinline)) void bad_function() { +ATTRIBUTE_NOINLINE void bad_function() { char buffer[] = "hello"; // CHECK: strcpy-param-overlap: memory ranges // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap diff --git a/compiler-rt/test/asan/TestCases/strncat-overlap.cpp b/compiler-rt/test/asan/TestCases/strncat-overlap.cpp index 3e3f7ee2723f5..e4f2fbca68abf 100644 --- a/compiler-rt/test/asan/TestCases/strncat-overlap.cpp +++ b/compiler-rt/test/asan/TestCases/strncat-overlap.cpp @@ -28,11 +28,12 @@ // UNSUPPORTED: android +#include "defines.h" #include // Don't inline function otherwise stacktrace changes. -__attribute__((noinline)) void bad_function() { +ATTRIBUTE_NOINLINE void bad_function() { char buffer[] = "hello\0XXX"; // CHECK: strncat-param-overlap: memory ranges // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap diff --git a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp index ff84052a94987..f75f8c5eb3ff6 100644 --- a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp +++ b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp @@ -6,14 +6,15 @@ // REQUIRES: compiler-rt-optimized // REQUIRES: stable-runtime -#include +#include "defines.h" #include +#include // We need a way to prevent the optimize from eliminating the // strncpy below (which otherwises writes to dead storage). We // need the read to be out-of-line to prevent memory forwarding // from making the memory dead again. -int sink_memory(int N, char *p) __attribute__((noinline)); +int ATTRIBUTE_NOINLINE sink_memory(int N, char *p); int sink_memory(int N, char *p) { int sum = 0; for (int i = 0; i < N; i++) diff --git a/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp b/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp index 860fc5d304e0e..9334a333c052a 100644 --- a/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp +++ b/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp @@ -28,11 +28,12 @@ // UNSUPPORTED: android +#include "defines.h" #include // Don't inline function otherwise stacktrace changes. -__attribute__((noinline)) void bad_function() { +ATTRIBUTE_NOINLINE void bad_function() { char buffer[] = "hello"; // CHECK: strncpy-param-overlap: memory ranges // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap diff --git a/compiler-rt/test/asan/TestCases/throw_call_test.cpp b/compiler-rt/test/asan/TestCases/throw_call_test.cpp index 20a7c0b766015..06e9422701406 100644 --- a/compiler-rt/test/asan/TestCases/throw_call_test.cpp +++ b/compiler-rt/test/asan/TestCases/throw_call_test.cpp @@ -2,6 +2,10 @@ // http://code.google.com/p/address-sanitizer/issues/detail?id=147 (not fixed). // BROKEN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t +// MSVC doesn't support GCC style inline ASM +// UNSUPPORTED: msvc + +#include "defines.h" #include static volatile int zero = 0; inline void pretend_to_do_something(void *x) { @@ -15,7 +19,7 @@ void ReallyThrow() { throw 42; } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void Throw() { int a, b, c, d, e, f, g, h; pretend_to_do_something(&a); @@ -30,7 +34,7 @@ void Throw() { ReallyThrow(); } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void CheckStack() { int ar[100]; pretend_to_do_something(ar); diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cpp b/compiler-rt/test/asan/TestCases/throw_catch.cpp index 2884e95f8a7e2..71e66e3fc4dd4 100644 --- a/compiler-rt/test/asan/TestCases/throw_catch.cpp +++ b/compiler-rt/test/asan/TestCases/throw_catch.cpp @@ -1,17 +1,18 @@ // RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t +#include "defines.h" #include -#include #include +#include -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void Throw() { int local; fprintf(stderr, "Throw: %p\n", &local); throw 1; } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void ThrowAndCatch() { int local; try { @@ -21,7 +22,7 @@ void ThrowAndCatch() { } } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void TestThrow() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, @@ -33,7 +34,7 @@ void TestThrow() { assert(!__asan_address_is_poisoned(x + 32)); } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void TestThrowInline() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, diff --git a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp index a9069e1ca8d1a..2faf3efe9e6ec 100644 --- a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp +++ b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp @@ -2,8 +2,9 @@ // RUN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t // Investigate why it fails with NDK 21. -// UNSUPPORTED: android +// UNSUPPORTED: android, MSVC +#include "defines.h" #include static volatile int zero = 0; inline void pretend_to_do_something(void *x) { @@ -34,7 +35,7 @@ void Throw() { ReallyThrow(); } -__attribute__((noinline)) +ATTRIBUTE_NOINLINE void CheckStack() { int ar[100]; pretend_to_do_something(ar); diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp index 0eca27181e54f..110d9e5222453 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp @@ -1,12 +1,13 @@ // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s +#include "defines.h" #include int main() { std::function f; { int x = 0; - f = [&x]() __attribute__((noinline)) { + f = [&x]() ATTRIBUTE_NOINLINE { return x; // BOOM // CHECK: ERROR: AddressSanitizer: stack-use-after-scope // We cannot assert the line, after the argument promotion pass this crashes diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp index 42f62c72397ec..c4a188d2c86ce 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp @@ -1,10 +1,11 @@ // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +#include "defines.h" #include struct IntHolder { explicit IntHolder(int *val = 0) : val_(val) { } - __attribute__((noinline)) ~IntHolder() { + ATTRIBUTE_NOINLINE ~IntHolder() { printf("Value: %d\n", *val_); // BOOM // CHECK: ERROR: AddressSanitizer: stack-use-after-scope // CHECK: #0 0x{{.*}} in IntHolder::~IntHolder{{.*}}.cpp:[[@LINE-2]] diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp index 1014ff919b9ef..d0154ef744241 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp @@ -4,9 +4,13 @@ // // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s +// MSVC marks this as xfail because it doesn't generate the metadata to display the "x.i" offset. +// XFAIL: msvc +#include "defines.h" + int *arr; -__attribute__((always_inline)) +ATTRIBUTE_ALWAYS_INLINE void inlined(int arg) { int x[5]; for (int i = 0; i < arg; i++) x[i] = i; diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp index 286b6441a5698..b97fe6730ddc4 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} %s -o %t && not %run %t 2>&1 | FileCheck %s volatile int *p; diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp index 8a8a7b60deb6b..8fedceb6cf330 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp @@ -1,4 +1,5 @@ -// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \ +// RUN: %s -o %t && not %run %t 2>&1 | FileCheck %s #include diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp index 3e199056930cb..7254a785995b7 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp @@ -1,4 +1,5 @@ -// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \ +// RUN: %s -o %t && not %run %t 2>&1 | FileCheck %s int *p[3]; diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp index 29680f37bfa53..ab14e14e485d9 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp @@ -1,14 +1,14 @@ -// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \ +// RUN: %s -o %t && not %run %t 2>&1 | FileCheck %s +#include "defines.h" struct IntHolder { int val; }; const IntHolder *saved; -__attribute__((noinline)) void save(const IntHolder &holder) { - saved = &holder; -} +ATTRIBUTE_NOINLINE void save(const IntHolder &holder) { saved = &holder; } int main(int argc, char *argv[]) { save({argc}); diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp index b98d6f12911a7..ff65f592ee208 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp @@ -1,9 +1,10 @@ -// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \ +// RUN: %s -o %t && not %run %t 2>&1 | FileCheck %s + +#include "defines.h" struct IntHolder { - __attribute__((noinline)) const IntHolder &Self() const { - return *this; - } + ATTRIBUTE_NOINLINE const IntHolder &Self() const { return *this; } int val = 3; }; diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp index 5751a0a09bb4e..3e740edfae250 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp @@ -11,6 +11,7 @@ // RUN: not %run %t 9 2>&1 | FileCheck %s // RUN: not %run %t 10 2>&1 | FileCheck %s +#include "defines.h" #include #include #include @@ -32,7 +33,7 @@ template struct Ptr { T *t; }; -template __attribute__((noinline)) void test() { +template ATTRIBUTE_NOINLINE void test() { Ptr ptr; { T x; diff --git a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp index 613d4bb2763fa..743e2ae71425b 100644 --- a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp +++ b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp @@ -1,20 +1,22 @@ // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t // RUN: not %run %t 2>&1 | FileCheck %s // +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc // This is reduced testcase based on Chromium code. // See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc. -#include +#include "defines.h" #include +#include int a = 7; int b; int c; int *p; -__attribute__((noinline)) void fn3(int *first, int second) { -} +ATTRIBUTE_NOINLINE void fn3(int *first, int second) {} int main() { int d = b && c; diff --git a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp index 00df5d2919c46..5269a35e9796a 100644 --- a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp +++ b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp @@ -2,11 +2,14 @@ // RUN: not %run %t 2>&1 | FileCheck %s // // REQUIRES: stable-runtime +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc +#include "defines.h" #include #include -__attribute__((noinline)) void foo(int index, int len) { +ATTRIBUTE_NOINLINE void foo(int index, int len) { if (index > len) { char str[len]; assert(!(reinterpret_cast(str) & 31L)); diff --git a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp index 370e0dc72c12f..d4cf9513d0fa6 100644 --- a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp +++ b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp @@ -3,6 +3,9 @@ // // REQUIRES: stable-runtime +// MSVC doesn't support VLAs +// UNSUPPORTED: msvc + #include #include diff --git a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp index a7d00ce9b6988..3af4d04a587c2 100644 --- a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp +++ b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp @@ -1,6 +1,10 @@ // Check that ASan correctly detects SEGV on the zero page. // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s +#if defined(_MSC_VER) && !defined(__CLANG__) +# define __has_feature(x) 0 +#endif + #if __has_feature(ptrauth_calls) # include #endif diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py index c57f5ca0fa652..2da511103da7c 100644 --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -183,6 +183,7 @@ def build_invocation(compile_flags, with_lto=False): config.substitutions.append(("%MD", "-MD")) config.substitutions.append(("%MT", "-MT")) config.substitutions.append(("%Gw", "-Gw")) + config.substitutions.append(("%Oy-", "-Oy-")) base_lib = os.path.join( config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix @@ -220,6 +221,7 @@ def build_invocation(compile_flags, with_lto=False): config.substitutions.append(("%MD", "")) config.substitutions.append(("%MT", "")) config.substitutions.append(("%Gw", "-fdata-sections")) + config.substitutions.append(("%Oy-", "-fno-omit-frame-pointer")) # FIXME: De-hardcode this path. asan_source_dir = os.path.join( diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c index ff767d754eb97..e4953bf51b037 100644 --- a/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c +++ b/compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c @@ -14,8 +14,19 @@ int test__aeabi_idivmod(si_int a, si_int b, { si_int rem; du_int ret = __aeabi_idivmod(a, b); + // __aeabi_idivmod actually returns a struct { quotient; remainder; } using + // value_in_regs calling convention. Due to the ABI rules, struct fields + // come in the same order regardless of endianness. However since the + // result is received here as a 64-bit integer, in which endianness does + // matter, the position of each component (quotient and remainder) varies + // depending on endianness. +# if _YUGA_BIG_ENDIAN + rem = ret & 0xFFFFFFFF; + si_int result = ret >> 32; +# else rem = ret >> 32; si_int result = ret & 0xFFFFFFFF; +# endif if (result != expected_result) { printf("error in __aeabi_idivmod: %d / %d = %d, expected %d\n", a, b, result, expected_result); diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c index de5a43d5b8143..a507267c44602 100644 --- a/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c +++ b/compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c @@ -13,8 +13,19 @@ int test__aeabi_uidivmod(su_int a, su_int b, su_int expected_result, su_int expected_rem) { du_int ret = __aeabi_uidivmod(a, b); + // __aeabi_uidivmod actually returns a struct { quotient; remainder; } + // using value_in_regs calling convention. Due to the ABI rules, struct + // fields come in the same order regardless of endianness. However since + // the result is received here as a 64-bit integer, in which endianness + // does matter, the position of each component (quotient and remainder) + // varies depending on endianness. +# if _YUGA_BIG_ENDIAN + su_int rem = ret & 0xFFFFFFFF; + si_int result = ret >> 32; +# else su_int rem = ret >> 32; si_int result = ret & 0xFFFFFFFF; +# endif if (result != expected_result) { printf("error in __aeabi_uidivmod: %u / %u = %u, expected %u\n", diff --git a/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c b/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c index 2ff65a8b9ec3f..02cfa2f38713b 100644 --- a/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c +++ b/compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c @@ -12,20 +12,37 @@ COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b); int test_aeabi_uldivmod(du_int a, du_int b, du_int expected_q, du_int expected_r) { du_int q, r; + // __aeabi_uldivmod returns a struct { quotient; remainder; } using + // value_in_regs calling convention. Each field is a 64-bit integer, so the + // quotient resides in r0 and r1, while the remainder in r2 and r3. The + // byte order however depends on the endianness. __asm__( +# if _YUGA_BIG_ENDIAN + "movs r1, %Q[a] \n" + "movs r0, %R[a] \n" + "movs r3, %Q[b] \n" + "movs r2, %R[b] \n" +# else "movs r0, %Q[a] \n" "movs r1, %R[a] \n" "movs r2, %Q[b] \n" "movs r3, %R[b] \n" +# endif "bl __aeabi_uldivmod \n" +# if _YUGA_BIG_ENDIAN + "movs %Q[q], r1\n" + "movs %R[q], r0\n" + "movs %Q[r], r3\n" + "movs %R[r], r2\n" +# else "movs %Q[q], r0\n" "movs %R[q], r1\n" "movs %Q[r], r2\n" "movs %R[r], r3\n" - : [q] "=r" (q), [r] "=r"(r) +# endif + : [q] "=r"(q), [r] "=r"(r) : [a] "r"(a), [b] "r"(b) - : "lr", "r0", "r1", "r2", "r3" - ); + : "lr", "r0", "r1", "r2", "r3"); if (q != expected_q || r != expected_r) printf("error in aeabi_uldivmod: %llX / %llX = %llX, R = %llX, expected %llX, %llX\n", a, b, q, r, expected_q, expected_r); diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index 2e27bc2279ac4..c012b884ae3be 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -79,6 +79,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) message(FATAL_ERROR "flang isn't supported on 32 bit CPUs") endif() +set(MLIR_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../mlir" CACHE PATH "Path to MLIR source tree") + if (FLANG_STANDALONE_BUILD) set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -240,13 +242,14 @@ else() set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() - set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir ) # --src-root - set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir + set(MLIR_INCLUDE_DIRS ${MLIR_MAIN_SRC_DIR}/include ) # --includedir set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) - include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) + include_directories(SYSTEM ${MLIR_INCLUDE_DIRS}) include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) endif() +option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ON) + set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") mark_as_advanced(FLANG_TOOLS_INSTALL_DIR) @@ -299,7 +302,7 @@ set(FLANG_DEFAULT_LINKER "" CACHE STRING "Default linker to use (linker name or absolute path, empty for platform default)") set(FLANG_DEFAULT_RTLIB "" CACHE STRING - "Default Fortran runtime library to use (\"libFortranRuntime\"), leave empty for platform default.") + "Default Fortran runtime library to use (\"libflang_rt.runtime\"), leave empty for platform default.") if (NOT(FLANG_DEFAULT_RTLIB STREQUAL "")) message(WARNING "Resetting Flang's default runtime library to use platform default.") @@ -487,7 +490,9 @@ if (FLANG_BUILD_TOOLS) add_subdirectory(tools) endif() -add_subdirectory(runtime) +if (FLANG_INCLUDE_RUNTIME) + add_subdirectory(runtime) +endif () if (LLVM_INCLUDE_EXAMPLES) add_subdirectory(examples) diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake index 1f178772067ed..c9f65eb73fef0 100644 --- a/flang/cmake/modules/AddFlang.cmake +++ b/flang/cmake/modules/AddFlang.cmake @@ -57,7 +57,7 @@ function(add_flang_library name) set(LIBTYPE SHARED) elseif(ARG_STATIC) # If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC. - # This is required behavior for libFortranFloat128Math. + # This is required behavior for libflang_rt.quadmath. set(LIBTYPE STATIC) else() # Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account. diff --git a/flang/docs/Directives.md b/flang/docs/Directives.md index f356f762b13a2..c6c2e29a420ea 100644 --- a/flang/docs/Directives.md +++ b/flang/docs/Directives.md @@ -39,15 +39,22 @@ A list of non-standard directives supported by Flang * `!dir$ vector always` forces vectorization on the following loop regardless of cost model decisions. The loop must still be vectorizable. [This directive currently only works on plain do loops without labels]. +* `!dir$ unroll [n]` specifies that the compiler ought to unroll the immediately + following loop `n` times. When `n` is `0` or `1`, the loop should not be unrolled + at all. When `n` is `2` or greater, the loop should be unrolled exactly `n` + times if possible. When `n` is omitted, the compiler should attempt to fully + unroll the loop. Some compilers accept an optional `=` before the `n` when `n` + is present in the directive. Flang does not. # Directive Details ## Introduction Directives are commonly used in Fortran programs to specify additional actions to be performed by the compiler. The directives are always specified with the -`!dir$` or `cdir$` prefix. +`!dir$` or `cdir$` prefix. ## Loop Directives + Some directives are associated with the following construct, for example loop directives. Directives on loops are used to specify additional transformation to be performed by the compiler like enabling vectorisation, unrolling, interchange diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md index 5f960a954783d..97744f0bee069 100644 --- a/flang/docs/FlangDriver.md +++ b/flang/docs/FlangDriver.md @@ -175,18 +175,18 @@ like this: ``` $ flang -v -o example example.o -"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...] +"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...] ``` The automatically added libraries are: -* `FortranRuntime`: Provides most of the Flang runtime library. +* `flang_rt.runtime`: Provides most of the Flang runtime library. If the code is C/C++ based and invokes Fortran routines, one can either use Clang or Flang as the linker driver. If Clang is used, it will automatically all required runtime libraries needed by C++ (e.g., for STL) to the linker invocation. In this case, one has to explicitly provide the Fortran runtime library -`FortranRuntime`. An alternative is to use Flang to link. +`flang_rt.runtime`. An alternative is to use Flang to link. In this case, it may be required to explicitly supply C++ runtime libraries. On Darwin, the logical root where the system libraries are located (sysroot) diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md index 1c85a6754b155..e422a31a0b402 100644 --- a/flang/docs/GettingStarted.md +++ b/flang/docs/GettingStarted.md @@ -216,7 +216,7 @@ cmake \ -DCMAKE_CUDA_COMPILER=clang \ -DCMAKE_CUDA_HOST_COMPILER=clang++ \ ../runtime/ -make -j FortranRuntime +make -j flang-rt ``` Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support) @@ -239,7 +239,7 @@ cmake \ -DCMAKE_CUDA_HOST_COMPILER=clang++ \ ../runtime/ -make -j FortranRuntime +make -j flang-rt ``` Note that `nvcc` might limit support to certain @@ -294,7 +294,7 @@ cmake \ -DFLANG_OMP_DEVICE_ARCHITECTURES="all" \ ../runtime/ -make -j FortranRuntime +make -j flang-rt ``` The result of the build is a "device-only" library, i.e. the host @@ -309,7 +309,7 @@ The same set of CMake variables works for Flang in-tree build. One may provide optional CMake variables to customize the build. Available options: * `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of - `FortranFloat128Math` library that provides `REAL(16)` math APIs + `flang_rt.quadmath` library that provides `REAL(16)` math APIs for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file `quadmath.h` must be available to the build compiler. [More details](Real16MathSupport.md). diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md index 52d00ae4daef8..008c57937e23b 100644 --- a/flang/docs/OpenACC-descriptor-management.md +++ b/flang/docs/OpenACC-descriptor-management.md @@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2): All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping. -The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `FortranRuntime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`). +The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt.runtime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`). ## TODOs: diff --git a/flang/docs/Real16MathSupport.md b/flang/docs/Real16MathSupport.md index 21482c7be21af..93492c8b767c3 100644 --- a/flang/docs/Real16MathSupport.md +++ b/flang/docs/Real16MathSupport.md @@ -12,9 +12,9 @@ To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies on third-party libraries providing the implementation. `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used -to build `FortranFloat128Math` library that has unresolved references +to build `libflang_rt.quadmath` library that has unresolved references to GCC `libquadmath` library. A Flang driver built with this option -will automatically link `FortranFloat128Math` and `libquadmath` libraries +will automatically link `libflang_rt.quadmath` and `libquadmath` libraries to any Fortran program. This implies that `libquadmath` library has to be available in the standard library paths, so that linker can find it. The `libquadmath` library installation into Flang project diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md index f0c956281915f..387d4b2e62e0f 100644 --- a/flang/docs/ReleaseNotes.md +++ b/flang/docs/ReleaseNotes.md @@ -36,6 +36,13 @@ page](https://llvm.org/releases/). ## Build System Changes + * The FortranRuntime library has been renamed to `flang_rt.runtime`. + + * The FortranFloat128Math library has been renamed to `flang_rt.quadmath`. + + * The CufRuntime_cuda_${version} library has been renamed to + `flang_rt.cuda_${version}`. + ## New Issues Found diff --git a/flang/examples/CMakeLists.txt b/flang/examples/CMakeLists.txt index 8cc66ddbbbb0e..23c6e790791fb 100644 --- a/flang/examples/CMakeLists.txt +++ b/flang/examples/CMakeLists.txt @@ -1,4 +1,6 @@ -add_subdirectory(ExternalHelloWorld) +if (FLANG_INCLUDE_RUNTIME) + add_subdirectory(ExternalHelloWorld) +endif () add_subdirectory(PrintFlangFunctionNames) add_subdirectory(FlangOmpReport) add_subdirectory(FeatureList) diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt index 042d4b6238ba4..b61948718a5e3 100644 --- a/flang/examples/ExternalHelloWorld/CMakeLists.txt +++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt @@ -5,5 +5,5 @@ add_llvm_example(external-hello-world target_link_libraries(external-hello-world PRIVATE - FortranRuntime + flang_rt.runtime ) diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h index c8acdac6cafbe..93eca78424775 100644 --- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h +++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h @@ -57,7 +57,13 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener { explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap, mlir::SymbolTable *symbolTable = nullptr) : OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)}, - symbolTable{symbolTable} {} + symbolTable{symbolTable} { + auto fmi = mlir::dyn_cast(*op); + if (fmi) { + // Set the builder with FastMathFlags attached to the operation. + setFastMathFlags(fmi.getFastMathFlagsAttr().getValue()); + } + } explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap, mlir::SymbolTable *symbolTable = nullptr) : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)}, diff --git a/flang/include/flang/Optimizer/Dialect/CMakeLists.txt b/flang/include/flang/Optimizer/Dialect/CMakeLists.txt index 10ab213b30b02..73f388cbab6c9 100644 --- a/flang/include/flang/Optimizer/Dialect/CMakeLists.txt +++ b/flang/include/flang/Optimizer/Dialect/CMakeLists.txt @@ -37,7 +37,7 @@ set_target_properties(flang-doc PROPERTIES FOLDER "Flang/Docs") set(dialect_doc_filename "FIRLangRef") set(LLVM_TARGET_DEFINITIONS FIROps.td) -tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc "-I${MLIR_INCLUDE_DIR}") +tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc) set(GEN_DOC_FILE ${FLANG_BINARY_DIR}/docs/Dialect/${dialect_doc_filename}.md) add_custom_command( OUTPUT ${GEN_DOC_FILE} diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index a31629b17cf29..36e58e456dea3 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -63,6 +63,7 @@ #include "flang/Semantics/tools.h" #include "flang/Support/Version.h" #include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h" +#include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Parser/Parser.h" @@ -2170,11 +2171,38 @@ class FirConverter : public Fortran::lower::AbstractConverter { return builder->createIntegerConstant(loc, controlType, 1); // step } + // For unroll directives without a value, force full unrolling. + // For unroll directives with a value, if the value is greater than 1, + // force unrolling with the given factor. Otherwise, disable unrolling. + mlir::LLVM::LoopUnrollAttr + genLoopUnrollAttr(std::optional directiveArg) { + mlir::BoolAttr falseAttr = + mlir::BoolAttr::get(builder->getContext(), false); + mlir::BoolAttr trueAttr = mlir::BoolAttr::get(builder->getContext(), true); + mlir::IntegerAttr countAttr; + mlir::BoolAttr fullUnrollAttr; + bool shouldUnroll = true; + if (directiveArg.has_value()) { + auto unrollingFactor = directiveArg.value(); + if (unrollingFactor == 0 || unrollingFactor == 1) { + shouldUnroll = false; + } else { + countAttr = + builder->getIntegerAttr(builder->getI64Type(), unrollingFactor); + } + } else { + fullUnrollAttr = trueAttr; + } + + mlir::BoolAttr disableAttr = shouldUnroll ? falseAttr : trueAttr; + return mlir::LLVM::LoopUnrollAttr::get( + builder->getContext(), /*disable=*/disableAttr, /*count=*/countAttr, {}, + /*full=*/fullUnrollAttr, {}, {}, {}); + } + void addLoopAnnotationAttr( IncrementLoopInfo &info, llvm::SmallVectorImpl &dirs) { - mlir::BoolAttr f = mlir::BoolAttr::get(builder->getContext(), false); - mlir::BoolAttr t = mlir::BoolAttr::get(builder->getContext(), true); mlir::LLVM::LoopVectorizeAttr va; mlir::LLVM::LoopUnrollAttr ua; bool has_attrs = false; @@ -2182,20 +2210,15 @@ class FirConverter : public Fortran::lower::AbstractConverter { Fortran::common::visit( Fortran::common::visitors{ [&](const Fortran::parser::CompilerDirective::VectorAlways &) { + mlir::BoolAttr falseAttr = + mlir::BoolAttr::get(builder->getContext(), false); va = mlir::LLVM::LoopVectorizeAttr::get(builder->getContext(), - /*disable=*/f, {}, {}, - {}, {}, {}, {}); + /*disable=*/falseAttr, + {}, {}, {}, {}, {}, {}); has_attrs = true; }, [&](const Fortran::parser::CompilerDirective::Unroll &u) { - mlir::IntegerAttr countAttr; - if (u.v.has_value()) { - countAttr = builder->getIntegerAttr(builder->getI64Type(), - u.v.value()); - } - ua = mlir::LLVM::LoopUnrollAttr::get( - builder->getContext(), /*disable=*/f, /*count*/ countAttr, - {}, /*full*/ u.v.has_value() ? f : t, {}, {}, {}); + ua = genLoopUnrollAttr(u.v); has_attrs = true; }, [&](const auto &) {}}, diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index ac1a1c00eb145..a11a2c824bf9e 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -2281,8 +2281,8 @@ static Op createComputeOp( mlir::Value selfCond; llvm::SmallVector waitOperands, attachEntryOperands, copyEntryOperands, copyinEntryOperands, copyoutEntryOperands, - createEntryOperands, dataClauseOperands, numGangs, numWorkers, - vectorLength, async; + createEntryOperands, nocreateEntryOperands, presentEntryOperands, + dataClauseOperands, numGangs, numWorkers, vectorLength, async; llvm::SmallVector numGangsDeviceTypes, numWorkersDeviceTypes, vectorLengthDeviceTypes, asyncDeviceTypes, asyncOnlyDeviceTypes, waitOperandsDeviceTypes, waitOnlyDeviceTypes; @@ -2457,19 +2457,25 @@ static Op createComputeOp( } else if (const auto *noCreateClause = std::get_if( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations( noCreateClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_no_create, /*structured=*/true, /*implicit=*/false, async, asyncDeviceTypes, asyncOnlyDeviceTypes); + nocreateEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *presentClause = std::get_if( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations( presentClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_present, /*structured=*/true, /*implicit=*/false, async, asyncDeviceTypes, asyncOnlyDeviceTypes); + presentEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *devicePtrClause = std::get_if( &clause.u)) { @@ -2634,6 +2640,10 @@ static Op createComputeOp( builder, attachEntryOperands, /*structured=*/true); genDataExitOperations( builder, createEntryOperands, /*structured=*/true); + genDataExitOperations( + builder, nocreateEntryOperands, /*structured=*/true); + genDataExitOperations( + builder, presentEntryOperands, /*structured=*/true); builder.restoreInsertionPoint(insPt); return computeOp; @@ -2648,7 +2658,8 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, mlir::Value ifCond; llvm::SmallVector attachEntryOperands, createEntryOperands, copyEntryOperands, copyinEntryOperands, copyoutEntryOperands, - dataClauseOperands, waitOperands, async; + nocreateEntryOperands, presentEntryOperands, dataClauseOperands, + waitOperands, async; llvm::SmallVector asyncDeviceTypes, asyncOnlyDeviceTypes, waitOperandsDeviceTypes, waitOnlyDeviceTypes; llvm::SmallVector waitOperandsSegments; @@ -2745,19 +2756,25 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, } else if (const auto *noCreateClause = std::get_if( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations( noCreateClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_no_create, /*structured=*/true, /*implicit=*/false, async, asyncDeviceTypes, asyncOnlyDeviceTypes); + nocreateEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *presentClause = std::get_if( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDataOperandOperations( presentClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_present, /*structured=*/true, /*implicit=*/false, async, asyncDeviceTypes, asyncOnlyDeviceTypes); + presentEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *deviceptrClause = std::get_if( &clause.u)) { @@ -2837,6 +2854,10 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, builder, attachEntryOperands, /*structured=*/true); genDataExitOperations( builder, createEntryOperands, /*structured=*/true); + genDataExitOperations( + builder, nocreateEntryOperands, /*structured=*/true); + genDataExitOperations( + builder, presentEntryOperands, /*structured=*/true); builder.restoreInsertionPoint(insPt); } @@ -3814,7 +3835,7 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { llvm::SmallVector dataClauseOperands, copyEntryOperands, copyinEntryOperands, createEntryOperands, copyoutEntryOperands, - deviceResidentEntryOperands; + presentEntryOperands, deviceResidentEntryOperands; Fortran::lower::StatementContext stmtCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); @@ -3845,11 +3866,14 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, } else if (const auto *presentClause = std::get_if( &clause.u)) { + auto crtDataStart = dataClauseOperands.size(); genDeclareDataOperandOperations( + mlir::acc::DeleteOp>( presentClause->v, converter, semanticsContext, stmtCtx, dataClauseOperands, mlir::acc::DataClause::acc_present, /*structured=*/true, /*implicit=*/false); + presentEntryOperands.append(dataClauseOperands.begin() + crtDataStart, + dataClauseOperands.end()); } else if (const auto *copyinClause = std::get_if(&clause.u)) { auto crtDataStart = dataClauseOperands.size(); @@ -3928,14 +3952,15 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, openAccCtx.attachCleanup([&builder, loc, createEntryOperands, copyEntryOperands, copyinEntryOperands, - copyoutEntryOperands, deviceResidentEntryOperands, - declareToken]() { + copyoutEntryOperands, presentEntryOperands, + deviceResidentEntryOperands, declareToken]() { llvm::SmallVector operands; operands.append(createEntryOperands); operands.append(deviceResidentEntryOperands); operands.append(copyEntryOperands); operands.append(copyinEntryOperands); operands.append(copyoutEntryOperands); + operands.append(presentEntryOperands); mlir::func::FuncOp funcOp = builder.getFunction(); auto ops = funcOp.getOps(); @@ -3957,6 +3982,8 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, builder, copyinEntryOperands, /*structured=*/true); genDataExitOperations( builder, copyoutEntryOperands, /*structured=*/true); + genDataExitOperations( + builder, presentEntryOperands, /*structured=*/true); }); } diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp index 9b684520ec078..9a80e36efe837 100644 --- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp +++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp @@ -809,8 +809,8 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc, // Generate a call to the Fortran runtime library providing // support for 128-bit float math. // On 'HAS_LDBL128' targets the implementation -// is provided by FortranRuntime, otherwise, it is done via -// FortranFloat128Math library. In the latter case the compiler +// is provided by flang_rt, otherwise, it is done via the +// libflang_rt.quadmath library. In the latter case the compiler // has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee // proper linking actions in the driver. static mlir::Value genLibF128Call(fir::FirOpBuilder &builder, diff --git a/flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp b/flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp index 0cfefc2d23ecb..3d506abbaa454 100644 --- a/flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp +++ b/flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp @@ -930,9 +930,7 @@ class ReductionConversion : public mlir::OpRewritePattern { llvm_unreachable("unsupported type"); }; - fir::KindMapping kindMap = - fir::getKindMapping(op->template getParentOfType()); - fir::FirOpBuilder builder{op, kindMap}; + fir::FirOpBuilder builder{rewriter, op.getOperation()}; mlir::Value init; GenBodyFn genBodyFn; diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt index 3587ec078c47f..7cc720e2df9af 100644 --- a/flang/runtime/CMakeLists.txt +++ b/flang/runtime/CMakeLists.txt @@ -241,13 +241,13 @@ set(supported_files utf.cpp ) -enable_cuda_compilation(FortranRuntime "${supported_files}") +enable_cuda_compilation(flang_rt "${supported_files}") enable_omp_offload_compilation("${supported_files}") -if (NOT TARGET FortranFloat128Math) - # If FortranFloat128Math is not defined, then we are not building - # standalone FortranFloat128Math library. Instead, include - # the relevant sources into FortranRuntime itself. +if (NOT TARGET flang_rt.quadmath) + # If flang_rt.quadmath is not defined, then we are not building + # standalone flang_rt.quadmath library. Instead, include + # the relevant sources into flang_rt.runtime itself. # The information is provided via FortranFloat128MathILib # interface library. get_target_property(f128_sources @@ -275,7 +275,7 @@ if (NOT TARGET FortranFloat128Math) endif() if (NOT DEFINED MSVC) - add_flang_library(FortranRuntime + add_flang_library(flang_rt.runtime ${sources} LINK_LIBS ${linked_libraries} @@ -283,33 +283,36 @@ if (NOT DEFINED MSVC) INSTALL_WITH_TOOLCHAIN ) else() - add_flang_library(FortranRuntime + add_flang_library(flang_rt.runtime ${sources} LINK_LIBS ${linked_libraries} ) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) - add_flang_library(FortranRuntime.static ${sources} + add_flang_library(flang_rt.runtime.static ${sources} INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries") + set_target_properties(flang_rt.runtime.static PROPERTIES FOLDER "Flang/Runtime Libraries") set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) - add_flang_library(FortranRuntime.dynamic ${sources} + add_flang_library(flang_rt.runtime.dynamic ${sources} INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries") + set_target_properties(flang_rt.runtime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries") set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug) - add_flang_library(FortranRuntime.static_dbg ${sources} + add_flang_library(flang_rt.runtime.static_dbg ${sources} INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") + set_target_properties(flang_rt.runtime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL) - add_flang_library(FortranRuntime.dynamic_dbg ${sources} + add_flang_library(flang_rt.runtime.dynamic_dbg ${sources} INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") - add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic - FortranRuntime.static_dbg FortranRuntime.dynamic_dbg) + set_target_properties(flang_rt.runtime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") + add_dependencies(flang_rt.runtime + flang_rt.runtime.static + flang_rt.runtime.dynamic + flang_rt.runtime.static_dbg + flang_rt.runtime.dynamic_dbg) endif() -set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries") +set_target_properties(flang_rt.runtime PROPERTIES FOLDER "Flang/Runtime Libraries") -# If FortranRuntime is part of a Flang build (and not a separate build) then +# If flang_rt is part of a Flang build (and not a separate build) then # add dependency to make sure that Fortran runtime library is being built after # we have the Flang compiler available. This also includes the MODULE files # that compile when the 'flang' target is built. @@ -317,9 +320,21 @@ set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries" # TODO: This is a workaround and should be updated when runtime build procedure # is changed to a regular runtime build. See discussion in PR #95388. if (TARGET flang AND TARGET module_files) - add_dependencies(FortranRuntime flang module_files) + add_dependencies(flang_rt.runtime flang module_files) endif() if (FLANG_CUF_RUNTIME) add_subdirectory(CUDA) endif() + +# Compatibility targets. +add_custom_target(flang-rt) +add_dependencies(flang-rt flang_rt.runtime) +if (TARGET flang_rt.quadmath) + add_dependencies(flang-rt flang_rt.quadmath) +endif () +if (TARGET flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}) + add_dependencies(flang-rt flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}) +endif () +add_custom_target(FortranRuntime) +add_dependencies(FortranRuntime flang_rt.runtime) diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt index bfbae58086c1f..1fd3bf22a83cf 100644 --- a/flang/runtime/CUDA/CMakeLists.txt +++ b/flang/runtime/CUDA/CMakeLists.txt @@ -8,10 +8,10 @@ include_directories(${CUDAToolkit_INCLUDE_DIRS}) -# libCufRuntime depends on a certain version of CUDA. To be able to have +# libflang_rt.cuda depends on a certain version of CUDA. To be able to have # multiple build of this library with different CUDA version, the version is # added to the library name. -set(CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}) +set(CUFRT_LIBNAME flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}) add_flang_library(${CUFRT_LIBNAME} allocator.cpp @@ -33,6 +33,6 @@ endif() target_link_libraries(${CUFRT_LIBNAME} PRIVATE - FortranRuntime + flang_rt.runtime ${CUDA_RT_TARGET} ) diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt index 703f85fcaf8da..3c382d16a21cd 100644 --- a/flang/runtime/Float128Math/CMakeLists.txt +++ b/flang/runtime/Float128Math/CMakeLists.txt @@ -12,7 +12,7 @@ # It is distributed as a static library only. # Fortran programs/libraries that end up linking any of the provided # will have a dependency on the third-party library that is being -# used for building this FortranFloat128Math library. +# used for building this flang_rt.quadmath library. include(CheckLibraryExists) @@ -93,20 +93,20 @@ if (FLANG_RUNTIME_F128_MATH_LIB) ) endif() - add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN + add_flang_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN ${sources}) if (DEFINED MSVC) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) - add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN + add_flang_library(flang_rt.quadmath.static STATIC INSTALL_WITH_TOOLCHAIN ${sources} ) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug) - add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN + add_flang_library(flang_rt.quadmath.static_dbg STATIC INSTALL_WITH_TOOLCHAIN ${sources} ) - add_dependencies(FortranFloat128Math FortranFloat128Math.static - FortranFloat128Math.static_dbg + add_dependencies(flang_rt.quadmath flang_rt.quadmath.static + flang_rt.quadmath.static_dbg ) endif() elseif (HAVE_LDBL_MANT_DIG_113) @@ -118,7 +118,7 @@ elseif (HAVE_LDBL_MANT_DIG_113) ) target_sources(FortranFloat128MathILib INTERFACE ${sources}) else() - message(FATAL_ERROR "FortranRuntime cannot build without libm") + message(FATAL_ERROR "flang_rt.quadmath cannot build without libm") endif() else() # We can use '__float128' version from libc, if it has them. diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp index e6f6e81c7b50c..942604a92aaad 100644 --- a/flang/runtime/time-intrinsic.cpp +++ b/flang/runtime/time-intrinsic.cpp @@ -62,7 +62,7 @@ template double GetCpuTime(fallback_implementation) { #if defined __MINGW32__ // clock_gettime is implemented in the pthread library for MinGW. -// Using it here would mean that all programs that link libFortranRuntime are +// Using it here would mean that all programs that link libflang_rt are // required to also link to pthread. Instead, don't use the function. #undef CLOCKID_CPU_TIME #undef CLOCKID_ELAPSED_TIME diff --git a/flang/runtime/tools.h b/flang/runtime/tools.h index facbd23161057..75544098d47ab 100644 --- a/flang/runtime/tools.h +++ b/flang/runtime/tools.h @@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind( if constexpr (HasCppTypeFor) { // If FUNC implemenation relies on FP math functions, // then we should not be here. The compiler should have - // generated a call to an entry in FortranFloat128Math + // generated a call to an entry in flang_rt.quadmath // library. if constexpr (!NEEDSMATH) { return FUNC<16>{}(std::forward(x)...); diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt index cab214c2ef4c8..3fac8717e9bd9 100644 --- a/flang/test/CMakeLists.txt +++ b/flang/test/CMakeLists.txt @@ -71,9 +71,13 @@ set(FLANG_TEST_DEPENDS llvm-objdump llvm-readobj split-file - FortranRuntime FortranDecimal ) + +if (FLANG_INCLUDE_RUNTIME) + list(APPEND FLANG_TEST_DEPENDS flang_rt.runtime) +endif () + if (LLVM_ENABLE_PLUGINS AND NOT WIN32) list(APPEND FLANG_TEST_DEPENDS Bye) endif() @@ -120,3 +124,9 @@ if (DEFINED FLANG_TEST_TARGET_TRIPLE) "to use FLANG_TEST_TARGET_TRIPLE.") endif() endif() + +# Compatibility targets. +if (FLANG_INCLUDE_RUNTIME) + add_custom_target(check-flang-rt) + add_dependencies(check-flang-rt check-flang) +endif () diff --git a/flang/test/Driver/ctofortran.f90 b/flang/test/Driver/ctofortran.f90 index 78eac32133b18..10c7adaccc958 100644 --- a/flang/test/Driver/ctofortran.f90 +++ b/flang/test/Driver/ctofortran.f90 @@ -1,4 +1,5 @@ ! UNSUPPORTED: system-windows +! REQUIRES: flang-rt ! RUN: split-file %s %t ! RUN: chmod +x %t/runtest.sh ! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s diff --git a/flang/test/Driver/exec.f90 b/flang/test/Driver/exec.f90 index fd174005ddf62..9ca91ee24011c 100644 --- a/flang/test/Driver/exec.f90 +++ b/flang/test/Driver/exec.f90 @@ -1,4 +1,5 @@ ! UNSUPPORTED: system-windows +! REQUIRES: flang-rt ! Verify that flang can correctly build executables. ! RUN: %flang %s -o %t diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90 index 5a073b0c51712..e195bdde6d2c9 100644 --- a/flang/test/Driver/gcc-toolchain-install-dir.f90 +++ b/flang/test/Driver/gcc-toolchain-install-dir.f90 @@ -1,5 +1,5 @@ !! Test that --gcc-toolchain and --gcc-install-dir options are working as expected. -!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libFortranRuntime, etc. are not supposed to be affected. +!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt.runtime, etc. are not supposed to be affected. !! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line. ! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386 diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 16bd4c3ba8371..4e62a8c32d360 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -29,37 +29,37 @@ ! executable and may find the GNU linker from MinGW or Cygwin. ! UNIX-LABEL: "{{.*}}ld{{(\.exe)?}}" ! UNIX-SAME: "[[object_file]]" -! UNIX-F128NONE-NOT: FortranFloat128Math -! SOLARIS-F128NONE-NOT: FortranFloat128Math -! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" -! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record" -! UNIX-SAME: "-lFortranRuntime" "-lm" +! UNIX-F128NONE-NOT: lang_rt.quadmath +! SOLARIS-F128NONE-NOT: flang_rt.quadmath +! UNIX-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed" +! SOLARIS-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "-z" "ignore" "-lquadmath" "-z" "record" +! UNIX-SAME: "-lflang_rt.runtime" "-lm" ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a" ! BSD-LABEL: "{{.*}}ld{{(\.exe)?}}" ! BSD-SAME: "[[object_file]]" -! BSD-F128NONE-NOT: FortranFloat128Math -! BSD-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" -! BSD-SAME: -lFortranRuntime +! BSD-F128NONE-NOT: flang_rt.quadmath +! BSD-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed" +! BSD-SAME: -lflang_rt.runtime ! BSD-SAME: -lexecinfo ! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}" ! DARWIN-SAME: "[[object_file]]" -! DARWIN-F128NONE-NOT: FortranFloat128Math -! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" -! DARWIN-SAME: -lFortranRuntime +! DARWIN-F128NONE-NOT: libflang_rt.quadmath +! DARWIN-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed" +! DARWIN-SAME: -lflang_rt.runtime ! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}" ! HAIKU-SAME: "[[object_file]]" -! HAIKU-F128NONE-NOT: FortranFloat128Math -! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" -! HAIKU-SAME: "-lFortranRuntime" +! HAIKU-F128NONE-NOT: libflang_rt.quadmath +! HAIKU-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed" +! HAIKU-SAME: "-lflang_rt.runtime" ! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}" ! MINGW-SAME: "[[object_file]]" -! MINGW-F128NONE-NOT: FortranFloat128Math -! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed" -! MINGW-SAME: -lFortranRuntime +! MINGW-F128NONE-NOT: libflang_rt.quadmath +! MINGW-F128LIBQUADMATH-SAME: "-lflang_rt.quadmath" "--as-needed" "-lquadmath" "--no-as-needed" +! MINGW-SAME: -lflang_rt.runtime ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and ! any .exe suffix that is added when resolving to the full path of diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90 index befe61fdadcd1..641c73912c4d1 100644 --- a/flang/test/Driver/msvc-dependent-lib-flags.f90 +++ b/flang/test/Driver/msvc-dependent-lib-flags.f90 @@ -7,21 +7,21 @@ ! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib ! MSVC-SAME: -D_MT ! MSVC-SAME: --dependent-lib=libcmt -! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib +! MSVC-SAME: --dependent-lib=flang_rt.runtime.static.lib ! MSVC-DEBUG: -fc1 ! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib ! MSVC-DEBUG-SAME: -D_MT ! MSVC-DEBUG-SAME: -D_DEBUG ! MSVC-DEBUG-SAME: --dependent-lib=libcmtd -! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib +! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.runtime.static_dbg.lib ! MSVC-DLL: -fc1 ! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib ! MSVC-DLL-SAME: -D_MT ! MSVC-DLL-SAME: -D_DLL ! MSVC-DLL-SAME: --dependent-lib=msvcrt -! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib +! MSVC-DLL-SAME: --dependent-lib=flang_rt.runtime.dynamic.lib ! MSVC-DLL-DEBUG: -fc1 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib @@ -29,4 +29,4 @@ ! MSVC-DLL-DEBUG-SAME: -D_DEBUG ! MSVC-DLL-DEBUG-SAME: -D_DLL ! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd -! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib +! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.runtime.dynamic_dbg.lib diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90 index ab7c675fe7b77..dc23be6462376 100644 --- a/flang/test/Driver/nostdlib.f90 +++ b/flang/test/Driver/nostdlib.f90 @@ -24,5 +24,5 @@ ! in certain cases. But it is not clear that it is worth checking for each ! platform individually. -! CHECK-NOT: "-lFortranRuntime" +! CHECK-NOT: "-lflang_rt.runtime" ! CHECK-NOT: "-lgcc" diff --git a/flang/test/Evaluate/rewrite-out_of_range.F90 b/flang/test/Evaluate/rewrite-out_of_range.F90 index 9196bba591e63..fcfe3eb8f6bd1 100644 --- a/flang/test/Evaluate/rewrite-out_of_range.F90 +++ b/flang/test/Evaluate/rewrite-out_of_range.F90 @@ -1,7 +1,7 @@ ! Tests rewriting of OUT_OF_RANGE() -! REQUIRES: target=x86-64{{.*}} +! REQUIRES: target=x86_64{{.*}} ! REQUIRES: system-linux -! RUN: %flang_fc1 -fdebug-unparse -cpp %s 2>&1 | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{%if system-linux %{,CHECK-X86-64%}%} +! RUN: %flang_fc1 -fdebug-unparse -cpp %s 2>&1 | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{%if system-linux %{,CHECK-X86-64%}%}%if flang-supports-f128-math %{,CHECK-KIND16%} logical round @@ -32,7 +32,7 @@ M(XT,XK,real,4); \ M(XT,XK,real,8); \ M(XT,XK,real,10); \ - M(XT,XK,real,16) + M(XT,XK,real, merge(16, 4, selected_real_kind(p=33).eq.16)) #define INTXS(M1,M2) \ M1(M2, integer, 1); \ @@ -47,7 +47,7 @@ M1(M2, real, 4); \ M1(M2, real, 8); \ M1(M2, real, 10); \ - M1(M2, real, 16) + M1(M2, real, merge(16, 4, selected_real_kind(p=33).eq.16)) INTXS(INTMOLDS, T1) INTXS(REALMOLDS, T1) @@ -87,31 +87,31 @@ !CHECK: PRINT *, " integer", 1_4, "real", 4_4, .false._4 !CHECK: PRINT *, " integer", 1_4, "real", 8_4, .false._4 !CHECK: PRINT *, " integer", 1_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " integer", 1_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " integer", 1_4, "real", 16_4, .false._4 !CHECK: PRINT *, " integer", 2_4, "real", 2_4, .false._4 !CHECK: PRINT *, " integer", 2_4, "real", 3_4, .false._4 !CHECK: PRINT *, " integer", 2_4, "real", 4_4, .false._4 !CHECK: PRINT *, " integer", 2_4, "real", 8_4, .false._4 !CHECK: PRINT *, " integer", 2_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " integer", 2_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " integer", 2_4, "real", 16_4, .false._4 !CHECK: PRINT *, " integer", 4_4, "real", 2_4, bgt(x--65519_4,131038_4) !CHECK: PRINT *, " integer", 4_4, "real", 3_4, .false._4 !CHECK: PRINT *, " integer", 4_4, "real", 4_4, .false._4 !CHECK: PRINT *, " integer", 4_4, "real", 8_4, .false._4 !CHECK: PRINT *, " integer", 4_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " integer", 4_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " integer", 4_4, "real", 16_4, .false._4 !CHECK: PRINT *, " integer", 8_4, "real", 2_4, bgt(x--65519_8,131038_8) !CHECK: PRINT *, " integer", 8_4, "real", 3_4, .false._4 !CHECK: PRINT *, " integer", 8_4, "real", 4_4, .false._4 !CHECK: PRINT *, " integer", 8_4, "real", 8_4, .false._4 !CHECK: PRINT *, " integer", 8_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " integer", 8_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " integer", 8_4, "real", 16_4, .false._4 !CHECK: PRINT *, " integer", 16_4, "real", 2_4, bgt(x--65519_16,131038_16) !CHECK: PRINT *, " integer", 16_4, "real", 3_4, .false._4 !CHECK: PRINT *, " integer", 16_4, "real", 4_4, .false._4 !CHECK: PRINT *, " integer", 16_4, "real", 8_4, .false._4 !CHECK: PRINT *, " integer", 16_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " integer", 16_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " integer", 16_4, "real", 16_4, .false._4 !CHECK: PRINT *, " real", 2_4, "integer", 1_4, bgt(transfer(real(x,kind=4)--1.28875e2_4,0_4),1132488704_4) !CHECK: PRINT *, " real", 2_4, "integer", 2_4, bgt(transfer(real(x,kind=4)--3.2768e4_4,0_4),1199566848_4) !CHECK: PRINT *, " real", 2_4, "integer", 4_4, bgt(transfer(real(x,kind=4)--6.5504e4_4,0_4),1207951360_4) @@ -137,11 +137,11 @@ !CHECK: PRINT *, " real", 10_4, "integer", 4_4, bgt(transfer(real(x,kind=16)--2.14748364899999999976716935634613037109375e9_16,0_16),85231552932850404448147289660857516032_16) !CHECK: PRINT *, " real", 10_4, "integer", 8_4, bgt(transfer(real(x,kind=16)--9.223372036854775808e18_16,0_16),85397706432322310006440791651706208256_16) !CHECK: PRINT *, " real", 10_4, "integer", 16_4, bgt(transfer(real(x,kind=16)--1.70141183460469231731687303715884105728e38_16,0_16),85730013431268538974666743416776294400_16) -!CHECK: PRINT *, " real", 16_4, "integer", 1_4, bgt(transfer(x--1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,0_16),85106958090653963310913789279497879551_16) -!CHECK: PRINT *, " real", 16_4, "integer", 2_4, bgt(transfer(x--3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,0_16),85148476262340800794535946896424304639_16) -!CHECK: PRINT *, " real", 16_4, "integer", 4_4, bgt(transfer(x--2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,0_16),85231552932850404448147711873322582015_16) -!CHECK: PRINT *, " real", 16_4, "integer", 8_4, bgt(transfer(x--9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,0_16),85397706432322310006441354601659629567_16) -!CHECK: PRINT *, " real", 16_4, "integer", 16_4, bgt(transfer(x--1.70141183460469231731687303715884105728e38_16,0_16),85730013431268538974667024891753005055_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 1_4, bgt(transfer(x--1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,0_16),85106958090653963310913789279497879551_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 2_4, bgt(transfer(x--3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,0_16),85148476262340800794535946896424304639_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 4_4, bgt(transfer(x--2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,0_16),85231552932850404448147711873322582015_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 8_4, bgt(transfer(x--9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,0_16),85397706432322310006441354601659629567_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 16_4, bgt(transfer(x--1.70141183460469231731687303715884105728e38_16,0_16),85730013431268538974667024891753005055_16) !CHECK: PRINT *, " real", 2_4, "integer", 1_4, "round", bgt(transfer(real(x,kind=4)-real(merge(-1.28375e2_2,-1.28875e2_2,round),kind=4),0_4),transfer(real(merge(1.274375e2_2,1.279375e2_2,round),kind=4)-real(merge(-1.28375e2_2,-1.28875e2_2,round),kind=4),0_4)) !CHECK: PRINT *, " real", 2_4, "integer", 2_4, "round", bgt(transfer(real(x,kind=4)-real(merge(-3.2768e4_2,-3.2768e4_2,round),kind=4),0_4),transfer(real(merge(3.2752e4_2,3.2752e4_2,round),kind=4)-real(merge(-3.2768e4_2,-3.2768e4_2,round),kind=4),0_4)) !CHECK: PRINT *, " real", 2_4, "integer", 4_4, "round", bgt(transfer(real(x,kind=4)-real(merge(-6.5504e4_2,-6.5504e4_2,round),kind=4),0_4),transfer(real(merge(6.5504e4_2,6.5504e4_2,round),kind=4)-real(merge(-6.5504e4_2,-6.5504e4_2,round),kind=4),0_4)) @@ -167,44 +167,44 @@ !CHECK: PRINT *, " real", 10_4, "integer", 4_4, "round", bgt(transfer(real(x,kind=16)-real(merge(-2.14748364849999999976716935634613037109375e9_10,-2.14748364899999999976716935634613037109375e9_10,round),kind=16),0_16),transfer(real(merge(2.147483647499999999883584678173065185546875e9_10,2.147483647999999999883584678173065185546875e9_10,round),kind=16)-real(merge(-2.14748364849999999976716935634613037109375e9_10,-2.14748364899999999976716935634613037109375e9_10,round),kind=16),0_16)) !CHECK: PRINT *, " real", 10_4, "integer", 8_4, "round", bgt(transfer(real(x,kind=16)-real(merge(-9.223372036854775808e18_10,-9.223372036854775808e18_10,round),kind=16),0_16),transfer(real(merge(9.223372036854775807e18_10,9.2233720368547758075e18_10,round),kind=16)-real(merge(-9.223372036854775808e18_10,-9.223372036854775808e18_10,round),kind=16),0_16)) !CHECK: PRINT *, " real", 10_4, "integer", 16_4, "round", bgt(transfer(real(x,kind=16)-real(merge(-1.70141183460469231731687303715884105728e38_10,-1.70141183460469231731687303715884105728e38_10,round),kind=16),0_16),transfer(real(merge(1.7014118346046923172246393167902932992e38_10,1.7014118346046923172246393167902932992e38_10,round),kind=16)-real(merge(-1.70141183460469231731687303715884105728e38_10,-1.70141183460469231731687303715884105728e38_10,round),kind=16),0_16)) -!CHECK: PRINT *, " real", 16_4, "integer", 1_4, "round", bgt(transfer(x-merge(-1.28499999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,-1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,round),0_16),transfer(merge(1.274999999999999999999999999999999876740483559216905404417411674564651613561494514215155504643917083740234375e2_16,1.279999999999999999999999999999999876740483559216905404417411674564651613561494514215155504643917083740234375e2_16,round)-merge(-1.28499999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,-1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,round),0_16)) -!CHECK: PRINT *, " real", 16_4, "integer", 2_4, "round", bgt(transfer(x-merge(-3.27684999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,-3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,round),0_16),transfer(merge(3.276749999999999999999999999999999684455637911595277835308573886885508130717425956390798091888427734375e4_16,3.276799999999999999999999999999999684455637911595277835308573886885508130717425956390798091888427734375e4_16,round)-merge(-3.27684999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,-3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,round),0_16)) -!CHECK: PRINT *, " real", 16_4, "integer", 4_4, "round", bgt(transfer(x-merge(-2.147483648499999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,-2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,round),0_16),transfer(merge(2.1474836474999999999999999999999997932048468617430812821478269825092866085469722747802734375e9_16,2.1474836479999999999999999999999997932048468617430812821478269825092866085469722747802734375e9_16,round)-merge(-2.147483648499999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,-2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,round),0_16)) -!CHECK: PRINT *, " real", 16_4, "integer", 8_4, "round", bgt(transfer(x-merge(-9.2233720368547758084999999999999982236431605997495353221893310546875e18_16,-9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,round),0_16),transfer(merge(9.22337203685477580749999999999999911182158029987476766109466552734375e18_16,9.22337203685477580799999999999999911182158029987476766109466552734375e18_16,round)-merge(-9.2233720368547758084999999999999982236431605997495353221893310546875e18_16,-9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,round),0_16)) -!CHECK: PRINT *, " real", 16_4, "integer", 16_4, "round", bgt(transfer(x-merge(-1.70141183460469231731687303715884105728e38_16,-1.70141183460469231731687303715884105728e38_16,round),0_16),transfer(merge(1.70141183460469231731687303715884089344e38_16,1.70141183460469231731687303715884089344e38_16,round)-merge(-1.70141183460469231731687303715884105728e38_16,-1.70141183460469231731687303715884105728e38_16,round),0_16)) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 1_4, "round", bgt(transfer(x-merge(-1.28499999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,-1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,round),0_16),transfer(merge(1.274999999999999999999999999999999876740483559216905404417411674564651613561494514215155504643917083740234375e2_16,1.279999999999999999999999999999999876740483559216905404417411674564651613561494514215155504643917083740234375e2_16,round)-merge(-1.28499999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,-1.28999999999999999999999999999999975348096711843381080883482334912930322712298902843031100928783416748046875e2_16,round),0_16)) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 2_4, "round", bgt(transfer(x-merge(-3.27684999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,-3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,round),0_16),transfer(merge(3.276749999999999999999999999999999684455637911595277835308573886885508130717425956390798091888427734375e4_16,3.276799999999999999999999999999999684455637911595277835308573886885508130717425956390798091888427734375e4_16,round)-merge(-3.27684999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,-3.27689999999999999999999999999999936891127582319055567061714777377101626143485191278159618377685546875e4_16,round),0_16)) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 4_4, "round", bgt(transfer(x-merge(-2.147483648499999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,-2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,round),0_16),transfer(merge(2.1474836474999999999999999999999997932048468617430812821478269825092866085469722747802734375e9_16,2.1474836479999999999999999999999997932048468617430812821478269825092866085469722747802734375e9_16,round)-merge(-2.147483648499999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,-2.147483648999999999999999999999999586409693723486162564295653965018573217093944549560546875e9_16,round),0_16)) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 8_4, "round", bgt(transfer(x-merge(-9.2233720368547758084999999999999982236431605997495353221893310546875e18_16,-9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,round),0_16),transfer(merge(9.22337203685477580749999999999999911182158029987476766109466552734375e18_16,9.22337203685477580799999999999999911182158029987476766109466552734375e18_16,round)-merge(-9.2233720368547758084999999999999982236431605997495353221893310546875e18_16,-9.2233720368547758089999999999999982236431605997495353221893310546875e18_16,round),0_16)) +!CHECK-KIND16: PRINT *, " real", 16_4, "integer", 16_4, "round", bgt(transfer(x-merge(-1.70141183460469231731687303715884105728e38_16,-1.70141183460469231731687303715884105728e38_16,round),0_16),transfer(merge(1.70141183460469231731687303715884089344e38_16,1.70141183460469231731687303715884089344e38_16,round)-merge(-1.70141183460469231731687303715884105728e38_16,-1.70141183460469231731687303715884105728e38_16,round),0_16)) !CHECK: PRINT *, " real", 2_4, "real", 2_4, .false._4 !CHECK: PRINT *, " real", 2_4, "real", 3_4, .false._4 !CHECK: PRINT *, " real", 2_4, "real", 4_4, .false._4 !CHECK: PRINT *, " real", 2_4, "real", 8_4, .false._4 !CHECK: PRINT *, " real", 2_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " real", 2_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 2_4, "real", 16_4, .false._4 !CHECK: PRINT *, " real", 3_4, "real", 2_4, blt(int(transfer(abs(x)-6.5536e4_3,0_2),kind=8)-1_8,32639_2) !CHECK: PRINT *, " real", 3_4, "real", 3_4, .false._4 !CHECK: PRINT *, " real", 3_4, "real", 4_4, .false._4 !CHECK: PRINT *, " real", 3_4, "real", 8_4, .false._4 !CHECK: PRINT *, " real", 3_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " real", 3_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 3_4, "real", 16_4, .false._4 !CHECK: PRINT *, " real", 4_4, "real", 2_4, blt(int(transfer(abs(x)-6.5504e4_4,0_4),kind=8)-1_8,2139095039_4) !CHECK: PRINT *, " real", 4_4, "real", 3_4, blt(int(transfer(abs(x)-3.3895313892515354759047080037148786688e38_4,0_4),kind=8)-1_8,2139095039_4) !CHECK: PRINT *, " real", 4_4, "real", 4_4, .false._4 !CHECK: PRINT *, " real", 4_4, "real", 8_4, .false._4 !CHECK: PRINT *, " real", 4_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " real", 4_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 4_4, "real", 16_4, .false._4 !CHECK: PRINT *, " real", 8_4, "real", 2_4, blt(transfer(abs(x)-6.5504e4_8,0_8)-1_8,9218868437227405311_8) !CHECK: PRINT *, " real", 8_4, "real", 3_4, blt(transfer(abs(x)-3.3895313892515354759047080037148786688e38_8,0_8)-1_8,9218868437227405311_8) !CHECK: PRINT *, " real", 8_4, "real", 4_4, blt(transfer(abs(x)-3.4028234663852885981170418348451692544e38_8,0_8)-1_8,9218868437227405311_8) !CHECK: PRINT *, " real", 8_4, "real", 8_4, .false._4 !CHECK: PRINT *, " real", 8_4, "real", 10_4, .false._4 -!CHECK: PRINT *, " real", 8_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 8_4, "real", 16_4, .false._4 !CHECK-X86-64: PRINT *, " real", 10_4, "real", 2_4, blt(transfer(abs(x)-6.5504e4_10,0_16)-1_16,604444463063240877801471_16) !CHECK-X86-64: PRINT *, " real", 10_4, "real", 3_4, blt(transfer(abs(x)-3.3895313892515354759047080037148786688e38_10,0_16)-1_16,604444463063240877801471_16) !CHECK-X86-64: PRINT *, " real", 10_4, "real", 4_4, blt(transfer(abs(x)-3.4028234663852885981170418348451692544e38_10,0_16)-1_16,604444463063240877801471_16) !CHECK-X86-64: PRINT *, " real", 10_4, "real", 8_4, blt(transfer(abs(x)-1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e308_10,0_16)-1_16,604444463063240877801471_16) !CHECK-X86-64: PRINT *, " real", 10_4, "real", 10_4, .false._4 -!CHECK-X86-64: PRINT *, " real", 10_4, "real", 16_4, .false._4 -!CHECK: PRINT *, " real", 16_4, "real", 2_4, blt(transfer(abs(x)-6.5504e4_16,0_16)-1_16,170135991163610696904058773219554885631_16) -!CHECK: PRINT *, " real", 16_4, "real", 3_4, blt(transfer(abs(x)-3.3895313892515354759047080037148786688e38_16,0_16)-1_16,170135991163610696904058773219554885631_16) -!CHECK: PRINT *, " real", 16_4, "real", 4_4, blt(transfer(abs(x)-3.4028234663852885981170418348451692544e38_16,0_16)-1_16,170135991163610696904058773219554885631_16) -!CHECK: PRINT *, " real", 16_4, "real", 8_4, blt(transfer(abs(x)-1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e308_16,0_16)-1_16,170135991163610696904058773219554885631_16) -!CHECK: PRINT *, " real", 16_4, "real", 10_4, blt(transfer(abs(x)-1.18973149535723176502126385303097020516906332229462420044032373389173700552297072261641029033652888285354569780749557731442744315367028843419812557385374367867359320070697326320191591828296152436552951064679108661431179063216977883889613478656060039914875343321145491116008867984515486651285234014977303760000912547939396622315138362241783854274391783813871780588948754057516822634765923557697480511372564902088485522249479139937758502601177354918009979622602685950855888360815984690023564513234659447638493985927645628457966177293040780660922910271504608538808795932778162298682754783076808004015069494230341172895777710033571401055977524212405734700738625166011082837911962300846927720096515350020847447079244384854591288672300061908512647211195136146752763351956292759795725027800298079590419313960302147099703527646744553092202267965628099149823208332964124103850923918473478612192169721054348428704835340811304257300221642134891734717423480071488075100206439051723424765600472176809648610799494341570347632064355862420744350442438056613601760883747816538902780957697597728686007148702828795556714140463261583262360276289631617397848425448686060994827086796804807870251185893083854658422304090880599629459458620190376604844679092600222541053077590106576067134720012584640695703025713896098375799892695455305236856075868317922311363951946885088077187210470520395758748001314313144425494391994017575316933939236688185618912993172910425292123683515992232205099800167710278403536014082929639811512287776813570604578934353545169653956125404884644716978689321167108722908808277835051822885764606221873970285165508372099234948333443522898475123275372663606621390228126470623407535207172405866507951821730346378263135339370677490195019784169044182473806316282858685774143258116536404021840272491339332094921949842244273042701987304453662035026238695780468200360144729199712309553005720614186697485284685618651483271597448120312194675168637934309618961510733006555242148519520176285859509105183947250286387163249416761380499631979144187025430270675849519200883791516940158174004671147787720145964446117520405945350476472180797576111172084627363927960033967047003761337450955318415007379641260504792325166135484129188421134082301547330475406707281876350361733290800595189632520707167390454777712968226520622565143991937680440029238090311243791261477625596469422198137514696707944687035800439250765945161837981185939204954403611491531078225107269148697980924094677214272701240437718740921675661363493890045123235166814608932240069799317601780533819184998193300841098599393876029260139091141452600372028487213241195542428210183120421610446740462163533690058366460659115629876474552506814500393294140413149540067760295100596225302282300363147382468105964844244132486457313743759509641616804802412935187620466813563687753281467553879887177183651289394719533506188500326760735438867336800207438784965701457609034985757124304510203873049485425670247933932280911052604153852899484920399109194612991249163328991799809438033787952209313146694614970593966415237594928589096048991612194498998638483702248667224914892467841020618336462741696957630763248023558797524525373703543388296086275342774001633343405508353704850737454481975472222897528108302089868263302028525992308416805453968791141829762998896457648276528750456285492426516521775079951625966922911497778896235667095662713848201819134832168799586365263762097828507009933729439678463987902491451422274252700636394232799848397673998715441855420156224415492665301451550468548925862027608576183712976335876121538256512963353814166394951655600026415918655485005705261143195291991880795452239464962763563017858089669222640623538289853586759599064700838568712381032959192649484625076899225841930548076362021508902214922052806984201835084058693849381549890944546197789302911357651677540623227829831403347327660395223160342282471752818181884430488092132193355086987339586127607367086665237555567580317149010847732009642431878007000879734603290627894355374356444885190719161645514115576193939969076741515640282654366402676009508752394550734155613586793306603174472092444651353236664764973540085196704077110364053815007348689179836404957060618953500508984091382686953509006678332447257871219660441528492484004185093281190896363417573989716659600075948780061916409485433875852065711654107226099628815012314437794400874930194474433078438899570184271000480830501217712356062289507626904285680004771889315808935851559386317665294808903126774702966254511086154895839508779675546413794489596052797520987481383976257859210575628440175934932416214833956535018919681138909184379573470326940634289008780584694035245347939808067427323629788710086717580253156130235606487870925986528841635097252953709111431720488774740553905400942537542411931794417513706468964386151771884986701034153254238591108962471088538580868883777725864856414593426212108664758848926003176234596076950884914966244415660441955208681198977024e4932_16,0_16)-1_16,170135991163610696904058773219554885631_16) -!CHECK: PRINT *, " real", 16_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 10_4, "real", 16_4, .false._4 +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 2_4, blt(transfer(abs(x)-6.5504e4_16,0_16)-1_16,170135991163610696904058773219554885631_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 3_4, blt(transfer(abs(x)-3.3895313892515354759047080037148786688e38_16,0_16)-1_16,170135991163610696904058773219554885631_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 4_4, blt(transfer(abs(x)-3.4028234663852885981170418348451692544e38_16,0_16)-1_16,170135991163610696904058773219554885631_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 8_4, blt(transfer(abs(x)-1.79769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368e308_16,0_16)-1_16,170135991163610696904058773219554885631_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 10_4, blt(transfer(abs(x)-1.18973149535723176502126385303097020516906332229462420044032373389173700552297072261641029033652888285354569780749557731442744315367028843419812557385374367867359320070697326320191591828296152436552951064679108661431179063216977883889613478656060039914875343321145491116008867984515486651285234014977303760000912547939396622315138362241783854274391783813871780588948754057516822634765923557697480511372564902088485522249479139937758502601177354918009979622602685950855888360815984690023564513234659447638493985927645628457966177293040780660922910271504608538808795932778162298682754783076808004015069494230341172895777710033571401055977524212405734700738625166011082837911962300846927720096515350020847447079244384854591288672300061908512647211195136146752763351956292759795725027800298079590419313960302147099703527646744553092202267965628099149823208332964124103850923918473478612192169721054348428704835340811304257300221642134891734717423480071488075100206439051723424765600472176809648610799494341570347632064355862420744350442438056613601760883747816538902780957697597728686007148702828795556714140463261583262360276289631617397848425448686060994827086796804807870251185893083854658422304090880599629459458620190376604844679092600222541053077590106576067134720012584640695703025713896098375799892695455305236856075868317922311363951946885088077187210470520395758748001314313144425494391994017575316933939236688185618912993172910425292123683515992232205099800167710278403536014082929639811512287776813570604578934353545169653956125404884644716978689321167108722908808277835051822885764606221873970285165508372099234948333443522898475123275372663606621390228126470623407535207172405866507951821730346378263135339370677490195019784169044182473806316282858685774143258116536404021840272491339332094921949842244273042701987304453662035026238695780468200360144729199712309553005720614186697485284685618651483271597448120312194675168637934309618961510733006555242148519520176285859509105183947250286387163249416761380499631979144187025430270675849519200883791516940158174004671147787720145964446117520405945350476472180797576111172084627363927960033967047003761337450955318415007379641260504792325166135484129188421134082301547330475406707281876350361733290800595189632520707167390454777712968226520622565143991937680440029238090311243791261477625596469422198137514696707944687035800439250765945161837981185939204954403611491531078225107269148697980924094677214272701240437718740921675661363493890045123235166814608932240069799317601780533819184998193300841098599393876029260139091141452600372028487213241195542428210183120421610446740462163533690058366460659115629876474552506814500393294140413149540067760295100596225302282300363147382468105964844244132486457313743759509641616804802412935187620466813563687753281467553879887177183651289394719533506188500326760735438867336800207438784965701457609034985757124304510203873049485425670247933932280911052604153852899484920399109194612991249163328991799809438033787952209313146694614970593966415237594928589096048991612194498998638483702248667224914892467841020618336462741696957630763248023558797524525373703543388296086275342774001633343405508353704850737454481975472222897528108302089868263302028525992308416805453968791141829762998896457648276528750456285492426516521775079951625966922911497778896235667095662713848201819134832168799586365263762097828507009933729439678463987902491451422274252700636394232799848397673998715441855420156224415492665301451550468548925862027608576183712976335876121538256512963353814166394951655600026415918655485005705261143195291991880795452239464962763563017858089669222640623538289853586759599064700838568712381032959192649484625076899225841930548076362021508902214922052806984201835084058693849381549890944546197789302911357651677540623227829831403347327660395223160342282471752818181884430488092132193355086987339586127607367086665237555567580317149010847732009642431878007000879734603290627894355374356444885190719161645514115576193939969076741515640282654366402676009508752394550734155613586793306603174472092444651353236664764973540085196704077110364053815007348689179836404957060618953500508984091382686953509006678332447257871219660441528492484004185093281190896363417573989716659600075948780061916409485433875852065711654107226099628815012314437794400874930194474433078438899570184271000480830501217712356062289507626904285680004771889315808935851559386317665294808903126774702966254511086154895839508779675546413794489596052797520987481383976257859210575628440175934932416214833956535018919681138909184379573470326940634289008780584694035245347939808067427323629788710086717580253156130235606487870925986528841635097252953709111431720488774740553905400942537542411931794417513706468964386151771884986701034153254238591108962471088538580868883777725864856414593426212108664758848926003176234596076950884914966244415660441955208681198977024e4932_16,0_16)-1_16,170135991163610696904058773219554885631_16) +!CHECK-KIND16: PRINT *, " real", 16_4, "real", 16_4, .false._4 diff --git a/flang/test/HLFIR/maxval-elemental.fir b/flang/test/HLFIR/maxval-elemental.fir index aa642253b0832..9dc028abe8da3 100644 --- a/flang/test/HLFIR/maxval-elemental.fir +++ b/flang/test/HLFIR/maxval-elemental.fir @@ -82,9 +82,9 @@ func.func @_QPtest_float(%arg0: !fir.box> {fir.bindc_name = "a // CHECK-NEXT: %[[V6:.*]] = fir.do_loop %arg1 = %c1 to %c4 step %c1 iter_args(%arg2 = %cst) -> (f32) { // CHECK-NEXT: %[[V7:.*]] = hlfir.designate %[[V5]] (%arg1) : (!fir.box>, index) -> !fir.ref // CHECK-NEXT: %[[V8:.*]] = fir.load %[[V7]] : !fir.ref -// CHECK-NEXT: %[[V9:.*]] = arith.cmpf ogt, %[[V8]], %arg2 : f32 -// CHECK-NEXT: %[[V10:.*]] = arith.cmpf une, %arg2, %arg2 : f32 -// CHECK-NEXT: %[[V11:.*]] = arith.cmpf oeq, %[[V8]], %[[V8]] : f32 +// CHECK-NEXT: %[[V9:.*]] = arith.cmpf ogt, %[[V8]], %arg2 fastmath : f32 +// CHECK-NEXT: %[[V10:.*]] = arith.cmpf une, %arg2, %arg2 fastmath : f32 +// CHECK-NEXT: %[[V11:.*]] = arith.cmpf oeq, %[[V8]], %[[V8]] fastmath : f32 // CHECK-NEXT: %[[V12:.*]] = arith.andi %[[V10]], %[[V11]] : i1 // CHECK-NEXT: %[[V13:.*]] = arith.ori %[[V9]], %[[V12]] : i1 // CHECK-NEXT: %[[V14:.*]] = arith.select %[[V13]], %[[V8]], %arg2 : f32 diff --git a/flang/test/HLFIR/minval-elemental.fir b/flang/test/HLFIR/minval-elemental.fir index 8da1b1bdf515b..64cd5403ec558 100644 --- a/flang/test/HLFIR/minval-elemental.fir +++ b/flang/test/HLFIR/minval-elemental.fir @@ -82,9 +82,9 @@ func.func @_QPtest_float(%arg0: !fir.box> {fir.bindc_name = "a // CHECK-NEXT: %[[V6:.*]] = fir.do_loop %arg1 = %c1 to %c4 step %c1 iter_args(%arg2 = %cst) -> (f32) { // CHECK-NEXT: %[[V7:.*]] = hlfir.designate %[[V5]] (%arg1) : (!fir.box>, index) -> !fir.ref // CHECK-NEXT: %[[V8:.*]] = fir.load %[[V7]] : !fir.ref -// CHECK-NEXT: %[[V9:.*]] = arith.cmpf olt, %[[V8]], %arg2 : f32 -// CHECK-NEXT: %[[V10:.*]] = arith.cmpf une, %arg2, %arg2 : f32 -// CHECK-NEXT: %[[V11:.*]] = arith.cmpf oeq, %[[V8]], %[[V8]] : f32 +// CHECK-NEXT: %[[V9:.*]] = arith.cmpf olt, %[[V8]], %arg2 fastmath : f32 +// CHECK-NEXT: %[[V10:.*]] = arith.cmpf une, %arg2, %arg2 fastmath : f32 +// CHECK-NEXT: %[[V11:.*]] = arith.cmpf oeq, %[[V8]], %[[V8]] fastmath : f32 // CHECK-NEXT: %[[V12:.*]] = arith.andi %[[V10]], %[[V11]] : i1 // CHECK-NEXT: %[[V13:.*]] = arith.ori %[[V9]], %[[V12]] : i1 // CHECK-NEXT: %[[V14:.*]] = arith.select %[[V13]], %[[V8]], %arg2 : f32 diff --git a/flang/test/Integration/unroll.f90 b/flang/test/Integration/unroll.f90 index 9d69605e10d1b..aa47e465b63fc 100644 --- a/flang/test/Integration/unroll.f90 +++ b/flang/test/Integration/unroll.f90 @@ -3,14 +3,47 @@ ! CHECK-LABEL: unroll_dir subroutine unroll_dir integer :: a(10) - !dir$ unroll - ! CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[ANNOTATION:.*]] + !dir$ unroll + ! CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[UNROLL_ENABLE_FULL_ANNO:.*]] do i=1,10 - a(i)=i + a(i)=i end do end subroutine unroll_dir -! CHECK: ![[ANNOTATION]] = distinct !{![[ANNOTATION]], ![[UNROLL:.*]], ![[UNROLL_FULL:.*]]} -! CHECK: ![[UNROLL]] = !{!"llvm.loop.unroll.enable"} -! CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"} +! CHECK-LABEL: unroll_dir_0 +subroutine unroll_dir_0 + integer :: a(10) + !dir$ unroll 0 + ! CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[UNROLL_DISABLE_ANNO:.*]] + do i=1,10 + a(i)=i + end do +end subroutine unroll_dir_0 + +! CHECK-LABEL: unroll_dir_1 +subroutine unroll_dir_1 + integer :: a(10) + !dir$ unroll 1 + ! CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[UNROLL_DISABLE_ANNO]] + do i=1,10 + a(i)=i + end do +end subroutine unroll_dir_1 + +! CHECK-LABEL: unroll_dir_2 +subroutine unroll_dir_2 + integer :: a(10) + !dir$ unroll 2 + ! CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[UNROLL_ENABLE_COUNT_2:.*]] + do i=1,10 + a(i)=i + end do +end subroutine unroll_dir_2 +! CHECK: ![[UNROLL_ENABLE_FULL_ANNO]] = distinct !{![[UNROLL_ENABLE_FULL_ANNO]], ![[UNROLL_ENABLE:.*]], ![[UNROLL_FULL:.*]]} +! CHECK: ![[UNROLL_ENABLE:.*]] = !{!"llvm.loop.unroll.enable"} +! CHECK: ![[UNROLL_FULL:.*]] = !{!"llvm.loop.unroll.full"} +! CHECK: ![[UNROLL_DISABLE_ANNO]] = distinct !{![[UNROLL_DISABLE_ANNO]], ![[UNROLL_DISABLE:.*]]} +! CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"} +! CHECK: ![[UNROLL_ENABLE_COUNT_2]] = distinct !{![[UNROLL_ENABLE_COUNT_2]], ![[UNROLL_ENABLE]], ![[UNROLL_COUNT_2:.*]]} +! CHECK: ![[UNROLL_COUNT_2]] = !{!"llvm.loop.unroll.count", i32 2} diff --git a/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 b/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 index 0b7c8664abd9f..065033431137d 100644 --- a/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 +++ b/flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90 @@ -65,8 +65,10 @@ subroutine acc_declare_present(a) ! CHECK-DAG: %[[DECL:.*]]:2 = hlfir.declare %[[ARG0]](%{{.*}}) dummy_scope %{{[0-9]+}} {acc.declare = #acc.declare, uniq_name = "_QMacc_declareFacc_declare_presentEa"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> (!fir.ref>, !fir.ref>) ! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%{{.*}} : index) upperbound(%{{.*}} : index) extent(%{{.*}} : index) stride(%{{.*}} : index) startIdx(%[[C1]] : index) ! CHECK: %[[PRESENT:.*]] = acc.present varPtr(%[[DECL]]#0 : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {name = "a"} -! CHECK: acc.declare_enter dataOperands(%[[PRESENT]] : !fir.ref>) +! CHECK: %[[TOKEN:.*]] = acc.declare_enter dataOperands(%[[PRESENT]] : !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) +! CHECK: acc.declare_exit token(%[[TOKEN]]) dataOperands(%[[PRESENT]] : !fir.ref>) +! CHECK: acc.delete accPtr(%[[PRESENT]] : !fir.ref>) bounds(%[[BOUND]]) {dataClause = #acc, name = "a"} subroutine acc_declare_copyin() integer :: a(100), b(10), i diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90 index 9f03bc3c2b481..8727c0722e474 100644 --- a/flang/test/Lower/OpenACC/acc-declare.f90 +++ b/flang/test/Lower/OpenACC/acc-declare.f90 @@ -59,8 +59,10 @@ subroutine acc_declare_present(a) ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref> {fir.bindc_name = "a"}) ! CHECK: %[[DECL:.*]]:2 = hlfir.declare %[[ARG0]](%{{.*}}) dummy_scope %{{[0-9]+}} {acc.declare = #acc.declare, uniq_name = "_QMacc_declareFacc_declare_presentEa"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> (!fir.ref>, !fir.ref>) ! CHECK: %[[PRESENT:.*]] = acc.present varPtr(%[[DECL]]#0 : !fir.ref>) -> !fir.ref> {name = "a"} -! CHECK: acc.declare_enter dataOperands(%[[PRESENT]] : !fir.ref>) +! CHECK: %[[TOKEN:.*]] = acc.declare_enter dataOperands(%[[PRESENT]] : !fir.ref>) ! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) +! CHECK: acc.declare_exit token(%[[TOKEN]]) dataOperands(%[[PRESENT]] : !fir.ref>) +! CHECK: acc.delete accPtr(%[[PRESENT]] : !fir.ref>) {dataClause = #acc, name = "a"} subroutine acc_declare_copyin() integer :: a(100), b(10), i diff --git a/flang/test/Lower/OpenACC/acc-kernels-loop.f90 b/flang/test/Lower/OpenACC/acc-kernels-loop.f90 index 182b512f3931e..aa5d65afd57ec 100644 --- a/flang/test/Lower/OpenACC/acc-kernels-loop.f90 +++ b/flang/test/Lower/OpenACC/acc-kernels-loop.f90 @@ -393,6 +393,8 @@ subroutine acc_kernels_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[NOCREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NOCREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc kernels loop present(a, b) DO i = 1, n @@ -407,6 +409,8 @@ subroutine acc_kernels_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc kernels loop deviceptr(a) deviceptr(b) DO i = 1, n diff --git a/flang/test/Lower/OpenACC/acc-kernels.f90 b/flang/test/Lower/OpenACC/acc-kernels.f90 index f25a9d411098b..b333bb981a79b 100644 --- a/flang/test/Lower/OpenACC/acc-kernels.f90 +++ b/flang/test/Lower/OpenACC/acc-kernels.f90 @@ -253,6 +253,9 @@ subroutine acc_kernels ! CHECK: acc.kernels dataOperands(%[[NO_CREATE_A]], %[[NO_CREATE_B]], %[[CREATE_C]] : !fir.ref>, !fir.ref>, !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[CREATE_C]] : !fir.ref>) {dataClause = #acc, name = "c"} +! CHECK: acc.delete accPtr(%[[NO_CREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NO_CREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc kernels present(a, b, c) !$acc end kernels @@ -263,6 +266,9 @@ subroutine acc_kernels ! CHECK: acc.kernels dataOperands(%[[PRESENT_A]], %[[PRESENT_B]], %[[PRESENT_C]] : !fir.ref>, !fir.ref>, !fir.ref>) { ! CHECK: acc.terminator ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} +! CHECK: acc.delete accPtr(%[[PRESENT_C]] : !fir.ref>) {dataClause = #acc, name = "c"} !$acc kernels deviceptr(a) deviceptr(c) !$acc end kernels diff --git a/flang/test/Lower/OpenACC/acc-parallel-loop.f90 b/flang/test/Lower/OpenACC/acc-parallel-loop.f90 index 6f4409eaf5600..7a41da320b955 100644 --- a/flang/test/Lower/OpenACC/acc-parallel-loop.f90 +++ b/flang/test/Lower/OpenACC/acc-parallel-loop.f90 @@ -393,6 +393,8 @@ subroutine acc_parallel_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[NOCREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NOCREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc parallel loop present(a, b) DO i = 1, n @@ -407,6 +409,8 @@ subroutine acc_parallel_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc parallel loop deviceptr(a) deviceptr(b) DO i = 1, n diff --git a/flang/test/Lower/OpenACC/acc-parallel.f90 b/flang/test/Lower/OpenACC/acc-parallel.f90 index 7a51be21e914d..e16c1b218878c 100644 --- a/flang/test/Lower/OpenACC/acc-parallel.f90 +++ b/flang/test/Lower/OpenACC/acc-parallel.f90 @@ -291,7 +291,8 @@ subroutine acc_parallel ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} ! CHECK: acc.delete accPtr(%[[CREATE_C]] : !fir.ref>) {dataClause = #acc, name = "c"} - +! CHECK: acc.delete accPtr(%[[NO_CREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NO_CREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc parallel present(a, b, c) !$acc end parallel @@ -302,6 +303,9 @@ subroutine acc_parallel ! CHECK: acc.parallel dataOperands(%[[PRESENT_A]], %[[PRESENT_B]], %[[PRESENT_C]] : !fir.ref>, !fir.ref>, !fir.ref>) { ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} +! CHECK: acc.delete accPtr(%[[PRESENT_C]] : !fir.ref>) {dataClause = #acc, name = "c"} !$acc parallel deviceptr(a) deviceptr(c) !$acc end parallel diff --git a/flang/test/Lower/OpenACC/acc-serial-loop.f90 b/flang/test/Lower/OpenACC/acc-serial-loop.f90 index 66cde19ef09af..a94f0e8e8583e 100644 --- a/flang/test/Lower/OpenACC/acc-serial-loop.f90 +++ b/flang/test/Lower/OpenACC/acc-serial-loop.f90 @@ -334,6 +334,8 @@ subroutine acc_serial_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[NOCREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NOCREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc serial loop present(a, b) DO i = 1, n @@ -348,6 +350,8 @@ subroutine acc_serial_loop ! CHECK-NEXT: }{{$}} ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc serial loop deviceptr(a) deviceptr(b) DO i = 1, n diff --git a/flang/test/Lower/OpenACC/acc-serial.f90 b/flang/test/Lower/OpenACC/acc-serial.f90 index 88b801a82ee68..f2f73876af877 100644 --- a/flang/test/Lower/OpenACC/acc-serial.f90 +++ b/flang/test/Lower/OpenACC/acc-serial.f90 @@ -227,6 +227,9 @@ subroutine acc_serial ! CHECK: acc.serial dataOperands(%[[NO_CREATE_A]], %[[NO_CREATE_B]], %[[CREATE_C]] : !fir.ref>, !fir.ref>, !fir.ref>) { ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[CREATE_C]] : !fir.ref>) {dataClause = #acc, name = "c"} +! CHECK: acc.delete accPtr(%[[NO_CREATE_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[NO_CREATE_B]] : !fir.ref>) {dataClause = #acc, name = "b"} !$acc serial present(a, b, c) !$acc end serial @@ -237,6 +240,9 @@ subroutine acc_serial ! CHECK: acc.serial dataOperands(%[[PRESENT_A]], %[[PRESENT_B]], %[[PRESENT_C]] : !fir.ref>, !fir.ref>, !fir.ref>) { ! CHECK: acc.yield ! CHECK-NEXT: }{{$}} +! CHECK: acc.delete accPtr(%[[PRESENT_A]] : !fir.ref>) {dataClause = #acc, name = "a"} +! CHECK: acc.delete accPtr(%[[PRESENT_B]] : !fir.ref>) {dataClause = #acc, name = "b"} +! CHECK: acc.delete accPtr(%[[PRESENT_C]] : !fir.ref>) {dataClause = #acc, name = "c"} !$acc serial deviceptr(a) deviceptr(c) !$acc end serial diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c index b1a5fa004014c..4fcf8f9d478d8 100644 --- a/flang/test/Runtime/no-cpp-dep.c +++ b/flang/test/Runtime/no-cpp-dep.c @@ -1,9 +1,9 @@ /* This test makes sure that flang's runtime does not depend on the C++ runtime -library. It tries to link this simple file against libFortranRuntime.a with +library. It tries to link this simple file against libflang_rt.runtime.a with a C compiler. -REQUIRES: c-compiler +REQUIRES: c-compiler, flang-rt RUN: %if system-aix %{ export OBJECT_MODE=64 %} RUN: %cc -std=c99 %s -I%include %libruntime -lm \ diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py index c452b6d231c89..c6266f3976f7c 100644 --- a/flang/test/lit.cfg.py +++ b/flang/test/lit.cfg.py @@ -163,11 +163,14 @@ ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal") ) +if config.flang_include_runtime: + config.available_features.add("flang-rt") + # Define some variables to help us test that the flang runtime doesn't depend on # the C++ runtime libraries. For this we need a C compiler. If for some reason # we don't have one, we can just disable the test. -if config.cc: - libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a") +if config.flang_include_runtime and config.cc: + libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.runtime.a") include = os.path.join(config.flang_src_dir, "include") if ( diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in index d1a0ac763cf8a..697ba3fa79763 100644 --- a/flang/test/lit.site.cfg.py.in +++ b/flang/test/lit.site.cfg.py.in @@ -1,6 +1,7 @@ @LIT_SITE_CFG_IN_HEADER@ import sys +import lit.util config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@")) @@ -32,6 +33,7 @@ else: config.openmp_module_dir = None config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@" config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@" +config.flang_include_runtime = lit.util.pythonize_bool("@FLANG_INCLUDE_RUNTIME@") import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt index cc2bc5b8eb5ce..5b5f23b5dc73c 100644 --- a/flang/tools/f18/CMakeLists.txt +++ b/flang/tools/f18/CMakeLists.txt @@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS ) # Define the list of Fortran module files that need to be compiled -# to produce an object file for inclusion into the FortranRuntime +# to produce an object file for inclusion into the flang_rt.runtime # library. set(MODULES_WITH_IMPLEMENTATION "iso_fortran_env_impl" @@ -105,11 +105,11 @@ if (NOT CMAKE_CROSSCOMPILING) endif() # Some modules have an implementation part that needs to be added to the - # FortranRuntime library. + # flang_rt.runtime library. set(compile_with "-fsyntax-only") set(object_output "") set(include_in_link FALSE) - if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION) + if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FLANG_INCLUDE_RUNTIME) set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}") set(compile_with -c -o ${object_output}) set(include_in_link TRUE) @@ -127,14 +127,14 @@ if (NOT CMAKE_CROSSCOMPILING) install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang") # If a module has been compiled into an object file, add the file to - # the link line for the FortranRuntime library. + # the link line for the flang_rt.runtime library. if(include_in_link) list(APPEND module_objects ${object_output}) endif() endforeach() # Set a CACHE variable that is visible to the CMakeLists.txt in runtime/, so that - # the compiled Fortran modules can be added to the link line of the FortranRuntime + # the compiled Fortran modules can be added to the link line of the flang_rt.runtime # library. set(FORTRAN_MODULE_OBJECTS ${module_objects} CACHE INTERNAL "" FORCE) diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt index 945067fed4f82..c54ceb3332abf 100644 --- a/flang/unittests/CMakeLists.txt +++ b/flang/unittests/CMakeLists.txt @@ -1,6 +1,8 @@ +include(AddFlangOffloadRuntime) + if (FLANG_EXPERIMENTAL_CUDA_RUNTIME) # If Fortran runtime is built as CUDA library, the linking - # of targets that link FortranRuntime must be done + # of targets that link flang_rt.runtime must be done # with CUDA_RESOLVE_DEVICE_SYMBOLS. # CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS # to take effect. @@ -11,6 +13,11 @@ add_custom_target(FlangUnitTests) set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests") function(add_flang_unittest_offload_properties target) + # Do not apply runtime properties if not even compiling the runtime. + if (NOT FLANG_INCLUDE_RUNTIME) + return () + endif () + # Set CUDA_RESOLVE_DEVICE_SYMBOLS. if (FLANG_EXPERIMENTAL_CUDA_RUNTIME) set_target_properties(${target} @@ -75,5 +82,7 @@ add_subdirectory(Optimizer) add_subdirectory(Common) add_subdirectory(Decimal) add_subdirectory(Evaluate) -add_subdirectory(Runtime) +if (FLANG_INCLUDE_RUNTIME) + add_subdirectory(Runtime) +endif () add_subdirectory(Frontend) diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt index 8111ecd72cfc7..2278d61febcb1 100644 --- a/flang/unittests/Evaluate/CMakeLists.txt +++ b/flang/unittests/Evaluate/CMakeLists.txt @@ -33,7 +33,6 @@ add_flang_nongtest_unittest(intrinsics FortranDecimal FortranSemantics FortranParser - FortranRuntime ) add_flang_nongtest_unittest(logical @@ -56,19 +55,21 @@ add_flang_nongtest_unittest(real ) llvm_update_compile_flags(real.test) -add_flang_nongtest_unittest(reshape - NonGTestTesting - FortranSemantics - FortranEvaluate - FortranRuntime -) +if (FLANG_INCLUDE_RUNTIME) + add_flang_nongtest_unittest(reshape + NonGTestTesting + FortranSemantics + FortranEvaluate + flang_rt.runtime + ) -add_flang_nongtest_unittest(ISO-Fortran-binding - NonGTestTesting - FortranEvaluate - FortranSemantics - FortranRuntime -) + add_flang_nongtest_unittest(ISO-Fortran-binding + NonGTestTesting + FortranEvaluate + FortranSemantics + flang_rt.runtime + ) +endif () add_flang_nongtest_unittest(folding FortranSupport diff --git a/flang/unittests/Runtime/CMakeLists.txt b/flang/unittests/Runtime/CMakeLists.txt index 179e439917ff2..f3743be49b015 100644 --- a/flang/unittests/Runtime/CMakeLists.txt +++ b/flang/unittests/Runtime/CMakeLists.txt @@ -33,7 +33,7 @@ add_flang_unittest(FlangRuntimeTests target_link_libraries(FlangRuntimeTests PRIVATE - FortranRuntime + flang_rt.runtime ) target_compile_definitions(FlangRuntimeTests PRIVATE NOT_EXE="$") diff --git a/flang/unittests/Runtime/CUDA/CMakeLists.txt b/flang/unittests/Runtime/CUDA/CMakeLists.txt index a7fe604d687bd..860b2664d623b 100644 --- a/flang/unittests/Runtime/CUDA/CMakeLists.txt +++ b/flang/unittests/Runtime/CUDA/CMakeLists.txt @@ -15,8 +15,8 @@ endif() target_link_libraries(FlangCufRuntimeTests PRIVATE ${CUDA_RT_TARGET} - CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR} - FortranRuntime + flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR} + flang_rt.runtime ) target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS}) diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 10bb9c9487d63..f33db5826537b 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -38,9 +38,8 @@ function(_get_common_test_compile_options output_var c_test flags) endif() # list(APPEND compile_options "-Wconversion") # list(APPEND compile_options "-Wno-sign-conversion") - # list(APPEND compile_options "-Wimplicit-fallthrough") - # list(APPEND compile_options "-Wwrite-strings") - list(APPEND compile_options "-Wextra-semi") + list(APPEND compile_options "-Wimplicit-fallthrough") + list(APPEND compile_options "-Wwrite-strings") # Silence this warning because _Complex is a part of C99. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(NOT c_test) @@ -51,13 +50,14 @@ function(_get_common_test_compile_options output_var c_test flags) list(APPEND compile_options "-Wno-gnu-imaginary-constant") endif() list(APPEND compile_options "-Wno-pedantic") - # if(NOT CMAKE_COMPILER_IS_GNUCXX) - # list(APPEND compile_options "-Wnewline-eof") - # list(APPEND compile_options "-Wnonportable-system-include-path") - # list(APPEND compile_options "-Wstrict-prototypes") - # list(APPEND compile_options "-Wthread-safety") - # list(APPEND compile_options "-Wglobal-constructors") - # endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + list(APPEND compile_options "-Wstrict-prototypes") + list(APPEND compile_options "-Wextra-semi") + list(APPEND compile_options "-Wnewline-eof") + list(APPEND compile_options "-Wnonportable-system-include-path") + list(APPEND compile_options "-Wthread-safety") + # list(APPEND compile_options "-Wglobal-constructors") + endif() endif() set(${output_var} ${compile_options} PARENT_SCOPE) endfunction() @@ -223,6 +223,8 @@ function(create_libc_unittest fq_target_name) _get_common_test_compile_options(compile_options "${LIBC_UNITTEST_C_TEST}" "${LIBC_UNITTEST_FLAGS}") + # TODO: Ideally we would have a separate function for link options. + set(link_options ${compile_options}) list(APPEND compile_options ${LIBC_UNITTEST_COMPILE_OPTIONS}) if(SHOW_INTERMEDIATE_OBJECTS) @@ -277,7 +279,7 @@ function(create_libc_unittest fq_target_name) target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options(${fq_build_target_name} PRIVATE ${compile_options}) - target_link_options(${fq_build_target_name} PRIVATE ${compile_options}) + target_link_options(${fq_build_target_name} PRIVATE ${link_options}) if(NOT LIBC_UNITTEST_CXX_STANDARD) set(LIBC_UNITTEST_CXX_STANDARD ${CMAKE_CXX_STANDARD}) @@ -558,14 +560,12 @@ function(add_integration_test test_name) if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU) target_link_options(${fq_build_target_name} PRIVATE ${LIBC_COMPILE_OPTIONS_DEFAULT} ${INTEGRATION_TEST_COMPILE_OPTIONS} - -Wno-multi-gpu -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto - "-Wl,-mllvm,-amdgpu-lower-global-ctor-dtor=0" -nostdlib -static + -Wno-multi-gpu -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto -nostdlib -static "-Wl,-mllvm,-amdhsa-code-object-version=${LIBC_GPU_CODE_OBJECT_VERSION}") elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX) target_link_options(${fq_build_target_name} PRIVATE ${LIBC_COMPILE_OPTIONS_DEFAULT} ${INTEGRATION_TEST_COMPILE_OPTIONS} "-Wl,--suppress-stack-size-warning" -Wno-multi-gpu - "-Wl,-mllvm,-nvptx-lower-global-ctor-dtor=1" "-Wl,-mllvm,-nvptx-emit-init-fini-kernel" -march=${LIBC_GPU_TARGET_ARCHITECTURE} -nostdlib -static "--cuda-path=${LIBC_CUDA_ROOT}") diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 81dceb74a1774..0a942516db6c3 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -647,6 +647,7 @@ endif() if(LIBC_TYPES_HAS_FLOAT16) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float16 entrypoints + libc.src.math.asinf16 libc.src.math.canonicalizef16 libc.src.math.ceilf16 libc.src.math.copysignf16 diff --git a/libc/docs/CMakeLists.txt b/libc/docs/CMakeLists.txt index 97f27fe6a6e0c..4ef0e920de683 100644 --- a/libc/docs/CMakeLists.txt +++ b/libc/docs/CMakeLists.txt @@ -59,6 +59,7 @@ if (SPHINX_FOUND) sys/mman sys/resource sys/stat + sys/statvfs sys/time sys/wait termios diff --git a/libc/docs/headers/index.rst b/libc/docs/headers/index.rst index 745b6f44750db..3dc30ef90a8e4 100644 --- a/libc/docs/headers/index.rst +++ b/libc/docs/headers/index.rst @@ -30,6 +30,7 @@ Implementation Status sys/mman sys/resource sys/stat + sys/statvfs sys/time sys/wait termios diff --git a/libc/docs/headers/math/index.rst b/libc/docs/headers/math/index.rst index 8548e4a5773bc..3e45e3e618abb 100644 --- a/libc/docs/headers/math/index.rst +++ b/libc/docs/headers/math/index.rst @@ -256,7 +256,7 @@ Higher Math Functions +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | acospi | | | | | | 7.12.4.8 | F.10.1.8 | +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| asin | |check| | | | | | 7.12.4.2 | F.10.1.2 | +| asin | |check| | | | |check| | | 7.12.4.2 | F.10.1.2 | +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | asinh | |check| | | | | | 7.12.5.2 | F.10.2.2 | +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt index dfc90009ef54a..84a2647ba664d 100644 --- a/libc/hdr/types/CMakeLists.txt +++ b/libc/hdr/types/CMakeLists.txt @@ -250,15 +250,6 @@ add_proxy_header_library( libc.include.locale ) -add_proxy_header_library( - sighandler_t - HDRS - sighandler_t.h - FULL_BUILD_DEPENDS - libc.include.llvm-libc-types.__sighandler_t - libc.include.signal -) - add_proxy_header_library( stack_t HDRS diff --git a/libc/hdr/types/sighandler_t.h b/libc/hdr/types/sighandler_t.h deleted file mode 100644 index bc40dd8b4c8f4..0000000000000 --- a/libc/hdr/types/sighandler_t.h +++ /dev/null @@ -1,24 +0,0 @@ -//===-- Definition of macros from __sighandler_t.h ------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_HDR_TYPES_SIGHANDLER_T_H -#define LLVM_LIBC_HDR_TYPES_SIGHANDLER_T_H - -#ifdef LIBC_FULL_BUILD - -#include "include/llvm-libc-types/__sighandler_t.h" - -using sighandler_t = __sighandler_t; - -#else // overlay mode - -#include - -#endif // LLVM_LIBC_FULL_BUILD - -#endif // LLVM_LIBC_HDR_TYPES_SIGHANDLER_T_H diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 63745542662d5..867bd1e5ee20f 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -284,13 +284,14 @@ add_header_macro( signal.h DEPENDS .llvm-libc-macros.signal_macros + .llvm-libc-types.pid_t .llvm-libc-types.sig_atomic_t + .llvm-libc-types.sighandler_t + .llvm-libc-types.siginfo_t .llvm-libc-types.sigset_t + .llvm-libc-types.stack_t .llvm-libc-types.struct_sigaction .llvm-libc-types.union_sigval - .llvm-libc-types.siginfo_t - .llvm-libc-types.stack_t - .llvm-libc-types.pid_t ) add_header_macro( diff --git a/libc/include/llvm-libc-macros/gpu/signal-macros.h b/libc/include/llvm-libc-macros/gpu/signal-macros.h index 2d8159240de8b..f0d49ea34fe0e 100644 --- a/libc/include/llvm-libc-macros/gpu/signal-macros.h +++ b/libc/include/llvm-libc-macros/gpu/signal-macros.h @@ -16,9 +16,9 @@ #define SIGSEGV 11 #define SIGTERM 15 -#define SIG_DFL ((__sighandler_t)(0)) -#define SIG_IGN ((__sighandler_t)(1)) -#define SIG_ERR ((__sighandler_t)(-1)) +#define SIG_DFL ((void (*)(int))(0)) +#define SIG_IGN ((void (*)(int))(1)) +#define SIG_ERR ((void (*)(int))(-1)) // Max signal number #define NSIG 64 diff --git a/libc/include/llvm-libc-macros/linux/signal-macros.h b/libc/include/llvm-libc-macros/linux/signal-macros.h index 0b7317ebc9b80..d220241a38206 100644 --- a/libc/include/llvm-libc-macros/linux/signal-macros.h +++ b/libc/include/llvm-libc-macros/linux/signal-macros.h @@ -86,9 +86,9 @@ #error "Signal stack sizes not defined for your platform." #endif -#define SIG_DFL ((__sighandler_t)0) -#define SIG_IGN ((__sighandler_t)1) -#define SIG_ERR ((__sighandler_t)-1) +#define SIG_DFL ((void (*)(int))0) +#define SIG_IGN ((void (*)(int))1) +#define SIG_ERR ((void (*)(int))(-1)) // SIGCHLD si_codes #define CLD_EXITED 1 // child has exited diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index 9e8d2f818d4ed..7ed69ab1af6d9 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -15,7 +15,6 @@ add_header(__pthread_start_t HDR __pthread_start_t.h) add_header(__pthread_tss_dtor_t HDR __pthread_tss_dtor_t.h) add_header(__qsortcompare_t HDR __qsortcompare_t.h) add_header(__qsortrcompare_t HDR __qsortrcompare_t.h) -add_header(__sighandler_t HDR __sighandler_t.h) add_header(__thread_type HDR __thread_type.h) add_header(blkcnt_t HDR blkcnt_t.h) add_header(blksize_t HDR blksize_t.h) @@ -66,6 +65,7 @@ if(LIBC_TYPES_TIME_T_IS_32_BIT) else() add_header(time_t HDR time_t_64.h DEST_HDR time_t.h) endif() +add_header(sighandler_t HDR sighandler_t.h) add_header(stack_t HDR stack_t.h DEPENDS .size_t) add_header(suseconds_t HDR suseconds_t.h) add_header(struct_dirent HDR struct_dirent.h DEPENDS .ino_t .off_t) diff --git a/libc/include/llvm-libc-types/__sighandler_t.h b/libc/include/llvm-libc-types/sighandler_t.h similarity index 52% rename from libc/include/llvm-libc-types/__sighandler_t.h rename to libc/include/llvm-libc-types/sighandler_t.h index 9c1ac997fc4ee..f39ab04685200 100644 --- a/libc/include/llvm-libc-types/__sighandler_t.h +++ b/libc/include/llvm-libc-types/sighandler_t.h @@ -1,4 +1,4 @@ -//===-- Definition of struct __sighandler_t -------------------------------===// +//===-- Definition of sighandler_t ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,9 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_TYPES___SIGHANDLER_T_H -#define LLVM_LIBC_TYPES___SIGHANDLER_T_H +#ifndef LLVM_LIBC_TYPES_SIGHANDLER_T_H +#define LLVM_LIBC_TYPES_SIGHANDLER_T_H -typedef void (*__sighandler_t)(int); +#ifdef __linux__ +// For compatibility with glibc. +typedef void (*sighandler_t)(int); +#endif -#endif // LLVM_LIBC_TYPES___SIGHANDLER_T_H +#endif // LLVM_LIBC_TYPES_SIGHANDLER_T_H diff --git a/libc/include/llvm-libc-types/struct_sigaction.h b/libc/include/llvm-libc-types/struct_sigaction.h index b4d0c965a4c63..907418b5e0f9a 100644 --- a/libc/include/llvm-libc-types/struct_sigaction.h +++ b/libc/include/llvm-libc-types/struct_sigaction.h @@ -25,6 +25,4 @@ struct sigaction { #endif }; -typedef void (*__sighandler_t)(int); - #endif // LLVM_LIBC_TYPES_STRUCT_SIGACTION_H diff --git a/libc/include/math.yaml b/libc/include/math.yaml index 3a660a59d3605..b98bc55f6cc53 100644 --- a/libc/include/math.yaml +++ b/libc/include/math.yaml @@ -32,6 +32,13 @@ functions: return_type: float arguments: - type: float + - name: asinf16 + standards: + - stdc + return_type: _Float16 + arguments: + - type: _Float16 + guard: LIBC_TYPES_HAS_FLOAT16 - name: asinhf standards: - stdc diff --git a/libc/include/signal.yaml b/libc/include/signal.yaml index 576e77576ac74..6fdd8c97ccbe2 100644 --- a/libc/include/signal.yaml +++ b/libc/include/signal.yaml @@ -3,12 +3,13 @@ header_template: signal.h.def macros: [] types: - type_name: pid_t - - type_name: stack_t + - type_name: sig_atomic_t + - type_name: sighandler_t - type_name: siginfo_t - - type_name: struct_sigaction - type_name: sigset_t + - type_name: stack_t + - type_name: struct_sigaction - type_name: union_sigval - - type_name: sig_atomic_t enums: [] objects: [] functions: @@ -69,10 +70,15 @@ functions: - name: signal standards: - stdc - return_type: __sighandler_t + # May the Geneva Convention have mercy on my soul... Why this insanity? + # Well: signal returns a function pointer to a function with no return + # value and which accepts an int. The parameter list appears on the far + # right of the declaration. i.e. + # void (*signal(int, void (*)(int)))(int); + return_type: void (* arguments: - type: int - - type: __sighandler_t + - type: void (*)(int)))(int - name: sigprocmask standards: - POSIX diff --git a/libc/src/complex/generic/CMakeLists.txt b/libc/src/complex/generic/CMakeLists.txt index 82d2b01d534a9..f1c21e4ed7271 100644 --- a/libc/src/complex/generic/CMakeLists.txt +++ b/libc/src/complex/generic/CMakeLists.txt @@ -4,8 +4,6 @@ add_entrypoint_object( cproj.cpp HDRS ../cproj.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -16,8 +14,6 @@ add_entrypoint_object( cprojf.cpp HDRS ../cprojf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -28,8 +24,6 @@ add_entrypoint_object( cprojl.cpp HDRS ../cprojl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -40,8 +34,6 @@ add_entrypoint_object( cprojf16.cpp HDRS ../cprojf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops libc.src.__support.macros.properties.types @@ -54,8 +46,6 @@ add_entrypoint_object( cprojf128.cpp HDRS ../cprojf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops libc.src.__support.macros.properties.types @@ -68,8 +58,6 @@ add_entrypoint_object( conj.cpp HDRS ../conj.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -80,8 +68,6 @@ add_entrypoint_object( conjf.cpp HDRS ../conjf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -92,8 +78,6 @@ add_entrypoint_object( conjl.cpp HDRS ../conjl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops ) @@ -104,8 +88,6 @@ add_entrypoint_object( conjf16.cpp HDRS ../conjf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops libc.src.__support.macros.properties.types @@ -118,8 +100,6 @@ add_entrypoint_object( conjf128.cpp HDRS ../conjf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.complex_basic_ops libc.src.__support.macros.properties.types @@ -132,8 +112,6 @@ add_entrypoint_object( creal.cpp HDRS ../creal.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -145,8 +123,6 @@ add_entrypoint_object( crealf.cpp HDRS ../crealf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -158,8 +134,6 @@ add_entrypoint_object( creall.cpp HDRS ../creall.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -171,8 +145,6 @@ add_entrypoint_object( crealf16.cpp HDRS ../crealf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -186,8 +158,6 @@ add_entrypoint_object( crealf128.cpp HDRS ../crealf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -201,8 +171,6 @@ add_entrypoint_object( cimag.cpp HDRS ../cimag.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -214,8 +182,6 @@ add_entrypoint_object( cimagf.cpp HDRS ../cimagf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -227,8 +193,6 @@ add_entrypoint_object( cimagl.cpp HDRS ../cimagl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -240,8 +204,6 @@ add_entrypoint_object( cimagf16.cpp HDRS ../cimagf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type @@ -255,8 +217,6 @@ add_entrypoint_object( cimagf128.cpp HDRS ../cimagf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.CPP.bit libc.src.__support.complex_type diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index fe5ebd793b40a..82551a4b57f45 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -47,6 +47,8 @@ add_math_entrypoint_object(acoshf) add_math_entrypoint_object(asin) add_math_entrypoint_object(asinf) +add_math_entrypoint_object(asinf16) + add_math_entrypoint_object(asinh) add_math_entrypoint_object(asinhf) diff --git a/libc/src/math/asinf16.h b/libc/src/math/asinf16.h new file mode 100644 index 0000000000000..f16647ec2a6f9 --- /dev/null +++ b/libc/src/math/asinf16.h @@ -0,0 +1,21 @@ +//===-- Implementation header for asinf16 -----------------------*- 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. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_ASINF16_H +#define LLVM_LIBC_SRC_MATH_ASINF16_H + +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +float16 asinf16(float16 x); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_ASINF16_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 0e57051807b33..9faf46d491426 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -6,8 +6,6 @@ add_entrypoint_object( canonicalize.cpp HDRS ../canonicalize.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -18,8 +16,6 @@ add_entrypoint_object( canonicalizef.cpp HDRS ../canonicalizef.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -30,8 +26,6 @@ add_entrypoint_object( canonicalizef16.cpp HDRS ../canonicalizef16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations @@ -43,8 +37,6 @@ add_entrypoint_object( canonicalizef128.cpp HDRS ../canonicalizef128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations @@ -56,8 +48,6 @@ add_entrypoint_object( canonicalizel.cpp HDRS ../canonicalizel.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -68,8 +58,6 @@ add_entrypoint_object( iscanonical.cpp HDRS ../iscanonical.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -78,8 +66,6 @@ add_entrypoint_object( iscanonicalf.cpp HDRS ../iscanonicalf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -88,8 +74,6 @@ add_entrypoint_object( iscanonicall.cpp HDRS ../iscanonicall.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -98,8 +82,6 @@ add_entrypoint_object( iscanonicalf16.cpp HDRS ../iscanonicalf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types ) @@ -110,8 +92,6 @@ add_entrypoint_object( iscanonicalf128.cpp HDRS ../iscanonicalf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types ) @@ -122,8 +102,6 @@ add_entrypoint_object( ceil.cpp HDRS ../ceil.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -136,8 +114,6 @@ add_entrypoint_object( ceilf.cpp HDRS ../ceilf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -150,8 +126,6 @@ add_entrypoint_object( ceill.cpp HDRS ../ceill.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -162,8 +136,6 @@ add_entrypoint_object( ceilf16.cpp HDRS ../ceilf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.cast libc.src.__support.FPUtil.nearest_integer_operations @@ -179,8 +151,6 @@ add_entrypoint_object( ceilf128.cpp HDRS ../ceilf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -192,8 +162,6 @@ add_entrypoint_object( daddl.cpp HDRS ../daddl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.generic.add_sub ) @@ -204,8 +172,6 @@ add_entrypoint_object( daddf128.cpp HDRS ../daddf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub @@ -217,8 +183,6 @@ add_entrypoint_object( ddivl.cpp HDRS ../ddivl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.generic.div ) @@ -229,8 +193,6 @@ add_entrypoint_object( ddivf128.cpp HDRS ../ddivf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div @@ -245,8 +207,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.FPUtil.fma libc.src.__support.macros.properties.types - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -257,8 +217,6 @@ add_entrypoint_object( ../dfmal.h DEPENDS libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -269,8 +227,6 @@ add_entrypoint_object( ../dsqrtl.h DEPENDS libc.src.__support.FPUtil.generic.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -282,8 +238,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) @@ -296,8 +250,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.FPUtil.generic.add_sub libc.src.__support.macros.properties.types - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -308,8 +260,6 @@ add_entrypoint_object( ../dsubl.h DEPENDS libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_header_library( @@ -392,8 +342,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fenv_impl libc.src.__support.FPUtil.fp_bits libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -413,8 +361,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -449,8 +395,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -468,8 +412,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -490,8 +432,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -512,8 +452,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -534,7 +472,7 @@ add_entrypoint_object( libc.src.__support.macros.optimization libc.src.__support.macros.properties.types COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_entrypoint_object( @@ -555,8 +493,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -574,8 +510,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.common libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -595,8 +529,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -614,8 +546,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -635,8 +565,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -657,8 +585,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -696,8 +622,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.except_value_utils libc.src.__support.FPUtil.multiply_add libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -708,8 +632,6 @@ add_entrypoint_object( ../fabs.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -722,8 +644,6 @@ add_entrypoint_object( ../fabsf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -736,8 +656,6 @@ add_entrypoint_object( ../fabsl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -751,8 +669,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.basic_operations libc.src.__support.macros.properties.architectures libc.src.__support.macros.properties.compiler - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -766,8 +682,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -778,8 +692,6 @@ add_entrypoint_object( ../fadd.h DEPENDS libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -790,8 +702,6 @@ add_entrypoint_object( ../faddl.h DEPENDS libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -803,8 +713,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.FPUtil.generic.add_sub libc.src.__support.macros.properties.types - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -813,8 +721,6 @@ add_entrypoint_object( trunc.cpp HDRS ../trunc.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -827,8 +733,6 @@ add_entrypoint_object( truncf.cpp HDRS ../truncf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -841,8 +745,6 @@ add_entrypoint_object( truncl.cpp HDRS ../truncl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -853,8 +755,6 @@ add_entrypoint_object( truncf16.cpp HDRS ../truncf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.cast libc.src.__support.FPUtil.nearest_integer_operations @@ -870,8 +770,6 @@ add_entrypoint_object( truncf128.cpp HDRS ../truncf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -883,8 +781,6 @@ add_entrypoint_object( floor.cpp HDRS ../floor.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -897,8 +793,6 @@ add_entrypoint_object( floorf.cpp HDRS ../floorf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -911,8 +805,6 @@ add_entrypoint_object( floorl.cpp HDRS ../floorl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -923,8 +815,6 @@ add_entrypoint_object( floorf16.cpp HDRS ../floorf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.cast libc.src.__support.FPUtil.nearest_integer_operations @@ -940,8 +830,6 @@ add_entrypoint_object( floorf128.cpp HDRS ../floorf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -953,8 +841,6 @@ add_entrypoint_object( round.cpp HDRS ../round.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -967,8 +853,6 @@ add_entrypoint_object( roundf.cpp HDRS ../roundf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -981,8 +865,6 @@ add_entrypoint_object( roundl.cpp HDRS ../roundl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -993,8 +875,6 @@ add_entrypoint_object( roundf16.cpp HDRS ../roundf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.cast libc.src.__support.FPUtil.nearest_integer_operations @@ -1010,8 +890,6 @@ add_entrypoint_object( roundf128.cpp HDRS ../roundf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1023,8 +901,6 @@ add_entrypoint_object( roundeven.cpp HDRS ../roundeven.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -1037,8 +913,6 @@ add_entrypoint_object( roundevenf.cpp HDRS ../roundevenf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -1051,8 +925,6 @@ add_entrypoint_object( roundevenl.cpp HDRS ../roundevenl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1063,8 +935,6 @@ add_entrypoint_object( roundevenf16.cpp HDRS ../roundevenf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1080,8 +950,6 @@ add_entrypoint_object( roundevenf128.cpp HDRS ../roundevenf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1093,8 +961,6 @@ add_entrypoint_object( lround.cpp HDRS ../lround.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1105,8 +971,6 @@ add_entrypoint_object( lroundf.cpp HDRS ../lroundf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1117,8 +981,6 @@ add_entrypoint_object( lroundl.cpp HDRS ../lroundl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1129,8 +991,6 @@ add_entrypoint_object( lroundf16.cpp HDRS ../lroundf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1142,8 +1002,6 @@ add_entrypoint_object( lroundf128.cpp HDRS ../lroundf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1155,8 +1013,6 @@ add_entrypoint_object( llround.cpp HDRS ../llround.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1167,8 +1023,6 @@ add_entrypoint_object( llroundf.cpp HDRS ../llroundf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1179,8 +1033,6 @@ add_entrypoint_object( llroundl.cpp HDRS ../llroundl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1191,8 +1043,6 @@ add_entrypoint_object( llroundf16.cpp HDRS ../llroundf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1204,8 +1054,6 @@ add_entrypoint_object( llroundf128.cpp HDRS ../llroundf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1217,8 +1065,6 @@ add_entrypoint_object( rint.cpp HDRS ../rint.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -1231,8 +1077,6 @@ add_entrypoint_object( rintf.cpp HDRS ../rintf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations FLAGS @@ -1245,8 +1089,6 @@ add_entrypoint_object( rintl.cpp HDRS ../rintl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1257,8 +1099,6 @@ add_entrypoint_object( rintf16.cpp HDRS ../rintf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.cast libc.src.__support.FPUtil.nearest_integer_operations @@ -1274,8 +1114,6 @@ add_entrypoint_object( rintf128.cpp HDRS ../rintf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1287,8 +1125,6 @@ add_entrypoint_object( lrint.cpp HDRS ../lrint.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1299,8 +1135,6 @@ add_entrypoint_object( lrintf.cpp HDRS ../lrintf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1311,8 +1145,6 @@ add_entrypoint_object( lrintl.cpp HDRS ../lrintl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1323,8 +1155,6 @@ add_entrypoint_object( lrintf16.cpp HDRS ../lrintf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1336,8 +1166,6 @@ add_entrypoint_object( lrintf128.cpp HDRS ../lrintf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1349,8 +1177,6 @@ add_entrypoint_object( llrint.cpp HDRS ../llrint.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1361,8 +1187,6 @@ add_entrypoint_object( llrintf.cpp HDRS ../llrintf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1373,8 +1197,6 @@ add_entrypoint_object( llrintl.cpp HDRS ../llrintl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.nearest_integer_operations ) @@ -1385,8 +1207,6 @@ add_entrypoint_object( llrintf16.cpp HDRS ../llrintf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1398,8 +1218,6 @@ add_entrypoint_object( llrintf128.cpp HDRS ../llrintf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations @@ -1413,8 +1231,6 @@ add_entrypoint_object( ../nearbyint.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1425,8 +1241,6 @@ add_entrypoint_object( ../nearbyintf.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1437,8 +1251,6 @@ add_entrypoint_object( ../nearbyintl.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1450,8 +1262,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1463,8 +1273,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_object_library( @@ -1488,8 +1296,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1514,8 +1320,6 @@ add_entrypoint_object( libc.src.__support.integer_literals libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1535,8 +1339,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1559,8 +1361,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1585,8 +1385,6 @@ add_entrypoint_object( libc.src.__support.integer_literals libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_header_library( @@ -1615,8 +1413,6 @@ add_entrypoint_object( ../exp2f.h DEPENDS .exp2f_impl - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1635,8 +1431,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1657,8 +1451,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1681,8 +1473,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1707,8 +1497,6 @@ add_entrypoint_object( libc.src.__support.integer_literals libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_header_library( @@ -1724,8 +1512,6 @@ add_header_library( libc.src.__support.macros.optimization libc.src.__support.common libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1736,8 +1522,6 @@ add_entrypoint_object( ../exp10f.h DEPENDS .exp10f_impl - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1761,8 +1545,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1782,8 +1564,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1805,8 +1585,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1831,8 +1609,6 @@ add_entrypoint_object( libc.src.__support.integer_literals libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1852,8 +1628,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1874,8 +1648,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1901,8 +1673,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.triple_double libc.src.__support.macros.optimization libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1924,8 +1694,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1936,8 +1704,6 @@ add_entrypoint_object( ../copysign.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -1950,8 +1716,6 @@ add_entrypoint_object( ../copysignf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -1964,8 +1728,6 @@ add_entrypoint_object( ../copysignl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -1977,8 +1739,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -1992,8 +1752,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2002,8 +1760,6 @@ add_entrypoint_object( frexp.cpp HDRS ../frexp.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2014,8 +1770,6 @@ add_entrypoint_object( frexpf.cpp HDRS ../frexpf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2026,8 +1780,6 @@ add_entrypoint_object( frexpl.cpp HDRS ../frexpl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2038,8 +1790,6 @@ add_entrypoint_object( frexpf16.cpp HDRS ../frexpf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2051,8 +1801,6 @@ add_entrypoint_object( frexpf128.cpp HDRS ../frexpf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2064,8 +1812,6 @@ add_entrypoint_object( ilogb.cpp HDRS ../ilogb.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2076,8 +1822,6 @@ add_entrypoint_object( ilogbf.cpp HDRS ../ilogbf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2088,8 +1832,6 @@ add_entrypoint_object( ilogbl.cpp HDRS ../ilogbl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2100,8 +1842,6 @@ add_entrypoint_object( ilogbf16.cpp HDRS ../ilogbf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2113,8 +1853,6 @@ add_entrypoint_object( ilogbf128.cpp HDRS ../ilogbf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2126,8 +1864,6 @@ add_entrypoint_object( llogb.cpp HDRS ../llogb.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2138,8 +1874,6 @@ add_entrypoint_object( llogbf.cpp HDRS ../llogbf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2150,8 +1884,6 @@ add_entrypoint_object( llogbl.cpp HDRS ../llogbl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2162,8 +1894,6 @@ add_entrypoint_object( llogbf16.cpp HDRS ../llogbf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2175,8 +1905,6 @@ add_entrypoint_object( llogbf128.cpp HDRS ../llogbf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2188,8 +1916,6 @@ add_entrypoint_object( ldexp.cpp HDRS ../ldexp.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2200,8 +1926,6 @@ add_entrypoint_object( ldexpf.cpp HDRS ../ldexpf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2212,8 +1936,6 @@ add_entrypoint_object( ldexpl.cpp HDRS ../ldexpl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2224,8 +1946,6 @@ add_entrypoint_object( ldexpf16.cpp HDRS ../ldexpf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2237,8 +1957,6 @@ add_entrypoint_object( ldexpf128.cpp HDRS ../ldexpf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2282,8 +2000,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.integer_literals libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2299,8 +2015,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.polyeval - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2321,8 +2035,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2341,8 +2053,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.integer_literals libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2359,8 +2069,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2380,8 +2088,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.integer_literals libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2398,8 +2104,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2420,8 +2124,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2441,8 +2143,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.integer_literals libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2459,8 +2159,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2481,8 +2179,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization libc.src.__support.macros.properties.cpu_features - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2491,8 +2187,6 @@ add_entrypoint_object( logb.cpp HDRS ../logb.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2503,8 +2197,6 @@ add_entrypoint_object( logbf.cpp HDRS ../logbf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2515,8 +2207,6 @@ add_entrypoint_object( logbl.cpp HDRS ../logbl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.manipulation_functions ) @@ -2527,8 +2217,6 @@ add_entrypoint_object( logbf16.cpp HDRS ../logbf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2540,8 +2228,6 @@ add_entrypoint_object( logbf128.cpp HDRS ../logbf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions @@ -2555,8 +2241,6 @@ add_entrypoint_object( ../modf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2567,8 +2251,6 @@ add_entrypoint_object( ../modff.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2579,8 +2261,6 @@ add_entrypoint_object( ../modfl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2592,8 +2272,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2605,8 +2283,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2617,8 +2293,6 @@ add_entrypoint_object( ../fmin.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2631,8 +2305,6 @@ add_entrypoint_object( ../fminf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2645,8 +2317,6 @@ add_entrypoint_object( ../fminl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2658,8 +2328,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2671,8 +2339,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2686,8 +2352,6 @@ add_entrypoint_object( ../fmax.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2700,8 +2364,6 @@ add_entrypoint_object( ../fmaxf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2714,8 +2376,6 @@ add_entrypoint_object( ../fmaxl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2727,8 +2387,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2740,8 +2398,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2754,8 +2410,6 @@ add_entrypoint_object( ../fmaximum.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2768,8 +2422,6 @@ add_entrypoint_object( ../fmaximumf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2782,8 +2434,6 @@ add_entrypoint_object( ../fmaximuml.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2795,8 +2445,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2810,8 +2458,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2822,8 +2468,6 @@ add_entrypoint_object( ../fmaximum_num.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2836,8 +2480,6 @@ add_entrypoint_object( ../fmaximum_numf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2850,8 +2492,6 @@ add_entrypoint_object( ../fmaximum_numl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2863,8 +2503,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -2878,8 +2516,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2927,8 +2563,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2940,8 +2574,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -2989,8 +2621,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3002,8 +2632,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3014,8 +2642,6 @@ add_entrypoint_object( ../fminimum.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3028,8 +2654,6 @@ add_entrypoint_object( ../fminimumf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3042,8 +2666,6 @@ add_entrypoint_object( ../fminimuml.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3055,8 +2677,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3070,8 +2690,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3082,8 +2700,6 @@ add_entrypoint_object( ../fminimum_num.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3096,8 +2712,6 @@ add_entrypoint_object( ../fminimum_numf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3110,8 +2724,6 @@ add_entrypoint_object( ../fminimum_numl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3123,8 +2735,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} FLAGS MISC_MATH_BASIC_OPS_OPT ) @@ -3138,8 +2748,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3187,8 +2795,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3200,8 +2806,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3249,8 +2853,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3262,8 +2864,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3276,8 +2876,6 @@ add_entrypoint_object( libc.hdr.errno_macros libc.hdr.fenv_macros libc.src.__support.FPUtil.double_double - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3288,8 +2886,6 @@ add_entrypoint_object( ../fmull.h DEPENDS libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3301,8 +2897,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3313,8 +2907,6 @@ add_entrypoint_object( ../fsub.h DEPENDS libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3325,8 +2917,6 @@ add_entrypoint_object( ../fsubl.h DEPENDS libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3338,8 +2928,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3350,8 +2938,6 @@ add_entrypoint_object( ../sqrt.h DEPENDS libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) @@ -3363,8 +2949,6 @@ add_entrypoint_object( ../sqrtf.h DEPENDS libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3375,8 +2959,6 @@ add_entrypoint_object( ../sqrtl.h DEPENDS libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3387,8 +2969,6 @@ add_entrypoint_object( ../sqrtf16.h DEPENDS libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3400,8 +2980,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3412,8 +2990,6 @@ add_entrypoint_object( ../remquof.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3424,8 +3000,6 @@ add_entrypoint_object( ../remquof128.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3436,8 +3010,6 @@ add_entrypoint_object( ../remquo.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3448,8 +3020,6 @@ add_entrypoint_object( ../remquol.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3461,8 +3031,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3473,8 +3041,6 @@ add_entrypoint_object( ../remainderf.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3485,8 +3051,6 @@ add_entrypoint_object( ../remainder.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3497,8 +3061,6 @@ add_entrypoint_object( ../remainderl.h DEPENDS libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3510,8 +3072,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3523,8 +3083,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.division_and_remainder_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3540,8 +3098,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3550,8 +3106,6 @@ add_entrypoint_object( fdim.cpp HDRS ../fdim.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -3562,8 +3116,6 @@ add_entrypoint_object( fdimf.cpp HDRS ../fdimf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -3574,8 +3126,6 @@ add_entrypoint_object( fdiml.cpp HDRS ../fdiml.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.basic_operations ) @@ -3586,8 +3136,6 @@ add_entrypoint_object( fdimf16.cpp HDRS ../fdimf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations @@ -3599,8 +3147,6 @@ add_entrypoint_object( fdimf128.cpp HDRS ../fdimf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations @@ -3612,8 +3158,6 @@ add_entrypoint_object( fdiv.cpp HDRS ../fdiv.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.generic.div ) @@ -3624,8 +3168,6 @@ add_entrypoint_object( fdivl.cpp HDRS ../fdivl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.generic.div ) @@ -3636,8 +3178,6 @@ add_entrypoint_object( fdivf128.cpp HDRS ../fdivf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div @@ -3649,8 +3189,6 @@ add_entrypoint_object( ffma.cpp HDRS ../ffma.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.fma ) @@ -3661,8 +3199,6 @@ add_entrypoint_object( ffmal.cpp HDRS ../ffmal.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.FPUtil.fma ) @@ -3673,8 +3209,6 @@ add_entrypoint_object( ffmaf128.cpp HDRS ../ffmaf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.fma @@ -3688,8 +3222,6 @@ add_entrypoint_object( ../hypot.h DEPENDS libc.src.__support.FPUtil.hypot - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3698,8 +3230,6 @@ add_entrypoint_object( issignaling.cpp HDRS ../issignaling.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3708,8 +3238,6 @@ add_entrypoint_object( issignalingf.cpp HDRS ../issignalingf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3718,8 +3246,6 @@ add_entrypoint_object( issignalingl.cpp HDRS ../issignalingl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3728,8 +3254,6 @@ add_entrypoint_object( issignalingf16.cpp HDRS ../issignalingf16.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types ) @@ -3740,8 +3264,6 @@ add_entrypoint_object( issignalingf128.cpp HDRS ../issignalingf128.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.macros.properties.types ) @@ -3752,8 +3274,6 @@ add_entrypoint_object( isnan.cpp HDRS ../isnan.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3762,8 +3282,6 @@ add_entrypoint_object( isnanf.cpp HDRS ../isnanf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3772,8 +3290,6 @@ add_entrypoint_object( isnanl.cpp HDRS ../isnanl.h - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3785,8 +3301,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.str_to_float libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3798,8 +3312,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.str_to_float libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3811,8 +3323,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.str_to_float libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3824,8 +3334,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.str_to_float libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3837,8 +3345,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.str_to_float libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3849,8 +3355,6 @@ add_entrypoint_object( ../nextafter.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3861,8 +3365,6 @@ add_entrypoint_object( ../nextafterf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3873,8 +3375,6 @@ add_entrypoint_object( ../nextafterl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3886,8 +3386,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3899,8 +3397,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3911,8 +3407,6 @@ add_entrypoint_object( ../nexttoward.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3923,8 +3417,6 @@ add_entrypoint_object( ../nexttowardf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3935,8 +3427,6 @@ add_entrypoint_object( ../nexttowardl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3948,8 +3438,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3960,8 +3448,6 @@ add_entrypoint_object( ../nextdown.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3972,8 +3458,6 @@ add_entrypoint_object( ../nextdownl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3984,8 +3468,6 @@ add_entrypoint_object( ../nextdownf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -3997,8 +3479,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4010,8 +3490,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4022,8 +3500,6 @@ add_entrypoint_object( ../nextup.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4034,8 +3510,6 @@ add_entrypoint_object( ../nextupl.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4046,8 +3520,6 @@ add_entrypoint_object( ../nextupf.h DEPENDS libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4059,8 +3531,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4072,8 +3542,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4084,8 +3552,6 @@ add_entrypoint_object( ../fmod.h DEPENDS libc.src.__support.FPUtil.generic.fmod - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4096,8 +3562,6 @@ add_entrypoint_object( ../fmodf.h DEPENDS libc.src.__support.FPUtil.generic.fmod - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4108,8 +3572,6 @@ add_entrypoint_object( ../fmodl.h DEPENDS libc.src.__support.FPUtil.generic.fmod - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4121,8 +3583,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.fmod - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4134,8 +3594,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.fmod - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4146,8 +3604,6 @@ add_entrypoint_object( ../fromfp.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4158,8 +3614,6 @@ add_entrypoint_object( ../fromfpf.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4170,8 +3624,6 @@ add_entrypoint_object( ../fromfpl.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4183,8 +3635,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4196,8 +3646,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4208,8 +3656,6 @@ add_entrypoint_object( ../fromfpx.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4220,8 +3666,6 @@ add_entrypoint_object( ../fromfpxf.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4232,8 +3676,6 @@ add_entrypoint_object( ../fromfpxl.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4245,8 +3687,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4258,8 +3698,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4270,8 +3708,6 @@ add_entrypoint_object( ../ufromfp.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4282,8 +3718,6 @@ add_entrypoint_object( ../ufromfpf.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4294,8 +3728,6 @@ add_entrypoint_object( ../ufromfpl.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4307,8 +3739,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4320,8 +3750,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4332,8 +3760,6 @@ add_entrypoint_object( ../ufromfpx.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4344,8 +3770,6 @@ add_entrypoint_object( ../ufromfpxf.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4356,8 +3780,6 @@ add_entrypoint_object( ../ufromfpxl.h DEPENDS libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4369,8 +3791,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4382,8 +3802,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.nearest_integer_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) #TODO: Add errno include to the hyperbolic functions. @@ -4406,8 +3824,6 @@ add_object_library( libc.src.__support.FPUtil.polyeval libc.src.__support.common libc.src.errno.errno - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4422,8 +3838,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4441,8 +3855,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4456,8 +3868,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4475,8 +3885,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4492,8 +3900,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4515,8 +3921,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4533,8 +3937,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4550,8 +3952,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4564,8 +3964,6 @@ add_entrypoint_object( .explogxf libc.src.__support.FPUtil.fp_bits libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_object_library( @@ -4594,8 +3992,25 @@ add_entrypoint_object( libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization .inv_trigf_utils - COMPILE_OPTIONS - ${libc_opt_high_flag} +) + +add_entrypoint_object( + asinf16 + SRCS + asinf16.cpp + HDRS + ../asinf16.h + DEPENDS + libc.hdr.errno_macros + libc.hdr.fenv_macros + libc.src.__support.FPUtil.cast + libc.src.__support.FPUtil.fenv_impl + libc.src.__support.FPUtil.fp_bits + libc.src.__support.FPUtil.multiply_add + libc.src.__support.FPUtil.polyeval + libc.src.__support.FPUtil.sqrt + libc.src.__support.macros.optimization + libc.src.__support.macros.properties.types ) add_entrypoint_object( @@ -4612,8 +4027,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.sqrt libc.src.__support.macros.optimization .inv_trigf_utils - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4631,8 +4044,6 @@ add_entrypoint_object( libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.rounding_mode libc.src.__support.macros.optimization - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4641,8 +4052,6 @@ add_entrypoint_object( atan2f.cpp HDRS ../atan2f.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS .inv_trigf_utils libc.src.__support.FPUtil.fp_bits @@ -4659,8 +4068,6 @@ add_entrypoint_object( atan2.cpp HDRS ../atan2.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS .inv_trigf_utils libc.src.__support.FPUtil.double_double @@ -4679,8 +4086,6 @@ add_entrypoint_object( atan2l.cpp HDRS ../atan2l.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS .atan2 ) @@ -4694,8 +4099,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4707,8 +4110,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4720,8 +4121,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4734,8 +4133,6 @@ add_entrypoint_object( libc.hdr.float_macros libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4748,8 +4145,6 @@ add_entrypoint_object( libc.hdr.float_macros libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4761,8 +4156,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4774,8 +4167,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4787,8 +4178,6 @@ add_entrypoint_object( DEPENDS libc.hdr.float_macros libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4801,8 +4190,6 @@ add_entrypoint_object( libc.hdr.float_macros libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4815,8 +4202,6 @@ add_entrypoint_object( libc.hdr.float_macros libc.src.__support.macros.properties.types libc.src.__support.FPUtil.manipulation_functions - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4827,8 +4212,6 @@ add_entrypoint_object( ../fmaf.h DEPENDS libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4839,8 +4222,6 @@ add_entrypoint_object( ../fma.h DEPENDS libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4851,8 +4232,6 @@ add_entrypoint_object( ../totalorder.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4863,8 +4242,6 @@ add_entrypoint_object( ../totalorderf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4875,8 +4252,6 @@ add_entrypoint_object( ../totalorderl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4887,8 +4262,6 @@ add_entrypoint_object( ../totalorderf16.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4900,8 +4273,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.FPUtil.basic_operations libc.src.__support.macros.properties.types - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( totalordermag @@ -4911,8 +4282,6 @@ add_entrypoint_object( ../totalordermag.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4923,8 +4292,6 @@ add_entrypoint_object( ../totalordermagf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4935,8 +4302,6 @@ add_entrypoint_object( ../totalordermagl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4947,8 +4312,6 @@ add_entrypoint_object( ../totalordermagf16.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4960,8 +4323,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.FPUtil.basic_operations libc.src.__support.macros.properties.types - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4972,8 +4333,6 @@ add_entrypoint_object( ../getpayload.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4984,8 +4343,6 @@ add_entrypoint_object( ../getpayloadf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -4996,8 +4353,6 @@ add_entrypoint_object( ../getpayloadl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5009,8 +4364,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5022,8 +4375,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5034,8 +4385,6 @@ add_entrypoint_object( ../setpayload.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5046,8 +4395,6 @@ add_entrypoint_object( ../setpayloadf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5058,8 +4405,6 @@ add_entrypoint_object( ../setpayloadl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5071,8 +4416,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5084,8 +4427,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5096,8 +4437,6 @@ add_entrypoint_object( ../setpayloadsig.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5108,8 +4447,6 @@ add_entrypoint_object( ../setpayloadsigf.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5120,8 +4457,6 @@ add_entrypoint_object( ../setpayloadsigl.h DEPENDS libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5133,8 +4468,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5146,8 +4479,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.basic_operations - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5159,8 +4490,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5172,8 +4501,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5185,8 +4512,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5198,8 +4523,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5211,8 +4534,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5224,8 +4545,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5237,8 +4556,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5250,8 +4567,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.add_sub - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5263,8 +4578,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5276,8 +4589,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5289,8 +4600,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5302,8 +4611,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.div - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5315,8 +4622,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5328,8 +4633,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5341,8 +4644,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5354,8 +4655,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.fma - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5367,8 +4666,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5380,8 +4677,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5393,8 +4688,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5406,8 +4699,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5418,8 +4709,6 @@ add_entrypoint_object( ../fsqrt.h DEPENDS libc.src.__support.FPUtil.generic.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5430,8 +4719,6 @@ add_entrypoint_object( ../fsqrtl.h DEPENDS libc.src.__support.FPUtil.generic.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5443,8 +4730,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.sqrt - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5453,8 +4738,6 @@ add_entrypoint_object( cbrtf.cpp HDRS ../cbrtf.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.hdr.fenv_macros libc.src.__support.FPUtil.fenv_impl @@ -5469,8 +4752,6 @@ add_entrypoint_object( cbrt.cpp HDRS ../cbrt.h - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.hdr.fenv_macros libc.src.__support.FPUtil.double_double @@ -5491,8 +4772,6 @@ add_entrypoint_object( ../dmull.h DEPENDS libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5504,8 +4783,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5517,8 +4794,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5530,8 +4805,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5543,8 +4816,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_entrypoint_object( @@ -5556,8 +4827,6 @@ add_entrypoint_object( DEPENDS libc.src.__support.macros.properties.types libc.src.__support.FPUtil.generic.mul - COMPILE_OPTIONS - ${libc_opt_high_flag} ) add_header_library( diff --git a/libc/src/math/generic/asinf16.cpp b/libc/src/math/generic/asinf16.cpp new file mode 100644 index 0000000000000..518c384a61530 --- /dev/null +++ b/libc/src/math/generic/asinf16.cpp @@ -0,0 +1,133 @@ +//===-- Half-precision asinf16(x) function --------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include "src/math/asinf16.h" +#include "hdr/errno_macros.h" +#include "hdr/fenv_macros.h" +#include "src/__support/FPUtil/FEnvImpl.h" +#include "src/__support/FPUtil/FPBits.h" +#include "src/__support/FPUtil/PolyEval.h" +#include "src/__support/FPUtil/cast.h" +#include "src/__support/FPUtil/multiply_add.h" +#include "src/__support/FPUtil/sqrt.h" +#include "src/__support/macros/optimization.h" + +namespace LIBC_NAMESPACE_DECL { + +// Generated by Sollya using the following command: +// > round(pi/2, D, RN); +static constexpr float PI_2 = 0x1.921fb54442d18p0f; + +LLVM_LIBC_FUNCTION(float16, asinf16, (float16 x)) { + using FPBits = fputil::FPBits; + FPBits xbits(x); + + uint16_t x_u = xbits.uintval(); + uint16_t x_abs = x_u & 0x7fff; + float xf = x; + + // |x| > 0x1p0, |x| > 1, or x is NaN. + if (LIBC_UNLIKELY(x_abs > 0x3c00)) { + // asinf16(NaN) = NaN + if (xbits.is_nan()) { + if (xbits.is_signaling_nan()) { + fputil::raise_except_if_required(FE_INVALID); + return FPBits::quiet_nan().get_val(); + } + + return x; + } + + // 1 < |x| <= +/-inf + fputil::raise_except_if_required(FE_INVALID); + fputil::set_errno_if_required(EDOM); + + return FPBits::quiet_nan().get_val(); + } + + float xsq = xf * xf; + + // |x| <= 0x1p-1, |x| <= 0.5 + if (x_abs <= 0x3800) { + // asinf16(+/-0) = +/-0 + if (LIBC_UNLIKELY(x_abs == 0)) + return x; + + // Exhaustive tests show that, + // for |x| <= 0x1.878p-9, when: + // x > 0, and rounding upward, or + // x < 0, and rounding downward, then, + // asin(x) = x * 2^-11 + x + // else, in other rounding modes, + // asin(x) = x + if (LIBC_UNLIKELY(x_abs <= 0x1a1e)) { + int rounding = fputil::quick_get_round(); + + if ((xbits.is_pos() && rounding == FE_UPWARD) || + (xbits.is_neg() && rounding == FE_DOWNWARD)) + return fputil::cast(fputil::multiply_add(xf, 0x1.0p-11f, xf)); + return x; + } + + // Degree-6 minimax odd polynomial of asin(x) generated by Sollya with: + // > P = fpminimax(asin(x)/x, [|0, 2, 4, 6, 8|], [|SG...|], [0, 0.5]); + float result = + fputil::polyeval(xsq, 0x1.000002p0f, 0x1.554c2ap-3f, 0x1.3541ccp-4f, + 0x1.43b2d6p-5f, 0x1.a0d73ep-5f); + return fputil::cast(xf * result); + } + + // When |x| > 0.5, assume that 0.5 < |x| <= 1, + // + // Step-by-step range-reduction proof: + // 1: Let y = asin(x), such that, x = sin(y) + // 2: From complimentary angle identity: + // x = sin(y) = cos(pi/2 - y) + // 3: Let z = pi/2 - y, such that x = cos(z) + // 4: From double angle formula; cos(2A) = 1 - sin^2(A): + // z = 2A, z/2 = A + // cos(z) = 1 - 2 * sin^2(z/2) + // 5: Make sin(z/2) subject of the formula: + // sin(z/2) = sqrt((1 - cos(z))/2) + // 6: Recall [3]; x = cos(z). Therefore: + // sin(z/2) = sqrt((1 - x)/2) + // 7: Let u = (1 - x)/2 + // 8: Therefore: + // asin(sqrt(u)) = z/2 + // 2 * asin(sqrt(u)) = z + // 9: Recall [3], z = pi/2 - y. Therefore: + // y = pi/2 - z + // y = pi/2 - 2 * asin(sqrt(u)) + // 10: Recall [1], y = asin(x). Therefore: + // asin(x) = pi/2 - 2 * asin(sqrt(u)) + // + // WHY? + // 11: Recall [7], u = (1 - x)/2 + // 12: Since 0.5 < x <= 1, therefore: + // 0 <= u <= 0.25 and 0 <= sqrt(u) <= 0.5 + // + // Hence, we can reuse the same [0, 0.5] domain polynomial approximation for + // Step [10] as `sqrt(u)` is in range. + + // 0x1p-1 < |x| <= 0x1p0, 0.5 < |x| <= 1.0 + float xf_abs = (xf < 0 ? -xf : xf); + float sign = (xbits.uintval() >> 15 == 1 ? -1.0 : 1.0); + float u = fputil::multiply_add(-0.5f, xf_abs, 0.5f); + float u_sqrt = fputil::sqrt(u); + + // Degree-6 minimax odd polynomial of asin(x) generated by Sollya with: + // > P = fpminimax(asin(x)/x, [|0, 2, 4, 6, 8|], [|SG...|], [0, 0.5]); + float asin_sqrt_u = + u_sqrt * fputil::polyeval(u, 0x1.000002p0f, 0x1.554c2ap-3f, + 0x1.3541ccp-4f, 0x1.43b2d6p-5f, 0x1.a0d73ep-5f); + + return fputil::cast(sign * + fputil::multiply_add(-2.0f, asin_sqrt_u, PI_2)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/signal/linux/CMakeLists.txt b/libc/src/signal/linux/CMakeLists.txt index f7457d31cf4f8..c0dd61e473881 100644 --- a/libc/src/signal/linux/CMakeLists.txt +++ b/libc/src/signal/linux/CMakeLists.txt @@ -127,7 +127,6 @@ add_entrypoint_object( DEPENDS .sigaction libc.hdr.signal_macros - libc.hdr.types.sighandler_t ) add_entrypoint_object( diff --git a/libc/src/signal/linux/signal.cpp b/libc/src/signal/linux/signal.cpp index 1da0ef8c97a20..7c8ea16c6cd2e 100644 --- a/libc/src/signal/linux/signal.cpp +++ b/libc/src/signal/linux/signal.cpp @@ -8,14 +8,17 @@ #include "src/signal/signal.h" #include "hdr/signal_macros.h" -#include "hdr/types/sighandler_t.h" #include "src/__support/common.h" #include "src/__support/macros/config.h" #include "src/signal/sigaction.h" namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(sighandler_t, signal, (int signum, sighandler_t handler)) { +// Our LLVM_LIBC_FUNCTION macro doesn't handle function pointer return types. +using signal_handler = void (*)(int); + +LLVM_LIBC_FUNCTION(signal_handler, signal, + (int signum, signal_handler handler)) { struct sigaction action, old; action.sa_handler = handler; action.sa_flags = SA_RESTART; diff --git a/libc/src/signal/signal.h b/libc/src/signal/signal.h index 06e77e11bf0bd..e1f31a8e126c5 100644 --- a/libc/src/signal/signal.h +++ b/libc/src/signal/signal.h @@ -9,12 +9,11 @@ #ifndef LLVM_LIBC_SRC_SIGNAL_SIGNAL_H #define LLVM_LIBC_SRC_SIGNAL_SIGNAL_H -#include "hdr/types/sighandler_t.h" #include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { -sighandler_t signal(int signum, sighandler_t handler); +void (*signal(int signum, void (*handler)(int)))(int); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/stdfix/CMakeLists.txt b/libc/src/stdfix/CMakeLists.txt index 815f739d23efa..37292d85367fe 100644 --- a/libc/src/stdfix/CMakeLists.txt +++ b/libc/src/stdfix/CMakeLists.txt @@ -9,8 +9,6 @@ foreach(suffix IN ITEMS hr r lr hk k lk) abs${suffix}.h SRCS abs${suffix}.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.fx_bits ) @@ -23,8 +21,6 @@ foreach(suffix IN ITEMS uhr ur ulr uhk uk) sqrt${suffix}.h SRCS sqrt${suffix}.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.sqrt ) @@ -37,8 +33,6 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) round${suffix}.h SRCS round${suffix}.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.fx_bits ) @@ -61,8 +55,6 @@ add_entrypoint_object( uhksqrtus.h SRCS uhksqrtus.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.sqrt ) @@ -73,8 +65,6 @@ add_entrypoint_object( uksqrtui.h SRCS uksqrtui.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.sqrt ) @@ -85,8 +75,6 @@ add_entrypoint_object( exphk.h SRCS exphk.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.fx_rep libc.src.__support.CPP.bit @@ -98,8 +86,6 @@ add_entrypoint_object( expk.h SRCS expk.cpp - COMPILE_OPTIONS - ${libc_opt_high_flag} DEPENDS libc.src.__support.fixed_point.fx_rep libc.src.__support.CPP.bit diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp index 119a06985b8f1..d66066023984e 100644 --- a/libc/test/UnitTest/FPExceptMatcher.cpp +++ b/libc/test/UnitTest/FPExceptMatcher.cpp @@ -37,7 +37,7 @@ static void sigfpeHandler(int sig) { } FPExceptMatcher::FPExceptMatcher(FunctionCaller *func) { - sighandler_t oldSIGFPEHandler = signal(SIGFPE, &sigfpeHandler); + auto *oldSIGFPEHandler = signal(SIGFPE, &sigfpeHandler); caughtExcept = false; fenv_t oldEnv; diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt index aeb8edf305d05..8d175e857fcd1 100644 --- a/libc/test/src/__support/CMakeLists.txt +++ b/libc/test/src/__support/CMakeLists.txt @@ -234,7 +234,7 @@ add_libc_test( libc.src.stdlib.srand libc.src.string.memset COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} UNIT_TEST_ONLY # Aligned Allocation is not supported in hermetic builds. ) diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index bbcdf2363c1e2..6a3dd8c9deff0 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -1597,7 +1597,7 @@ add_fp_unittest( libc.src.math.sqrtf libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -1613,7 +1613,7 @@ add_fp_unittest( libc.src.math.sqrt libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -1629,7 +1629,7 @@ add_fp_unittest( libc.src.math.sqrtl libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -2186,6 +2186,17 @@ add_fp_unittest( libc.src.__support.FPUtil.fp_bits ) +add_fp_unittest( + asinf16_test + NEED_MPFR + SUITE + libc-math-unittests + SRCS + asinf16_test.cpp + DEPENDS + libc.src.math.asinf16 +) + add_fp_unittest( acosf_test NEED_MPFR diff --git a/libc/test/src/math/asinf16_test.cpp b/libc/test/src/math/asinf16_test.cpp new file mode 100644 index 0000000000000..9593cad16ac77 --- /dev/null +++ b/libc/test/src/math/asinf16_test.cpp @@ -0,0 +1,42 @@ +//===-- Exhaustive test for asinf16 ---------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "src/math/asinf16.h" +#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/Test.h" +#include "utils/MPFRWrapper/MPFRUtils.h" + +using LlvmLibcAsinf16Test = LIBC_NAMESPACE::testing::FPTest; + +namespace mpfr = LIBC_NAMESPACE::testing::mpfr; + +// Range: [0, Inf] +static constexpr uint16_t POS_START = 0x0000U; +static constexpr uint16_t POS_STOP = 0x7c00U; + +// Range: [-Inf, 0] +static constexpr uint16_t NEG_START = 0x8000U; +static constexpr uint16_t NEG_STOP = 0xfc00U; + +TEST_F(LlvmLibcAsinf16Test, PositiveRange) { + for (uint16_t v = POS_START; v <= POS_STOP; ++v) { + float16 x = FPBits(v).get_val(); + + EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x, + LIBC_NAMESPACE::asinf16(x), 0.5); + } +} + +TEST_F(LlvmLibcAsinf16Test, NegativeRange) { + for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) { + float16 x = FPBits(v).get_val(); + + EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x, + LIBC_NAMESPACE::asinf16(x), 0.5); + } +} diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt index 423c3b7a8bfd1..b1927dbc19a3b 100644 --- a/libc/test/src/math/exhaustive/CMakeLists.txt +++ b/libc/test/src/math/exhaustive/CMakeLists.txt @@ -305,7 +305,7 @@ add_fp_unittest( SRCS hypotf_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS .exhaustive_test libc.src.math.hypotf diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index e0cb531b40421..14447728fb18a 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -2993,7 +2993,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3007,7 +3007,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3021,7 +3021,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3038,7 +3038,7 @@ add_fp_unittest( libc.src.math.sqrtf128 libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3957,6 +3957,17 @@ add_fp_unittest( libc.src.__support.FPUtil.fp_bits ) +add_fp_unittest( + asinf16_test + SUITE + libc-math-smoke-tests + SRCS + asinf16_test.cpp + DEPENDS + libc.src.errno.errno + libc.src.math.asinf16 +) + add_fp_unittest( acosf_test SUITE diff --git a/libc/test/src/math/smoke/asinf16_test.cpp b/libc/test/src/math/smoke/asinf16_test.cpp new file mode 100644 index 0000000000000..9f675b08319c0 --- /dev/null +++ b/libc/test/src/math/smoke/asinf16_test.cpp @@ -0,0 +1,42 @@ +//===-- Unittests for asinf16 ---------------------------------------------===// +// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include "src/errno/libc_errno.h" +#include "src/math/asinf16.h" +#include "test/UnitTest/FPMatcher.h" +#include "test/UnitTest/Test.h" + +using LlvmLibcAsinf16Test = LIBC_NAMESPACE::testing::FPTest; + +TEST_F(LlvmLibcAsinf16Test, SpecialNumbers) { + LIBC_NAMESPACE::libc_errno = 0; + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinf16(aNaN)); + EXPECT_MATH_ERRNO(0); + + EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::asinf16(sNaN), FE_INVALID); + EXPECT_MATH_ERRNO(0); + + EXPECT_FP_EQ(zero, LIBC_NAMESPACE::asinf16(zero)); + EXPECT_MATH_ERRNO(0); + + EXPECT_FP_EQ(neg_zero, LIBC_NAMESPACE::asinf16(neg_zero)); + EXPECT_MATH_ERRNO(0); + + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinf16(inf)); + EXPECT_MATH_ERRNO(EDOM); + + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinf16(neg_inf)); + EXPECT_MATH_ERRNO(EDOM); + + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinf16(2.0f)); + EXPECT_MATH_ERRNO(EDOM); + + EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::asinf16(-2.0f)); + EXPECT_MATH_ERRNO(EDOM); +} diff --git a/libc/test/src/signal/CMakeLists.txt b/libc/test/src/signal/CMakeLists.txt index a27f5b8f1000e..f86ce2ae96857 100644 --- a/libc/test/src/signal/CMakeLists.txt +++ b/libc/test/src/signal/CMakeLists.txt @@ -74,7 +74,6 @@ add_libc_unittest( SRCS signal_test.cpp DEPENDS - libc.hdr.types.sighandler_t libc.src.errno.errno libc.src.signal.raise libc.src.signal.signal diff --git a/libc/test/src/signal/signal_test.cpp b/libc/test/src/signal/signal_test.cpp index 4b57311eee2d8..bac9c3b8b68bb 100644 --- a/libc/test/src/signal/signal_test.cpp +++ b/libc/test/src/signal/signal_test.cpp @@ -13,14 +13,12 @@ #include "test/UnitTest/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include "hdr/types/sighandler_t.h" - using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; TEST(LlvmLibcSignal, Invalid) { LIBC_NAMESPACE::libc_errno = 0; - sighandler_t valid = +[](int) {}; + auto *valid = +[](int) {}; EXPECT_THAT((void *)LIBC_NAMESPACE::signal(0, valid), Fails(EINVAL, (void *)SIG_ERR)); EXPECT_THAT((void *)LIBC_NAMESPACE::signal(65, valid), diff --git a/libc/test/src/stdfix/CMakeLists.txt b/libc/test/src/stdfix/CMakeLists.txt index 90d20438edb4b..e4d4fc5b52558 100644 --- a/libc/test/src/stdfix/CMakeLists.txt +++ b/libc/test/src/stdfix/CMakeLists.txt @@ -14,7 +14,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk) SRCS abs${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.abs${suffix} libc.src.__support.fixed_point.fx_bits @@ -31,7 +31,7 @@ foreach(suffix IN ITEMS uhr ur ulr uhk uk) SRCS sqrt${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.sqrt${suffix} libc.src.__support.CPP.bit @@ -52,7 +52,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) SRCS round${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.round${suffix} libc.src.__support.fixed_point.fx_bits @@ -67,7 +67,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) SRCS ${suffix}bits_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.${suffix}bits libc.src.__support.CPP.bit @@ -84,7 +84,7 @@ add_libc_test( SRCS uhksqrtus_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.uhksqrtus libc.src.__support.CPP.bit @@ -103,7 +103,7 @@ add_libc_test( SRCS uksqrtui_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.uksqrtui libc.src.__support.CPP.bit @@ -122,7 +122,7 @@ add_libc_test( SRCS exphk_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.exphk libc.src.math.exp @@ -140,7 +140,7 @@ add_libc_test( SRCS expk_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.expk libc.src.math.exp diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt index f7df9146c8d48..9ff7fa109ff97 100644 --- a/libc/utils/MPFRWrapper/CMakeLists.txt +++ b/libc/utils/MPFRWrapper/CMakeLists.txt @@ -34,7 +34,7 @@ if(LIBC_TESTS_CAN_USE_MPFR) _get_common_test_compile_options(compile_options "" "") # mpfr/gmp headers do not work with -ffreestanding flag. list(REMOVE_ITEM compile_options "-ffreestanding") - target_compile_options(libcMPFRWrapper PRIVATE -O3 ${compile_options}) + target_compile_options(libcMPFRWrapper PRIVATE ${libc_opt_high_flag} ${compile_options}) add_dependencies( libcMPFRWrapper libcMPCommon diff --git a/libc/utils/docgen/sys/statvfs.yaml b/libc/utils/docgen/sys/statvfs.yaml new file mode 100644 index 0000000000000..b13c3cb7203e5 --- /dev/null +++ b/libc/utils/docgen/sys/statvfs.yaml @@ -0,0 +1,11 @@ +functions: + fstatvfs: + in-latest-posix: '' + statvfs: + in-latest-posix: '' + +macros: + ST_RDONLY: + in-latest-posix: '' + ST_NOSUID: + in-latest-posix: '' diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 8e3f5097ba84a..2978fadc2c29f 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -32,10 +32,6 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS spirv64/lib/SOURCES; # CLC internal libraries clc/lib/generic/SOURCES; - clc/lib/clspv/SOURCES; - clc/lib/clspv64/SOURCES; - clc/lib/spirv/SOURCES; - clc/lib/spirv64/SOURCES; ) set( LIBCLC_MIN_LLVM 3.9.0 ) @@ -266,15 +262,15 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) list( GET TRIPLE 1 VENDOR ) list( GET TRIPLE 2 OS ) - set( dirs ) + set( opencl_dirs ) if ( NOT ${ARCH} STREQUAL spirv AND NOT ${ARCH} STREQUAL spirv64 AND NOT ${ARCH} STREQUAL clspv AND NOT ${ARCH} STREQUAL clspv64) - LIST( APPEND dirs generic ) + LIST( APPEND opencl_dirs generic ) endif() if( ${ARCH} STREQUAL r600 OR ${ARCH} STREQUAL amdgcn ) - list( APPEND dirs amdgpu ) + list( APPEND opencl_dirs amdgpu ) endif() # Some targets' directories alias others @@ -291,11 +287,13 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) endif() set( clc_lib_files ) + set( clc_dirs ${dirs} generic ) + libclc_configure_lib_source( clc_lib_files CLC_INTERNAL LIB_ROOT_DIR clc - DIRS ${dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} + DIRS ${clc_dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} ) set( opencl_lib_files ) @@ -312,7 +310,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) libclc_configure_lib_source( opencl_lib_files - DIRS ${dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} + DIRS ${opencl_dirs} ${DARCH} ${DARCH}-${OS} ${DARCH}-${VENDOR}-${OS} ) foreach( d ${${t}_devices} ) @@ -353,7 +351,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE ) list( APPEND build_flags - -D__CLC_INTERNAL -D${CLC_TARGET_DEFINE} # All libclc builtin libraries see CLC headers -I${CMAKE_CURRENT_SOURCE_DIR}/clc/include @@ -365,12 +362,14 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) list( APPEND build_flags -mcpu=${cpu} ) endif() + set( clc_build_flags ${build_flags} -DCLC_INTERNAL ) + add_libclc_builtin_set( CLC_INTERNAL ARCH ${ARCH} ARCH_SUFFIX clc-${arch_suffix} TRIPLE ${clang_triple} - COMPILE_FLAGS ${build_flags} + COMPILE_FLAGS ${clc_build_flags} OPT_FLAGS ${opt_flags} LIB_FILES ${clc_lib_files} ) diff --git a/libclc/clc/include/clc/common/clc_sign.h b/libclc/clc/include/clc/common/clc_sign.h new file mode 100644 index 0000000000000..9e0984db7bb3b --- /dev/null +++ b/libclc/clc/include/clc/common/clc_sign.h @@ -0,0 +1,12 @@ +#ifndef __CLC_COMMON_CLC_SIGN_H__ +#define __CLC_COMMON_CLC_SIGN_H__ + +#define __CLC_FUNCTION __clc_sign +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_COMMON_CLC_SIGN_H__ diff --git a/libclc/clc/include/clc/integer/clc_abs.h b/libclc/clc/include/clc/integer/clc_abs.h index 31c62d311a006..59bd807b96060 100644 --- a/libclc/clc/include/clc/integer/clc_abs.h +++ b/libclc/clc/include/clc/integer/clc_abs.h @@ -1,14 +1,7 @@ #ifndef __CLC_INTEGER_CLC_ABS_H__ #define __CLC_INTEGER_CLC_ABS_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible abs -#define __clc_abs abs -#else - #define __CLC_BODY #include -#endif - #endif // __CLC_INTEGER_CLC_ABS_H__ diff --git a/libclc/clc/include/clc/integer/clc_abs_diff.h b/libclc/clc/include/clc/integer/clc_abs_diff.h index 9c33fcff23b79..021a9b6bc45a0 100644 --- a/libclc/clc/include/clc/integer/clc_abs_diff.h +++ b/libclc/clc/include/clc/integer/clc_abs_diff.h @@ -1,14 +1,7 @@ #ifndef __CLC_INTEGER_CLC_ABS_DIFF_H__ #define __CLC_INTEGER_CLC_ABS_DIFF_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible abs_diff -#define __clc_abs_diff abs_diff -#else - #define __CLC_BODY #include -#endif - #endif // __CLC_INTEGER_CLC_ABS_DIFF_H__ diff --git a/libclc/clc/include/clc/math/gentype.inc b/libclc/clc/include/clc/math/gentype.inc index 87719f2d9bc0e..3c80f1c6172ad 100644 --- a/libclc/clc/include/clc/math/gentype.inc +++ b/libclc/clc/include/clc/math/gentype.inc @@ -3,55 +3,69 @@ #define __CLC_SCALAR_GENTYPE float #define __CLC_FPSIZE 32 +#define __CLC_FP_LIT(x) x##F #define __CLC_GENTYPE float #define __CLC_INTN int +#define __CLC_BIT_INTN int #define __CLC_SCALAR #include __CLC_BODY #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #undef __CLC_SCALAR #define __CLC_GENTYPE float2 #define __CLC_INTN int2 +#define __CLC_BIT_INTN int2 #define __CLC_VECSIZE 2 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE float3 #define __CLC_INTN int3 +#define __CLC_BIT_INTN int3 #define __CLC_VECSIZE 3 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE float4 #define __CLC_INTN int4 +#define __CLC_BIT_INTN int4 #define __CLC_VECSIZE 4 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE float8 #define __CLC_INTN int8 +#define __CLC_BIT_INTN int8 #define __CLC_VECSIZE 8 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE float16 #define __CLC_INTN int16 +#define __CLC_BIT_INTN int16 #define __CLC_VECSIZE 16 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN +#undef __CLC_FP_LIT #undef __CLC_FPSIZE #undef __CLC_SCALAR_GENTYPE @@ -61,55 +75,69 @@ #define __CLC_SCALAR_GENTYPE double #define __CLC_FPSIZE 64 +#define __CLC_FP_LIT(x) (x) #define __CLC_SCALAR #define __CLC_GENTYPE double #define __CLC_INTN int +#define __CLC_BIT_INTN long #include __CLC_BODY #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #undef __CLC_SCALAR #define __CLC_GENTYPE double2 #define __CLC_INTN int2 +#define __CLC_BIT_INTN long2 #define __CLC_VECSIZE 2 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE double3 #define __CLC_INTN int3 +#define __CLC_BIT_INTN long3 #define __CLC_VECSIZE 3 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE double4 #define __CLC_INTN int4 +#define __CLC_BIT_INTN long4 #define __CLC_VECSIZE 4 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE double8 #define __CLC_INTN int8 +#define __CLC_BIT_INTN long8 #define __CLC_VECSIZE 8 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE double16 #define __CLC_INTN int16 +#define __CLC_BIT_INTN long16 #define __CLC_VECSIZE 16 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN +#undef __CLC_FP_LIT #undef __CLC_FPSIZE #undef __CLC_SCALAR_GENTYPE #endif @@ -121,55 +149,69 @@ #define __CLC_SCALAR_GENTYPE half #define __CLC_FPSIZE 16 +#define __CLC_FP_LIT(x) x##H #define __CLC_SCALAR #define __CLC_GENTYPE half #define __CLC_INTN int +#define __CLC_BIT_INTN short #include __CLC_BODY #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #undef __CLC_SCALAR #define __CLC_GENTYPE half2 #define __CLC_INTN int2 +#define __CLC_BIT_INTN short2 #define __CLC_VECSIZE 2 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE half3 #define __CLC_INTN int3 +#define __CLC_BIT_INTN short3 #define __CLC_VECSIZE 3 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE half4 #define __CLC_INTN int4 +#define __CLC_BIT_INTN short4 #define __CLC_VECSIZE 4 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE half8 #define __CLC_INTN int8 +#define __CLC_BIT_INTN short8 #define __CLC_VECSIZE 8 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN #define __CLC_GENTYPE half16 #define __CLC_INTN int16 +#define __CLC_BIT_INTN short16 #define __CLC_VECSIZE 16 #include __CLC_BODY #undef __CLC_VECSIZE #undef __CLC_GENTYPE +#undef __CLC_BIT_INTN #undef __CLC_INTN +#undef __CLC_FP_LIT #undef __CLC_FPSIZE #undef __CLC_SCALAR_GENTYPE #endif diff --git a/libclc/clc/include/clc/relational/clc_all.h b/libclc/clc/include/clc/relational/clc_all.h index 7be3d132dd53d..2ffced19ba0e5 100644 --- a/libclc/clc/include/clc/relational/clc_all.h +++ b/libclc/clc/include/clc/relational/clc_all.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ALL_H__ #define __CLC_RELATIONAL_CLC_ALL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible all -#define __clc_all all -#else - #include #include @@ -27,6 +22,4 @@ _CLC_VECTOR_ALL_DECL(long) #undef _CLC_ALL_DECL #undef _CLC_VECTOR_ALL_DECL -#endif - #endif // __CLC_RELATIONAL_CLC_ALL_H__ diff --git a/libclc/clc/include/clc/relational/clc_any.h b/libclc/clc/include/clc/relational/clc_any.h index 27dbffeb2eecd..2f554334d9bac 100644 --- a/libclc/clc/include/clc/relational/clc_any.h +++ b/libclc/clc/include/clc/relational/clc_any.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ANY_H__ #define __CLC_RELATIONAL_CLC_ANY_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible any -#define __clc_any any -#else - #include #include @@ -27,6 +22,4 @@ _CLC_VECTOR_ANY_DECL(long) #undef _CLC_ANY_DECL #undef _CLC_VECTOR_ANY_DECL -#endif - #endif // __CLC_RELATIONAL_CLC_ANY_H__ diff --git a/libclc/clc/include/clc/relational/clc_isequal.h b/libclc/clc/include/clc/relational/clc_isequal.h index 0f31fb9530a14..84bf0974dbbf5 100644 --- a/libclc/clc/include/clc/relational/clc_isequal.h +++ b/libclc/clc/include/clc/relational/clc_isequal.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISEQUAL_H__ #define __CLC_RELATIONAL_CLC_ISEQUAL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isequal -#define __clc_isequal isequal -#else - #include #include @@ -37,6 +32,4 @@ _CLC_VECTOR_ISEQUAL_DECL(half, short) #undef _CLC_ISEQUAL_DECL #undef _CLC_VECTOR_ISEQUAL_DECL -#endif - #endif // __CLC_RELATIONAL_CLC_ISEQUAL_H__ diff --git a/libclc/clc/include/clc/relational/clc_isfinite.h b/libclc/clc/include/clc/relational/clc_isfinite.h index 3ed276e07a2f1..82bcc6ec2da27 100644 --- a/libclc/clc/include/clc/relational/clc_isfinite.h +++ b/libclc/clc/include/clc/relational/clc_isfinite.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISFINITE_H__ #define __CLC_RELATIONAL_CLC_ISFINITE_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isfinite -#define __clc_isfinite isfinite -#else - #define __CLC_FUNCTION __clc_isfinite #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISFINITE_H__ diff --git a/libclc/clc/include/clc/relational/clc_isgreater.h b/libclc/clc/include/clc/relational/clc_isgreater.h index b51d59aeb5499..31961e4c51679 100644 --- a/libclc/clc/include/clc/relational/clc_isgreater.h +++ b/libclc/clc/include/clc/relational/clc_isgreater.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISGREATER_H__ #define __CLC_RELATIONAL_CLC_ISGREATER_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isgreater -#define __clc_isgreater isgreater -#else - #define __CLC_FUNCTION __clc_isgreater #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISGREATER_H__ diff --git a/libclc/clc/include/clc/relational/clc_isgreaterequal.h b/libclc/clc/include/clc/relational/clc_isgreaterequal.h index b7ffce151847f..0e072fad09655 100644 --- a/libclc/clc/include/clc/relational/clc_isgreaterequal.h +++ b/libclc/clc/include/clc/relational/clc_isgreaterequal.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ #define __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isgreaterequal -#define __clc_isgreaterequal isgreaterequal -#else - #define __CLC_FUNCTION __clc_isgreaterequal #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISGREATEREQUAL_H__ diff --git a/libclc/clc/include/clc/relational/clc_isinf.h b/libclc/clc/include/clc/relational/clc_isinf.h index 3f60bec5654a2..b666953d4a8e6 100644 --- a/libclc/clc/include/clc/relational/clc_isinf.h +++ b/libclc/clc/include/clc/relational/clc_isinf.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISINF_H__ #define __CLC_RELATIONAL_CLC_ISINF_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isinf -#define __clc_isinf isinf -#else - #include #include @@ -37,6 +32,4 @@ _CLC_VECTOR_ISINF_DECL(short, half) #undef _CLC_ISINF_DECL #undef _CLC_VECTOR_ISINF_DECL -#endif - #endif // __CLC_RELATIONAL_CLC_ISINF_H__ diff --git a/libclc/clc/include/clc/relational/clc_isless.h b/libclc/clc/include/clc/relational/clc_isless.h index c6950aa61ad90..482fddfe4f8af 100644 --- a/libclc/clc/include/clc/relational/clc_isless.h +++ b/libclc/clc/include/clc/relational/clc_isless.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISLESS_H__ #define __CLC_RELATIONAL_CLC_ISLESS_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isless -#define __clc_isless isless -#else - #define __CLC_FUNCTION __clc_isless #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISLESS_H__ diff --git a/libclc/clc/include/clc/relational/clc_islessequal.h b/libclc/clc/include/clc/relational/clc_islessequal.h index 7efac163e106a..520f3d9c6ffd6 100644 --- a/libclc/clc/include/clc/relational/clc_islessequal.h +++ b/libclc/clc/include/clc/relational/clc_islessequal.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ #define __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible islessequal -#define __clc_islessequal islessequal -#else - #define __CLC_FUNCTION __clc_islessequal #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISLESSEQUAL_H__ diff --git a/libclc/clc/include/clc/relational/clc_islessgreater.h b/libclc/clc/include/clc/relational/clc_islessgreater.h index df3c5e513c86c..e90eadbbca5e5 100644 --- a/libclc/clc/include/clc/relational/clc_islessgreater.h +++ b/libclc/clc/include/clc/relational/clc_islessgreater.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ #define __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible islessgreater -#define __clc_islessgreater islessgreater -#else - #define __CLC_FUNCTION __clc_islessgreater #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISLESSGREATER_H__ diff --git a/libclc/clc/include/clc/relational/clc_isnormal.h b/libclc/clc/include/clc/relational/clc_isnormal.h index 48ee6b83a5711..269abf0037411 100644 --- a/libclc/clc/include/clc/relational/clc_isnormal.h +++ b/libclc/clc/include/clc/relational/clc_isnormal.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISNORMAL_H__ #define __CLC_RELATIONAL_CLC_ISNORMAL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isnormal -#define __clc_isnormal isnormal -#else - #define __CLC_FUNCTION __clc_isnormal #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISNORMAL_H__ diff --git a/libclc/clc/include/clc/relational/clc_isnotequal.h b/libclc/clc/include/clc/relational/clc_isnotequal.h index 55c1bd91b2dd5..598657658ec58 100644 --- a/libclc/clc/include/clc/relational/clc_isnotequal.h +++ b/libclc/clc/include/clc/relational/clc_isnotequal.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ #define __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isnotequal -#define __clc_isnotequal isnotequal -#else - #define __CLC_FUNCTION __clc_isnotequal #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISNOTEQUAL_H__ diff --git a/libclc/clc/include/clc/relational/clc_isordered.h b/libclc/clc/include/clc/relational/clc_isordered.h index 5ce2bfe334027..f4363d3d8a832 100644 --- a/libclc/clc/include/clc/relational/clc_isordered.h +++ b/libclc/clc/include/clc/relational/clc_isordered.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISORDERED_H__ #define __CLC_RELATIONAL_CLC_ISORDERED_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isordered -#define __clc_isordered isordered -#else - #define __CLC_FUNCTION __clc_isordered #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISORDERED_H__ diff --git a/libclc/clc/include/clc/relational/clc_isunordered.h b/libclc/clc/include/clc/relational/clc_isunordered.h index 305d2b4e9131f..e7f01826d5cc9 100644 --- a/libclc/clc/include/clc/relational/clc_isunordered.h +++ b/libclc/clc/include/clc/relational/clc_isunordered.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_ISUNORDERED_H__ #define __CLC_RELATIONAL_CLC_ISUNORDERED_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible isunordered -#define __clc_isunordered isunordered -#else - #define __CLC_FUNCTION __clc_isunordered #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_ISUNORDERED_H__ diff --git a/libclc/clc/include/clc/relational/clc_signbit.h b/libclc/clc/include/clc/relational/clc_signbit.h index 45a7112c9eb96..55561dd834871 100644 --- a/libclc/clc/include/clc/relational/clc_signbit.h +++ b/libclc/clc/include/clc/relational/clc_signbit.h @@ -1,11 +1,6 @@ #ifndef __CLC_RELATIONAL_CLC_SIGNBIT_H__ #define __CLC_RELATIONAL_CLC_SIGNBIT_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible signbit -#define __clc_signbit signbit -#else - #define __CLC_FUNCTION __clc_signbit #define __CLC_BODY @@ -14,6 +9,4 @@ #undef __CLC_BODY #undef __CLC_FUNCTION -#endif - #endif // __CLC_RELATIONAL_CLC_SIGNBIT_H__ diff --git a/libclc/clc/include/clc/shared/clc_max.h b/libclc/clc/include/clc/shared/clc_max.h index 388f001a27782..9bfa05552a399 100644 --- a/libclc/clc/include/clc/shared/clc_max.h +++ b/libclc/clc/include/clc/shared/clc_max.h @@ -1,17 +1,10 @@ #ifndef __CLC_SHARED_CLC_MAX_H__ #define __CLC_SHARED_CLC_MAX_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible max -#define __clc_max max -#else - #define __CLC_BODY #include #define __CLC_BODY #include -#endif - #endif // __CLC_SHARED_CLC_MAX_H__ diff --git a/libclc/clc/include/clc/shared/clc_min.h b/libclc/clc/include/clc/shared/clc_min.h index c8d920e1b4eb8..a10193885328f 100644 --- a/libclc/clc/include/clc/shared/clc_min.h +++ b/libclc/clc/include/clc/shared/clc_min.h @@ -1,17 +1,10 @@ #ifndef __CLC_SHARED_CLC_MIN_H__ #define __CLC_SHARED_CLC_MIN_H__ -#if defined(CLC_CLSPV) || defined(CLC_SPIRV) -// clspv and spir-v targets provide their own OpenCL-compatible min -#define __clc_min min -#else - #define __CLC_BODY #include #define __CLC_BODY #include -#endif - #endif // __CLC_SHARED_CLC_MIN_H__ diff --git a/libclc/clc/lib/clspv/SOURCES b/libclc/clc/lib/clspv/SOURCES deleted file mode 100644 index 2fe07f62a328c..0000000000000 --- a/libclc/clc/lib/clspv/SOURCES +++ /dev/null @@ -1,23 +0,0 @@ -../generic/integer/clc_add_sat.cl -../generic/integer/clc_clz.cl -../generic/integer/clc_hadd.cl -../generic/integer/clc_mad24.cl -../generic/integer/clc_mad_sat.cl -../generic/integer/clc_mul24.cl -../generic/integer/clc_mul_hi.cl -../generic/integer/clc_popcount.cl -../generic/integer/clc_rhadd.cl -../generic/integer/clc_rotate.cl -../generic/integer/clc_sub_sat.cl -../generic/integer/clc_upsample.cl -../generic/math/clc_ceil.cl -../generic/math/clc_copysign.cl -../generic/math/clc_fabs.cl -../generic/math/clc_floor.cl -../generic/math/clc_mad.cl -../generic/math/clc_nextafter.cl -../generic/math/clc_rint.cl -../generic/math/clc_trunc.cl -../generic/relational/clc_isnan.cl -../generic/relational/clc_select.cl -../generic/shared/clc_clamp.cl diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 2d31f9ac23fec..b0eaf84c41438 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -1,5 +1,6 @@ common/clc_degrees.cl common/clc_radians.cl +common/clc_sign.cl common/clc_smoothstep.cl geometric/clc_dot.cl integer/clc_abs.cl diff --git a/libclc/clc/lib/generic/common/clc_sign.cl b/libclc/clc/lib/generic/common/clc_sign.cl new file mode 100644 index 0000000000000..3c0384d71a65d --- /dev/null +++ b/libclc/clc/lib/generic/common/clc_sign.cl @@ -0,0 +1,6 @@ +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/libclc/clc/lib/generic/common/clc_sign.inc b/libclc/clc/lib/generic/common/clc_sign.inc new file mode 100644 index 0000000000000..85fa330e58e9e --- /dev/null +++ b/libclc/clc/lib/generic/common/clc_sign.inc @@ -0,0 +1,7 @@ +_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_sign(__CLC_GENTYPE x) { + __CLC_BIT_INTN ret_zero = __clc_isnan(x) || x == __CLC_FP_LIT(0.0); + __CLC_GENTYPE ret_val = + __clc_select((__CLC_GENTYPE)__CLC_FP_LIT(1.0), + (__CLC_GENTYPE)__CLC_FP_LIT(0.0), ret_zero); + return __clc_copysign(ret_val, x); +} diff --git a/libclc/clc/lib/spirv/SOURCES b/libclc/clc/lib/spirv/SOURCES deleted file mode 100644 index 96040a3aebd83..0000000000000 --- a/libclc/clc/lib/spirv/SOURCES +++ /dev/null @@ -1,26 +0,0 @@ -../generic/common/clc_degrees.cl -../generic/common/clc_radians.cl -../generic/common/clc_smoothstep.cl -../generic/geometric/clc_dot.cl -../generic/integer/clc_add_sat.cl -../generic/integer/clc_clz.cl -../generic/integer/clc_hadd.cl -../generic/integer/clc_mad24.cl -../generic/integer/clc_mad_sat.cl -../generic/integer/clc_mul24.cl -../generic/integer/clc_mul_hi.cl -../generic/integer/clc_popcount.cl -../generic/integer/clc_rhadd.cl -../generic/integer/clc_rotate.cl -../generic/integer/clc_sub_sat.cl -../generic/integer/clc_upsample.cl -../generic/math/clc_ceil.cl -../generic/math/clc_copysign.cl -../generic/math/clc_fabs.cl -../generic/math/clc_floor.cl -../generic/math/clc_mad.cl -../generic/math/clc_nextafter.cl -../generic/math/clc_rint.cl -../generic/math/clc_trunc.cl -../generic/relational/clc_select.cl -../generic/shared/clc_clamp.cl diff --git a/libclc/generic/include/clc/float/definitions.h b/libclc/generic/include/clc/float/definitions.h index 62501230c92de..be3d0130f3e61 100644 --- a/libclc/generic/include/clc/float/definitions.h +++ b/libclc/generic/include/clc/float/definitions.h @@ -31,9 +31,7 @@ #define M_SQRT2_F 0x1.6a09e6p+0f #define M_SQRT1_2_F 0x1.6a09e6p-1f -#ifdef __CLC_INTERNAL -#define M_LOG210_F 0x1.a934f0p+1f -#endif +#define M_LOG210_F 0x1.a934f0p+1f #ifdef cl_khr_fp64 diff --git a/libclc/generic/lib/common/sign.cl b/libclc/generic/lib/common/sign.cl index ad8f7405e0cb3..2f04d93b3e47e 100644 --- a/libclc/generic/lib/common/sign.cl +++ b/libclc/generic/lib/common/sign.cl @@ -1,37 +1,8 @@ #include #include +#include -#define SIGN(TYPE, F) \ -_CLC_DEF _CLC_OVERLOAD TYPE sign(TYPE x) { \ - if (isnan(x)) { \ - return 0.0F; \ - } \ - if (x > 0.0F) { \ - return 1.0F; \ - } \ - if (x < 0.0F) { \ - return -1.0F; \ - } \ - return x; /* -0.0 or +0.0 */ \ -} +#define FUNCTION sign +#define __CLC_BODY -SIGN(float, f) -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, sign, float) - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -SIGN(double, ) -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, sign, double) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -SIGN(half,) -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, sign, half) - -#endif +#include diff --git a/libcxx/docs/Status/FormatPaper.csv b/libcxx/docs/Status/FormatPaper.csv index beec97b8c0179..6ddae9e2a1518 100644 --- a/libcxx/docs/Status/FormatPaper.csv +++ b/libcxx/docs/Status/FormatPaper.csv @@ -2,7 +2,7 @@ Section,Description,Dependencies,Assignee,Status,First released version `P1361 `__ `P2372 `__,"Formatting chrono" `[time.syn] `_,"Formatter ``chrono::duration``",,Mark de Wever,|Complete|,16 `[time.syn] `_,"Formatter ``chrono::sys_time``",,Mark de Wever,|Complete|,17 -`[time.syn] `_,"Formatter ``chrono::utc_time``",A ```` implementation,Mark de Wever,|Complete|,20 +`[time.syn] `_,"Formatter ``chrono::utc_time``",,Mark de Wever,|Complete|,20 `[time.syn] `_,"Formatter ``chrono::tai_time``",,Mark de Wever,|Complete|,21 `[time.syn] `_,"Formatter ``chrono::gps_time``",A ```` implementation,Mark de Wever,,, `[time.syn] `_,"Formatter ``chrono::file_time``",,Mark de Wever,|Complete|,17 diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index ce805b4eb7b8b..255a0474c0f6b 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -557,12 +557,14 @@ set(files __memory/compressed_pair.h __memory/concepts.h __memory/construct_at.h + __memory/destroy.h __memory/destruct_n.h __memory/inout_ptr.h __memory/noexcept_move_assign_container.h __memory/out_ptr.h __memory/pointer_traits.h __memory/ranges_construct_at.h + __memory/ranges_destroy.h __memory/ranges_uninitialized_algorithms.h __memory/raw_storage_iterator.h __memory/shared_count.h diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h index 0c054bbc3a1d8..c88b7f3222010 100644 --- a/libcxx/include/__format/buffer.h +++ b/libcxx/include/__format/buffer.h @@ -15,7 +15,6 @@ #include <__algorithm/max.h> #include <__algorithm/min.h> #include <__algorithm/ranges_copy.h> -#include <__algorithm/ranges_copy_n.h> #include <__algorithm/transform.h> #include <__algorithm/unwrap_iter.h> #include <__concepts/same_as.h> @@ -33,7 +32,7 @@ #include <__memory/allocator.h> #include <__memory/allocator_traits.h> #include <__memory/construct_at.h> -#include <__memory/ranges_construct_at.h> +#include <__memory/destroy.h> #include <__memory/uninitialized_algorithms.h> #include <__type_traits/add_pointer.h> #include <__type_traits/conditional.h> @@ -621,7 +620,7 @@ class _LIBCPP_TEMPLATE_VIS __retarget_buffer { } _LIBCPP_HIDE_FROM_ABI ~__retarget_buffer() { - ranges::destroy_n(__ptr_, __size_); + std::destroy_n(__ptr_, __size_); allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); } @@ -686,7 +685,7 @@ class _LIBCPP_TEMPLATE_VIS __retarget_buffer { // guard is optimized away so there is no runtime overhead. std::uninitialized_move_n(__ptr_, __size_, __result.ptr); __guard.__complete(); - ranges::destroy_n(__ptr_, __size_); + std::destroy_n(__ptr_, __size_); allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_); __ptr_ = __result.ptr; diff --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h index 1f129d17970b1..21337e766b2d0 100644 --- a/libcxx/include/__memory/construct_at.h +++ b/libcxx/include/__memory/construct_at.h @@ -57,9 +57,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` // taking an array). -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); - template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); @@ -70,28 +67,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at"); - std::__destroy(std::begin(*__loc), std::end(*__loc)); + auto const __end = std::end(*__loc); + for (auto __it = std::begin(*__loc); __it != __end; ++__it) + std::__destroy_at(__it); } #endif -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator -__destroy(_ForwardIterator __first, _ForwardIterator __last) { - for (; __first != __last; ++__first) - std::__destroy_at(std::addressof(*__first)); - return __first; -} - -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator -__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { - while (__last != __first) { - --__last; - std::__destroy_at(std::addressof(*__last)); - } - return __last; -} - #if _LIBCPP_STD_VER >= 17 template , int> = 0> @@ -106,18 +87,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) } # endif -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { - (void)std::__destroy(std::move(__first), std::move(__last)); -} - -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { - for (; __n > 0; (void)++__first, --__n) - std::__destroy_at(std::addressof(*__first)); - return __first; -} - #endif // _LIBCPP_STD_VER >= 17 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__memory/destroy.h b/libcxx/include/__memory/destroy.h new file mode 100644 index 0000000000000..69a252ba1331d --- /dev/null +++ b/libcxx/include/__memory/destroy.h @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_DESTROY_H +#define _LIBCPP___MEMORY_DESTROY_H + +#include <__config> +#include <__memory/addressof.h> +#include <__memory/allocator_traits.h> +#include <__memory/construct_at.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator +__destroy(_ForwardIterator __first, _ForwardIterator __last) { + for (; __first != __last; ++__first) + std::__destroy_at(std::addressof(*__first)); + return __first; +} + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator +__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) { + while (__last != __first) { + --__last; + std::__destroy_at(std::addressof(*__last)); + } + return __last; +} + +// Destroy all elements in [__first, __last) from left to right using allocator destruction. +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { + for (; __first != __last; ++__first) + allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__first)); +} + +#if _LIBCPP_STD_VER >= 17 +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { + (void)std::__destroy(std::move(__first), std::move(__last)); +} + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { + for (; __n > 0; (void)++__first, --__n) + std::__destroy_at(std::addressof(*__first)); + return __first; +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MEMORY_DESTROY_H diff --git a/libcxx/include/__memory/ranges_construct_at.h b/libcxx/include/__memory/ranges_construct_at.h index 35ed796510003..b8a94678c10c8 100644 --- a/libcxx/include/__memory/ranges_construct_at.h +++ b/libcxx/include/__memory/ranges_construct_at.h @@ -61,41 +61,6 @@ inline namespace __cpo { inline constexpr auto destroy_at = __destroy_at{}; } // namespace __cpo -// destroy - -struct __destroy { - template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> - requires destructible> - _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { - return std::__destroy(std::move(__first), std::move(__last)); - } - - template <__nothrow_input_range _InputRange> - requires destructible> - _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept { - return (*this)(ranges::begin(__range), ranges::end(__range)); - } -}; - -inline namespace __cpo { -inline constexpr auto destroy = __destroy{}; -} // namespace __cpo - -// destroy_n - -struct __destroy_n { - template <__nothrow_input_iterator _InputIterator> - requires destructible> - _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator - operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept { - return std::destroy_n(std::move(__first), __n); - } -}; - -inline namespace __cpo { -inline constexpr auto destroy_n = __destroy_n{}; -} // namespace __cpo - } // namespace ranges #endif // _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/__memory/ranges_destroy.h b/libcxx/include/__memory/ranges_destroy.h new file mode 100644 index 0000000000000..f134f1422e82c --- /dev/null +++ b/libcxx/include/__memory/ranges_destroy.h @@ -0,0 +1,79 @@ +// -*- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_RANGES_DESTROY_H +#define _LIBCPP___MEMORY_RANGES_DESTROY_H + +#include <__concepts/destructible.h> +#include <__config> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <__memory/concepts.h> +#include <__memory/destroy.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__ranges/dangling.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 +namespace ranges { + +// destroy + +struct __destroy { + template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> + requires destructible> + _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { + return std::__destroy(std::move(__first), std::move(__last)); + } + + template <__nothrow_input_range _InputRange> + requires destructible> + _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept { + return (*this)(ranges::begin(__range), ranges::end(__range)); + } +}; + +inline namespace __cpo { +inline constexpr auto destroy = __destroy{}; +} // namespace __cpo + +// destroy_n + +struct __destroy_n { + template <__nothrow_input_iterator _InputIterator> + requires destructible> + _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator + operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept { + return std::destroy_n(std::move(__first), __n); + } +}; + +inline namespace __cpo { +inline constexpr auto destroy_n = __destroy_n{}; +} // namespace __cpo + +} // namespace ranges + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MEMORY_RANGES_DESTROY_H diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h index 06b1fc488cf51..d513fa692c1f9 100644 --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -29,6 +29,7 @@ #include <__memory/auto_ptr.h> #include <__memory/compressed_pair.h> #include <__memory/construct_at.h> +#include <__memory/destroy.h> #include <__memory/pointer_traits.h> #include <__memory/shared_count.h> #include <__memory/uninitialized_algorithms.h> diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h index a02a88399a7a7..d7f210d12a212 100644 --- a/libcxx/include/__memory/uninitialized_algorithms.h +++ b/libcxx/include/__memory/uninitialized_algorithms.h @@ -21,6 +21,7 @@ #include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/construct_at.h> +#include <__memory/destroy.h> #include <__memory/pointer_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/extent.h> @@ -511,14 +512,6 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B #endif // _LIBCPP_STD_VER >= 17 -// Destroy all elements in [__first, __last) from left to right using allocator destruction. -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void -__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { - for (; __first != __last; ++__first) - allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first)); -} - template class _AllocatorDestroyRangeReverse { public: diff --git a/libcxx/include/__pstl/backends/libdispatch.h b/libcxx/include/__pstl/backends/libdispatch.h index 4c63c4c844207..a640a40352f5c 100644 --- a/libcxx/include/__pstl/backends/libdispatch.h +++ b/libcxx/include/__pstl/backends/libdispatch.h @@ -22,6 +22,7 @@ #include <__iterator/move_iterator.h> #include <__memory/allocator.h> #include <__memory/construct_at.h> +#include <__memory/destroy.h> #include <__memory/unique_ptr.h> #include <__new/exceptions.h> #include <__numeric/reduce.h> diff --git a/libcxx/include/chrono b/libcxx/include/chrono index bd4c98600440c..b39f060bf6b08 100644 --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -922,6 +922,8 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); } // chrono namespace std { + template + struct formatter, charT>; // C++20 template struct formatter, charT>; // C++20 template @@ -929,11 +931,9 @@ namespace std { template struct formatter, charT>; // C++20 template - struct formatter, charT>; // C++20 + struct formatter, charT>; // C++20 template struct formatter, charT>; // C++20 - template - struct formatter, charT>; // C++20 template struct formatter; // C++20 template struct formatter; // C++20 template struct formatter; // C++20 diff --git a/libcxx/include/memory b/libcxx/include/memory index fc62606ea0fd3..6661bc4f43756 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -958,12 +958,14 @@ template # if _LIBCPP_STD_VER >= 17 # include <__memory/construct_at.h> +# include <__memory/destroy.h> # endif # if _LIBCPP_STD_VER >= 20 # include <__memory/assume_aligned.h> # include <__memory/concepts.h> # include <__memory/ranges_construct_at.h> +# include <__memory/ranges_destroy.h> # include <__memory/ranges_uninitialized_algorithms.h> # include <__memory/uses_allocator_construction.h> # endif diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index fd39c946b992a..b0720703bd0de 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -1567,6 +1567,7 @@ module std [system] { module compressed_pair { header "__memory/compressed_pair.h" } module concepts { header "__memory/concepts.h" } module construct_at { header "__memory/construct_at.h" } + module destroy { header "__memory/destroy.h" } module destruct_n { header "__memory/destruct_n.h" } module fwd { header "__fwd/memory.h" } module inout_ptr { header "__memory/inout_ptr.h" } @@ -1574,6 +1575,7 @@ module std [system] { module out_ptr { header "__memory/out_ptr.h" } module pointer_traits { header "__memory/pointer_traits.h" } module ranges_construct_at { header "__memory/ranges_construct_at.h" } + module ranges_destroy { header "__memory/ranges_destroy.h" } module ranges_uninitialized_algorithms { header "__memory/ranges_uninitialized_algorithms.h" export std.algorithm.in_out_result diff --git a/libcxx/test/configs/nvptx-libc++-shared.cfg.in b/libcxx/test/configs/nvptx-libc++-shared.cfg.in index 9a3ca9c8da950..e07ed35da4d5a 100644 --- a/libcxx/test/configs/nvptx-libc++-shared.cfg.in +++ b/libcxx/test/configs/nvptx-libc++-shared.cfg.in @@ -10,8 +10,6 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -startfiles -stdlib ' '-L %{lib-dir} -lc++ -lc++abi ' '-Wl,--suppress-stack-size-warning ' - '-Wl,-mllvm,-nvptx-lower-global-ctor-dtor=1 ' - '-Wl,-mllvm,-nvptx-emit-init-fini-kernel' )) config.substitutions.append(('%{exec}', '%{executor} --no-parallelism' diff --git a/libcxx/test/libcxx/containers/associative/map/at.abort.pass.cpp b/libcxx/test/libcxx/containers/associative/map/at.abort.pass.cpp index 36aa644abb596..d68ee5f528599 100644 --- a/libcxx/test/libcxx/containers/associative/map/at.abort.pass.cpp +++ b/libcxx/test/libcxx/containers/associative/map/at.abort.pass.cpp @@ -23,14 +23,11 @@ #include "test_macros.h" - -void exit_success(int) { - std::_Exit(EXIT_SUCCESS); -} +void exit_success(int) { std::_Exit(EXIT_SUCCESS); } int main(int, char**) { - std::signal(SIGABRT, exit_success); - std::map map; - map.at(1); - return EXIT_FAILURE; + std::signal(SIGABRT, exit_success); + std::map map; + map.at(1); + return EXIT_FAILURE; } diff --git a/libcxx/test/libcxx/containers/associative/map/at.const.abort.pass.cpp b/libcxx/test/libcxx/containers/associative/map/at.const.abort.pass.cpp index f3dcca888f2b0..bbc8c7c4d726a 100644 --- a/libcxx/test/libcxx/containers/associative/map/at.const.abort.pass.cpp +++ b/libcxx/test/libcxx/containers/associative/map/at.const.abort.pass.cpp @@ -23,14 +23,11 @@ #include "test_macros.h" - -void exit_success(int) { - std::_Exit(EXIT_SUCCESS); -} +void exit_success(int) { std::_Exit(EXIT_SUCCESS); } int main(int, char**) { - std::signal(SIGABRT, exit_success); - std::map const map; - map.at(1); - return EXIT_FAILURE; + std::signal(SIGABRT, exit_success); + std::map const map; + map.at(1); + return EXIT_FAILURE; } diff --git a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm b/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm index 8b2f0057bcbc1..82b1c494c9566 100644 --- a/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm +++ b/libcxx/test/libcxx/containers/associative/map/find.modules.compile.pass.mm @@ -13,6 +13,4 @@ #include -void f(std::map const& map, int key) { - (void)map.find(key); -} +void f(std::map const& map, int key) { (void)map.find(key); } diff --git a/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp b/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp index 3f7086f7e37f3..bae78ba4b78c6 100644 --- a/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp +++ b/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp @@ -17,31 +17,33 @@ #include #include -template