-
Notifications
You must be signed in to change notification settings - Fork 16.3k
[LLVM] Successor count added to InstCount #171670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
33666b5
Format correction and return of InstCount
InakiVA cfe6a41
Clang format
InakiVA 8fad9c0
Clang format again
InakiVA 0d1c334
Clang format again and again
InakiVA 0f36c80
Clang format again and again }
InakiVA 1c00df2
func-properties-count name of stat
InakiVA deaf021
Updated colon
InakiVA 9b042e5
Added macro with stats
InakiVA eebacad
Clang format
InakiVA 67dd577
Merge branch 'main' into 4metrics
InakiVA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| //===-- llvm/FunctionProperties.def - File that describes Function Properties | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file contains descriptions of the various LLVM function properties. This | ||
| // is used as a central place for enumerating the different function properties | ||
| // and should eventually be the place to put comments about the function | ||
| // properties. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // NOTE: NO INCLUDE GUARD DESIRED! | ||
|
|
||
| // Provide definitions of macros so that users of this file do not have to | ||
| // define everything to use it. | ||
| // | ||
|
|
||
| // Basic/Standard Properties | ||
| #ifndef FUNCTION_PROPERTY | ||
| #define FUNCTION_PROPERTY(Name, Description) | ||
| #endif | ||
|
|
||
| // Detailed Properties (only processed if DETAILED_FUNCTION_PROPERTY is defined) | ||
| #ifndef DETAILED_FUNCTION_PROPERTY | ||
| #define DETAILED_FUNCTION_PROPERTY(Name, Description) | ||
| #endif | ||
|
|
||
| FUNCTION_PROPERTY(BasicBlockCount, "Number of basic blocks") | ||
InakiVA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FUNCTION_PROPERTY(BlocksReachedFromConditionalInstruction, | ||
| "Number of blocks reached from a conditional instruction, or " | ||
| "that are 'cases' of a SwitchInstr") | ||
| FUNCTION_PROPERTY(Uses, "Number of uses of this function, plus 1 if the " | ||
| "function is callable outside the module") | ||
| FUNCTION_PROPERTY(DirectCallsToDefinedFunctions, | ||
| "Number of direct calls made from this function to other " | ||
| "functions defined in this module") | ||
| FUNCTION_PROPERTY(LoadInstCount, "Load Instruction Count") | ||
| FUNCTION_PROPERTY(StoreInstCount, "Store Instruction Count") | ||
| FUNCTION_PROPERTY(MaxLoopDepth, "Maximum Loop Depth in the Function") | ||
| FUNCTION_PROPERTY(TopLevelLoopCount, | ||
| "Number of Top Level Loops in the Function") | ||
| FUNCTION_PROPERTY(TotalInstructionCount, | ||
| "Number of instructions (of all types)") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithSingleSuccessor, | ||
| "Basic blocks with one successors") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithTwoSuccessors, | ||
| "Basic blocks with two successors") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithMoreThanTwoSuccessors, | ||
| "Basic blocks with more than two successors") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithSinglePredecessor, | ||
| "Basic blocks with one predecessors") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithTwoPredecessors, | ||
| "Basic blocks with two predecessors") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlocksWithMoreThanTwoPredecessors, | ||
| "Basic blocks with more than two predecessors") | ||
| DETAILED_FUNCTION_PROPERTY(BigBasicBlocks, "Number of big basic blocks") | ||
| DETAILED_FUNCTION_PROPERTY(MediumBasicBlocks, "Number of medium basic blocks") | ||
| DETAILED_FUNCTION_PROPERTY(SmallBasicBlocks, "Number of small basic blocks") | ||
| DETAILED_FUNCTION_PROPERTY(CastInstructionCount, | ||
| "The number of cast instructions inside the function") | ||
| DETAILED_FUNCTION_PROPERTY( | ||
| FloatingPointInstructionCount, | ||
| "The number of floating point instructions inside the function") | ||
| DETAILED_FUNCTION_PROPERTY(IntegerInstructionCount, | ||
| "The number of integer instructions inside the function") | ||
| DETAILED_FUNCTION_PROPERTY(ConstantIntOperandCount, "Constant Int Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(ConstantFPOperandCount, "Constant FP Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(ConstantOperandCount, "Constant Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(InstructionOperandCount, "Instruction Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(BasicBlockOperandCount, "Basic Block Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(GlobalValueOperandCount, "Global Value Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(InlineAsmOperandCount, "Inline Asm Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(ArgumentOperandCount, "Argument Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(UnknownOperandCount, "Unknown Operand Count") | ||
| DETAILED_FUNCTION_PROPERTY(CriticalEdgeCount, "Critical Edge Count") | ||
| DETAILED_FUNCTION_PROPERTY(ControlFlowEdgeCount, "Number of basic block successors") | ||
| DETAILED_FUNCTION_PROPERTY(UnconditionalBranchCount, | ||
| "Number of unconditional branch instructions") | ||
| DETAILED_FUNCTION_PROPERTY(ConditionalBranchCount, | ||
| "Number of conditional branch instructions") | ||
| DETAILED_FUNCTION_PROPERTY(BranchInstructionCount, "Number of branch instructions") | ||
| DETAILED_FUNCTION_PROPERTY(BranchSuccessorCount, "Number of branch successors") | ||
| DETAILED_FUNCTION_PROPERTY(SwitchInstructionCount, "Number of switch instructions") | ||
| DETAILED_FUNCTION_PROPERTY(SwitchSuccessorCount, "Number of switch successors") | ||
| DETAILED_FUNCTION_PROPERTY(IntrinsicCount, "Intrinsic Count") | ||
| DETAILED_FUNCTION_PROPERTY(DirectCallCount, "Direct Call Count") | ||
| DETAILED_FUNCTION_PROPERTY(IndirectCallCount, "Indirect Call Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsIntegerCount, "Call Returns Integer Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsFloatCount, "Call Returns Float Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsPointerCount, "Call Returns Pointer Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsVectorIntCount, "Call Returns Vector Int Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsVectorFloatCount, | ||
| "Call Returns Vector Float Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallReturnsVectorPointerCount, | ||
| "Call Returns Vector Pointer Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallWithManyArgumentsCount, "Call With Many Arguments Count") | ||
| DETAILED_FUNCTION_PROPERTY(CallWithPointerArgumentCount, | ||
| "Call With Pointer Argument Count") | ||
|
|
||
| #undef FUNCTION_PROPERTY | ||
| #undef DETAILED_FUNCTION_PROPERTY | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| ; Testing with all of the below run lines that the pass gets added to the appropriate pipelines | ||
| ; REQUIRES: asserts | ||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes=func-properties-stats < %s 2>&1 | FileCheck %s | ||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto<O3>'< %s 2>&1 | FileCheck %s | ||
InakiVA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='thinlto-pre-link<O2>' < %s 2>&1 | FileCheck %s | ||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -passes='lto<O1>' < %s 2>&1 | FileCheck %s | ||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -O3 < %s 2>&1 | FileCheck %s | ||
| ; RUN: opt -stats -enable-detailed-function-properties -disable-output -O0 < %s 2>&1 | FileCheck %s | ||
|
|
||
| ; CHECK-DAG: 10 func-properties-stats - Number of basic blocks | ||
| ; CHECK-DAG: 8 func-properties-stats - Number of branch instructions | ||
| ; CHECK-DAG: 10 func-properties-stats - Number of branch successors | ||
| ; CHECK-DAG: 2 func-properties-stats - Number of conditional branch instructions | ||
| ; CHECK-DAG: 6 func-properties-stats - Number of unconditional branch instructions | ||
| ; CHECK-DAG: 18 func-properties-stats - Number of instructions (of all types) | ||
| ; CHECK-DAG: 14 func-properties-stats - Number of basic block successors | ||
| ; CHECK-DAG: 1 func-properties-stats - Number of switch instructions | ||
| ; CHECK-DAG: 4 func-properties-stats - Number of switch successors | ||
|
|
||
|
|
||
| define void @foo(i32 %i, i32 %j, i32 %n) { | ||
| entry: | ||
| %cmp = icmp slt i32 %i, %j | ||
| br i1 %cmp, label %if.then, label %if.end | ||
|
|
||
| if.then: | ||
| call void @f() | ||
| br label %if.end | ||
|
|
||
| if.end: | ||
| switch i32 %i, label %sw.default [ | ||
| i32 1, label %sw.bb | ||
| i32 2, label %sw.bb1 | ||
| i32 3, label %sw.bb1 | ||
| ] | ||
|
|
||
| sw.bb: | ||
| call void @g() | ||
| br label %sw.epilog | ||
|
|
||
| sw.bb1: | ||
| call void @h() | ||
| br label %sw.epilog | ||
|
|
||
| sw.default: | ||
| call void @k() | ||
| br label %sw.epilog | ||
|
|
||
| sw.epilog: | ||
| %cmp2 = icmp sgt i32 %i, %n | ||
| br i1 %cmp2, label %if.then3, label %if.else | ||
|
|
||
| if.then3: | ||
| call void @l() | ||
| br label %if.end4 | ||
|
|
||
| if.else: | ||
| call void @m() | ||
| br label %if.end4 | ||
|
|
||
| if.end4: | ||
| ret void | ||
| } | ||
|
|
||
| declare void @f() | ||
| declare void @g() | ||
| declare void @h() | ||
| declare void @k() | ||
| declare void @l() | ||
| declare void @m() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use FunctionProperties.def here as well?