diff --git a/clang-tools-extra/clangd/index/IndexAction.cpp b/clang-tools-extra/clangd/index/IndexAction.cpp index b7ceb6f5d484c..1b875bd203de1 100644 --- a/clang-tools-extra/clangd/index/IndexAction.cpp +++ b/clang-tools-extra/clangd/index/IndexAction.cpp @@ -121,30 +121,6 @@ struct IncludeGraphCollector : public PPCallbacks { IncludeGraph &IG; }; -/// An ASTConsumer that instructs the parser to skip bodies of functions in the -/// files that should not be processed. -class SkipProcessedFunctions : public ASTConsumer { -public: - SkipProcessedFunctions(std::function FileFilter) - : ShouldIndexFile(std::move(FileFilter)), Context(nullptr) { - assert(this->ShouldIndexFile); - } - - void Initialize(ASTContext &Context) override { this->Context = &Context; } - bool shouldSkipFunctionBody(Decl *D) override { - assert(Context && "Initialize() was never called."); - auto &SM = Context->getSourceManager(); - auto FID = SM.getFileID(SM.getExpansionLoc(D->getLocation())); - if (!FID.isValid()) - return false; - return !ShouldIndexFile(FID); - } - -private: - std::function ShouldIndexFile; - const ASTContext *Context; -}; - // Wraps the index action and reports index data after each translation unit. class IndexAction : public ASTFrontendAction { public: @@ -169,12 +145,15 @@ class IndexAction : public ASTFrontendAction { CI.getPreprocessor().addPPCallbacks( std::make_unique(CI.getSourceManager(), IG)); - std::vector> Consumers; - Consumers.push_back(std::make_unique( - [this](FileID FID) { return Collector->shouldIndexFile(FID); })); - Consumers.push_back(index::createIndexingASTConsumer( - Collector, Opts, CI.getPreprocessorPtr())); - return std::make_unique(std::move(Consumers)); + return index::createIndexingASTConsumer( + Collector, Opts, CI.getPreprocessorPtr(), + /*ShouldSkipFunctionBody=*/[this](const Decl *D) { + auto &SM = D->getASTContext().getSourceManager(); + auto FID = SM.getFileID(SM.getExpansionLoc(D->getLocation())); + if (!FID.isValid()) + return false; + return !Collector->shouldIndexFile(FID); + }); } bool BeginInvocation(CompilerInstance &CI) override { diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp index 1ae9fc091ad58..4b284163ef7e2 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp @@ -132,6 +132,7 @@ const Node *getParentOfRootStmts(const Node *CommonAnc) { // always unselected. return Parent->ASTNode.get() ? Parent->Parent : Parent; } + llvm_unreachable("Unhandled SelectionTree::Selection enum"); } // The ExtractionZone class forms a view of the code wrt Zone. diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 7add83f896244..f9668f1dce1f8 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -73,52 +73,6 @@ class TemplateDecl; class TemplateParameterList; class UsingDecl; -/// Represents any kind of function declaration, whether it is a -/// concrete function or a function template. -class AnyFunctionDecl { - NamedDecl *Function; - - AnyFunctionDecl(NamedDecl *ND) : Function(ND) {} - -public: - AnyFunctionDecl(FunctionDecl *FD) : Function(FD) {} - AnyFunctionDecl(FunctionTemplateDecl *FTD); - - /// Implicily converts any function or function template into a - /// named declaration. - operator NamedDecl *() const { return Function; } - - /// Retrieve the underlying function or function template. - NamedDecl *get() const { return Function; } - - static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) { - return AnyFunctionDecl(ND); - } -}; - -} // namespace clang - -namespace llvm { - - // Provide PointerLikeTypeTraits for non-cvr pointers. - template<> - struct PointerLikeTypeTraits< ::clang::AnyFunctionDecl> { - static void *getAsVoidPointer(::clang::AnyFunctionDecl F) { - return F.get(); - } - - static ::clang::AnyFunctionDecl getFromVoidPointer(void *P) { - return ::clang::AnyFunctionDecl::getFromNamedDecl( - static_cast< ::clang::NamedDecl*>(P)); - } - - enum { NumLowBitsAvailable = 2 }; - }; - -} // namespace llvm - -namespace clang { - /// Represents an access specifier followed by colon ':'. /// /// An objects of this class represents sugar for the syntactic occurrence @@ -3469,12 +3423,6 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl { return IsVirtual; } - /// Get the constructor or constructor template in the derived class - /// correspnding to this using shadow declaration, if it has been implicitly - /// declared already. - CXXConstructorDecl *getConstructor() const; - void setConstructor(NamedDecl *Ctor); - static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ConstructorUsingShadow; } }; diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 235b31c1c3120..cb04e78b3d52a 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -2527,10 +2527,6 @@ class ClassScopeFunctionSpecializationDecl : public Decl { } }; -/// Implementation of inline functions that require the template declarations -inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD) - : Function(FTD) {} - /// Represents a variable template specialization, which refers to /// a variable template with a given set of template arguments. /// diff --git a/clang/include/clang/Index/IndexingAction.h b/clang/include/clang/Index/IndexingAction.h index ce2ff0e105e5a..f0f10fbc88fde 100644 --- a/clang/include/clang/Index/IndexingAction.h +++ b/clang/include/clang/Index/IndexingAction.h @@ -9,6 +9,7 @@ #ifndef LLVM_CLANG_INDEX_INDEXINGACTION_H #define LLVM_CLANG_INDEX_INDEXINGACTION_H +#include "clang/AST/ASTConsumer.h" #include "clang/Basic/LLVM.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" @@ -51,10 +52,18 @@ struct IndexingOptions { }; /// Creates an ASTConsumer that indexes all symbols (macros and AST decls). -std::unique_ptr -createIndexingASTConsumer(std::shared_ptr DataConsumer, - const IndexingOptions &Opts, - std::shared_ptr PP); +std::unique_ptr createIndexingASTConsumer( + std::shared_ptr DataConsumer, + const IndexingOptions &Opts, std::shared_ptr PP, + std::function ShouldSkipFunctionBody); + +inline std::unique_ptr createIndexingASTConsumer( + std::shared_ptr DataConsumer, + const IndexingOptions &Opts, std::shared_ptr PP) { + return createIndexingASTConsumer( + std::move(DataConsumer), Opts, std::move(PP), + /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; }); +} /// Creates a frontend action that indexes all symbols (macros and AST decls). std::unique_ptr diff --git a/clang/lib/Index/IndexingAction.cpp b/clang/lib/Index/IndexingAction.cpp index e7079720140c9..6d6133e89d864 100644 --- a/clang/lib/Index/IndexingAction.cpp +++ b/clang/lib/Index/IndexingAction.cpp @@ -57,14 +57,17 @@ class IndexASTConsumer final : public ASTConsumer { std::shared_ptr DataConsumer; std::shared_ptr IndexCtx; std::shared_ptr PP; + std::function ShouldSkipFunctionBody; public: IndexASTConsumer(std::shared_ptr DataConsumer, const IndexingOptions &Opts, - std::shared_ptr PP) + std::shared_ptr PP, + std::function ShouldSkipFunctionBody) : DataConsumer(std::move(DataConsumer)), IndexCtx(new IndexingContext(Opts, *this->DataConsumer)), - PP(std::move(PP)) { + PP(std::move(PP)), + ShouldSkipFunctionBody(std::move(ShouldSkipFunctionBody)) { assert(this->DataConsumer != nullptr); assert(this->PP != nullptr); } @@ -92,6 +95,10 @@ class IndexASTConsumer final : public ASTConsumer { void HandleTranslationUnit(ASTContext &Ctx) override { DataConsumer->finish(); } + + bool shouldSkipFunctionBody(Decl *D) override { + return ShouldSkipFunctionBody(D); + } }; class IndexAction final : public ASTFrontendAction { @@ -108,18 +115,20 @@ class IndexAction final : public ASTFrontendAction { protected: std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { - return std::make_unique(DataConsumer, Opts, - CI.getPreprocessorPtr()); + return std::make_unique( + DataConsumer, Opts, CI.getPreprocessorPtr(), + /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; }); } }; } // anonymous namespace -std::unique_ptr -index::createIndexingASTConsumer(std::shared_ptr DataConsumer, - const IndexingOptions &Opts, - std::shared_ptr PP) { - return std::make_unique(DataConsumer, Opts, PP); +std::unique_ptr index::createIndexingASTConsumer( + std::shared_ptr DataConsumer, + const IndexingOptions &Opts, std::shared_ptr PP, + std::function ShouldSkipFunctionBody) { + return std::make_unique(DataConsumer, Opts, PP, + ShouldSkipFunctionBody); } std::unique_ptr diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index a808854ed98e3..703d3f212c339 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -824,11 +824,8 @@ VarDecl *Sema::createLambdaInitCaptureVarDecl(SourceLocation Loc, // FIXME: Retain the TypeSourceInfo from buildLambdaInitCaptureInitialization // rather than reconstructing it here. TypeSourceInfo *TSI = Context.getTrivialTypeSourceInfo(InitCaptureType, Loc); - bool IsInitCapturePack = false; - if (auto PETL = TSI->getTypeLoc().getAs()) { + if (auto PETL = TSI->getTypeLoc().getAs()) PETL.setEllipsisLoc(EllipsisLoc); - IsInitCapturePack = true; - } // Create a dummy variable representing the init-capture. This is not actually // used as a variable, and only exists as a way to name and refer to the diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index 372fb214a5ac1..5e567b3276aad 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/tools/libclang/Indexing.cpp @@ -297,54 +297,20 @@ class IndexPPCallbacks : public PPCallbacks { class IndexingConsumer : public ASTConsumer { CXIndexDataConsumer &DataConsumer; - ParsedSrcLocationsTracker *ParsedLocsTracker; public: IndexingConsumer(CXIndexDataConsumer &dataConsumer, ParsedSrcLocationsTracker *parsedLocsTracker) - : DataConsumer(dataConsumer), ParsedLocsTracker(parsedLocsTracker) {} - - // ASTConsumer Implementation + : DataConsumer(dataConsumer) {} void Initialize(ASTContext &Context) override { DataConsumer.setASTContext(Context); DataConsumer.startedTranslationUnit(); } - void HandleTranslationUnit(ASTContext &Ctx) override { - if (ParsedLocsTracker) - ParsedLocsTracker->syncWithStorage(); - } - bool HandleTopLevelDecl(DeclGroupRef DG) override { return !DataConsumer.shouldAbort(); } - - bool shouldSkipFunctionBody(Decl *D) override { - if (!ParsedLocsTracker) { - // Always skip bodies. - return true; - } - - const SourceManager &SM = DataConsumer.getASTContext().getSourceManager(); - SourceLocation Loc = D->getLocation(); - if (Loc.isMacroID()) - return false; - if (SM.isInSystemHeader(Loc)) - return true; // always skip bodies from system headers. - - FileID FID; - unsigned Offset; - std::tie(FID, Offset) = SM.getDecomposedLoc(Loc); - // Don't skip bodies from main files; this may be revisited. - if (SM.getMainFileID() == FID) - return false; - const FileEntry *FE = SM.getFileEntryForID(FID); - if (!FE) - return false; - - return ParsedLocsTracker->hasAlredyBeenParsed(Loc, FID, FE); - } }; //===----------------------------------------------------------------------===// @@ -404,11 +370,38 @@ class IndexingFrontendAction : public ASTFrontendAction { std::vector> Consumers; Consumers.push_back(std::make_unique( *DataConsumer, ParsedLocsTracker.get())); - Consumers.push_back( - createIndexingASTConsumer(DataConsumer, Opts, CI.getPreprocessorPtr())); + Consumers.push_back(createIndexingASTConsumer( + DataConsumer, Opts, CI.getPreprocessorPtr(), + [this](const Decl *D) { return this->shouldSkipFunctionBody(D); })); return std::make_unique(std::move(Consumers)); } + bool shouldSkipFunctionBody(const Decl *D) { + if (!ParsedLocsTracker) { + // Always skip bodies. + return true; + } + + const SourceManager &SM = D->getASTContext().getSourceManager(); + SourceLocation Loc = D->getLocation(); + if (Loc.isMacroID()) + return false; + if (SM.isInSystemHeader(Loc)) + return true; // always skip bodies from system headers. + + FileID FID; + unsigned Offset; + std::tie(FID, Offset) = SM.getDecomposedLoc(Loc); + // Don't skip bodies from main files; this may be revisited. + if (SM.getMainFileID() == FID) + return false; + const FileEntry *FE = SM.getFileEntryForID(FID); + if (!FE) + return false; + + return ParsedLocsTracker->hasAlredyBeenParsed(Loc, FID, FE); + } + TranslationUnitKind getTranslationUnitKind() override { if (DataConsumer->shouldIndexImplicitTemplateInsts()) return TU_Complete; @@ -416,6 +409,11 @@ class IndexingFrontendAction : public ASTFrontendAction { return TU_Prefix; } bool hasCodeCompletionSupport() const override { return false; } + + void EndSourceFileAction() override { + if (ParsedLocsTracker) + ParsedLocsTracker->syncWithStorage(); + } }; //===----------------------------------------------------------------------===// diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index d0d656d2476e2..afb91c726e4ba 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -840,6 +840,9 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase { if (isa(U)) return TTI::TCC_Free; // Model all PHI nodes as free. + if (isa(U)) + return TTI::TCC_Free; // Model all ExtractValue nodes as free. + // Static alloca doesn't generate target instructions. if (auto *A = dyn_cast(U)) if (A->isStaticAlloca()) diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index ee96a9da03a45..c463d82fca0c0 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -1286,6 +1286,8 @@ int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const { return getVectorInstrCost(I->getOpcode(), IE->getType(), Idx); } + case Instruction::ExtractValue: + return 0; // Model all ExtractValue nodes as free. case Instruction::ShuffleVector: { const ShuffleVectorInst *Shuffle = cast(I); Type *Ty = Shuffle->getType(); diff --git a/llvm/test/Analysis/CostModel/AArch64/aggregates.ll b/llvm/test/Analysis/CostModel/AArch64/aggregates.ll index c8b9f283f44a0..35d232b3b69ab 100644 --- a/llvm/test/Analysis/CostModel/AArch64/aggregates.ll +++ b/llvm/test/Analysis/CostModel/AArch64/aggregates.ll @@ -5,15 +5,15 @@ define i32 @extract_first_i32({i32, i32} %agg) { ; THROUGHPUT-LABEL: 'extract_first_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_first_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_first_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i32} %agg, 0 @@ -22,15 +22,15 @@ define i32 @extract_first_i32({i32, i32} %agg) { define i32 @extract_second_i32({i32, i32} %agg) { ; THROUGHPUT-LABEL: 'extract_second_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_second_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_second_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i32} %agg, 1 @@ -39,15 +39,15 @@ define i32 @extract_second_i32({i32, i32} %agg) { define i32 @extract_i32({i32, i1} %agg) { ; THROUGHPUT-LABEL: 'extract_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i1} %agg, 0 @@ -56,15 +56,15 @@ define i32 @extract_i32({i32, i1} %agg) { define i1 @extract_i1({i32, i1} %agg) { ; THROUGHPUT-LABEL: 'extract_i1' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i1 %r ; ; LATENCY-LABEL: 'extract_i1' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r ; ; CODESIZE-LABEL: 'extract_i1' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r ; %r = extractvalue {i32, i1} %agg, 1 @@ -73,15 +73,15 @@ define i1 @extract_i1({i32, i1} %agg) { define float @extract_float({i32, float} %agg) { ; THROUGHPUT-LABEL: 'extract_float' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, float } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %r ; ; LATENCY-LABEL: 'extract_float' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %r = extractvalue { i32, float } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r ; ; CODESIZE-LABEL: 'extract_float' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, float } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r ; %r = extractvalue {i32, float} %agg, 1 @@ -90,15 +90,15 @@ define float @extract_float({i32, float} %agg) { define [42 x i42] @extract_array({i32, [42 x i42]} %agg) { ; THROUGHPUT-LABEL: 'extract_array' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret [42 x i42] %r ; ; LATENCY-LABEL: 'extract_array' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r ; ; CODESIZE-LABEL: 'extract_array' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r ; %r = extractvalue {i32, [42 x i42]} %agg, 1 @@ -107,15 +107,15 @@ define [42 x i42] @extract_array({i32, [42 x i42]} %agg) { define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) { ; THROUGHPUT-LABEL: 'extract_vector' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <42 x i42> %r ; ; LATENCY-LABEL: 'extract_vector' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r ; ; CODESIZE-LABEL: 'extract_vector' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r ; %r = extractvalue {i32, <42 x i42>} %agg, 1 @@ -126,15 +126,15 @@ define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) { define %T1 @extract_struct({i32, %T1} %agg) { ; THROUGHPUT-LABEL: 'extract_struct' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret %T1 %r ; ; LATENCY-LABEL: 'extract_struct' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r ; ; CODESIZE-LABEL: 'extract_struct' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r ; %r = extractvalue {i32, %T1} %agg, 1 diff --git a/llvm/test/Analysis/CostModel/X86/aggregates.ll b/llvm/test/Analysis/CostModel/X86/aggregates.ll index 2fcdd5fbd2e2c..3fd97d8bf1505 100644 --- a/llvm/test/Analysis/CostModel/X86/aggregates.ll +++ b/llvm/test/Analysis/CostModel/X86/aggregates.ll @@ -5,15 +5,15 @@ define i32 @extract_first_i32({i32, i32} %agg) { ; THROUGHPUT-LABEL: 'extract_first_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_first_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_first_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 0 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 0 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i32} %agg, 0 @@ -22,15 +22,15 @@ define i32 @extract_first_i32({i32, i32} %agg) { define i32 @extract_second_i32({i32, i32} %agg) { ; THROUGHPUT-LABEL: 'extract_second_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_second_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_second_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i32 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i32 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i32} %agg, 1 @@ -39,15 +39,15 @@ define i32 @extract_second_i32({i32, i32} %agg) { define i32 @extract_i32({i32, i1} %agg) { ; THROUGHPUT-LABEL: 'extract_i32' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %r ; ; LATENCY-LABEL: 'extract_i32' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; ; CODESIZE-LABEL: 'extract_i32' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 0 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 0 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %r ; %r = extractvalue {i32, i1} %agg, 0 @@ -56,15 +56,15 @@ define i32 @extract_i32({i32, i1} %agg) { define i1 @extract_i1({i32, i1} %agg) { ; THROUGHPUT-LABEL: 'extract_i1' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i1 %r ; ; LATENCY-LABEL: 'extract_i1' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r ; ; CODESIZE-LABEL: 'extract_i1' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, i1 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, i1 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i1 %r ; %r = extractvalue {i32, i1} %agg, 1 @@ -73,15 +73,15 @@ define i1 @extract_i1({i32, i1} %agg) { define float @extract_float({i32, float} %agg) { ; THROUGHPUT-LABEL: 'extract_float' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, float } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret float %r ; ; LATENCY-LABEL: 'extract_float' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 3 for instruction: %r = extractvalue { i32, float } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r ; ; CODESIZE-LABEL: 'extract_float' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, float } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, float } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret float %r ; %r = extractvalue {i32, float} %agg, 1 @@ -90,15 +90,15 @@ define float @extract_float({i32, float} %agg) { define [42 x i42] @extract_array({i32, [42 x i42]} %agg) { ; THROUGHPUT-LABEL: 'extract_array' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret [42 x i42] %r ; ; LATENCY-LABEL: 'extract_array' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r ; ; CODESIZE-LABEL: 'extract_array' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, [42 x i42] } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret [42 x i42] %r ; %r = extractvalue {i32, [42 x i42]} %agg, 1 @@ -107,15 +107,15 @@ define [42 x i42] @extract_array({i32, [42 x i42]} %agg) { define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) { ; THROUGHPUT-LABEL: 'extract_vector' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <42 x i42> %r ; ; LATENCY-LABEL: 'extract_vector' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r ; ; CODESIZE-LABEL: 'extract_vector' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, <42 x i42> } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret <42 x i42> %r ; %r = extractvalue {i32, <42 x i42>} %agg, 1 @@ -126,15 +126,15 @@ define <42 x i42> @extract_vector({i32, <42 x i42>} %agg) { define %T1 @extract_struct({i32, %T1} %agg) { ; THROUGHPUT-LABEL: 'extract_struct' -; THROUGHPUT-NEXT: Cost Model: Unknown cost for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; THROUGHPUT-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret %T1 %r ; ; LATENCY-LABEL: 'extract_struct' -; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r ; ; CODESIZE-LABEL: 'extract_struct' -; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 +; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = extractvalue { i32, %T1 } %agg, 1 ; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret %T1 %r ; %r = extractvalue {i32, %T1} %agg, 1