diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 95a8e2c8b2660..09d024e9e83a3 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -4951,6 +4951,9 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) { } Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { + auto HasLHSSkip = CGF.getIsCounterPair(E); + auto HasRHSSkip = CGF.getIsCounterPair(E->getRHS()); + // Perform vector logical and on comparisons with zero vectors. if (E->getType()->isVectorType()) { CGF.incrementProfileCounter(E); @@ -4979,7 +4982,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { bool LHSCondVal; if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { if (LHSCondVal) { // If we have 1 && X, just emit X. - CGF.incrementProfileCounter(E); + CGF.incrementProfileCounter(CGF.UseExecPath, E, /*UseBoth=*/true); // If the top of the logical operator nest, reset the MCDC temp to 0. if (CGF.MCDCLogOpStack.empty()) @@ -4997,11 +5000,17 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { CodeGenFunction::isInstrumentedCondition(E->getRHS())) { CGF.maybeUpdateMCDCCondBitmap(E->getRHS(), RHSCond); llvm::BasicBlock *FBlock = CGF.createBasicBlock("land.end"); + llvm::BasicBlock *RHSSkip = + (HasRHSSkip.second ? CGF.createBasicBlock("land.rhsskip") : FBlock); llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock("land.rhscnt"); - Builder.CreateCondBr(RHSCond, RHSBlockCnt, FBlock); + Builder.CreateCondBr(RHSCond, RHSBlockCnt, RHSSkip); CGF.EmitBlock(RHSBlockCnt); - CGF.incrementProfileCounter(E->getRHS()); + CGF.incrementProfileCounter(CGF.UseExecPath, E->getRHS()); CGF.EmitBranch(FBlock); + if (HasRHSSkip.second) { + CGF.EmitBlock(RHSSkip); + CGF.incrementProfileCounter(CGF.UseSkipPath, E->getRHS()); + } CGF.EmitBlock(FBlock); } else CGF.markStmtMaybeUsed(E->getRHS()); @@ -5017,7 +5026,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { // 0 && RHS: If it is safe, just elide the RHS, and return 0/false. if (!CGF.ContainsLabel(E->getRHS())) { + CGF.markStmtAsUsed(false, E); + if (HasLHSSkip.second) + CGF.incrementProfileCounter(CGF.UseSkipPath, E); + CGF.markStmtMaybeUsed(E->getRHS()); + return llvm::Constant::getNullValue(ResTy); } } @@ -5031,12 +5045,21 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { llvm::BasicBlock *ContBlock = CGF.createBasicBlock("land.end"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("land.rhs"); + llvm::BasicBlock *LHSFalseBlock = + (HasLHSSkip.second ? CGF.createBasicBlock("land.lhsskip") : ContBlock); + CodeGenFunction::ConditionalEvaluation eval(CGF); // Branch on the LHS first. If it is false, go to the failure (cont) block. - CGF.EmitBranchOnBoolExpr(E->getLHS(), RHSBlock, ContBlock, + CGF.EmitBranchOnBoolExpr(E->getLHS(), RHSBlock, LHSFalseBlock, CGF.getProfileCount(E->getRHS())); + if (HasLHSSkip.second) { + CGF.EmitBlock(LHSFalseBlock); + CGF.incrementProfileCounter(CGF.UseSkipPath, E); + CGF.EmitBranch(ContBlock); + } + // Any edges into the ContBlock are now from an (indeterminate number of) // edges from this first condition. All of these values will be false. Start // setting up the PHI node in the Cont Block for this. @@ -5048,7 +5071,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { eval.begin(CGF); CGF.EmitBlock(RHSBlock); - CGF.incrementProfileCounter(E); + CGF.incrementProfileCounter(CGF.UseExecPath, E); Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); eval.end(CGF); @@ -5058,15 +5081,24 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { // If we're generating for profiling or coverage, generate a branch on the // RHS to a block that increments the RHS true counter needed to track branch // condition coverage. + llvm::BasicBlock *ContIncoming = RHSBlock; if (InstrumentRegions && CodeGenFunction::isInstrumentedCondition(E->getRHS())) { CGF.maybeUpdateMCDCCondBitmap(E->getRHS(), RHSCond); llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock("land.rhscnt"); - Builder.CreateCondBr(RHSCond, RHSBlockCnt, ContBlock); + llvm::BasicBlock *RHSBlockSkip = + (HasRHSSkip.second ? CGF.createBasicBlock("land.rhsskip") : ContBlock); + Builder.CreateCondBr(RHSCond, RHSBlockCnt, RHSBlockSkip); CGF.EmitBlock(RHSBlockCnt); - CGF.incrementProfileCounter(E->getRHS()); + CGF.incrementProfileCounter(CGF.UseExecPath, E->getRHS()); CGF.EmitBranch(ContBlock); PN->addIncoming(RHSCond, RHSBlockCnt); + if (HasRHSSkip.second) { + CGF.EmitBlock(RHSBlockSkip); + CGF.incrementProfileCounter(CGF.UseSkipPath, E->getRHS()); + CGF.EmitBranch(ContBlock); + ContIncoming = RHSBlockSkip; + } } // Emit an unconditional branch from this block to ContBlock. @@ -5076,7 +5108,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { CGF.EmitBlock(ContBlock); } // Insert an entry into the phi node for the edge with the value of RHSCond. - PN->addIncoming(RHSCond, RHSBlock); + PN->addIncoming(RHSCond, ContIncoming); CGF.MCDCLogOpStack.pop_back(); // If the top of the logical operator nest, update the MCDC bitmap. @@ -5094,6 +5126,9 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { } Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { + auto HasLHSSkip = CGF.getIsCounterPair(E); + auto HasRHSSkip = CGF.getIsCounterPair(E->getRHS()); + // Perform vector logical or on comparisons with zero vectors. if (E->getType()->isVectorType()) { CGF.incrementProfileCounter(E); @@ -5122,7 +5157,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { bool LHSCondVal; if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { if (!LHSCondVal) { // If we have 0 || X, just emit X. - CGF.incrementProfileCounter(E); + CGF.incrementProfileCounter(CGF.UseExecPath, E, /*UseBoth=*/true); // If the top of the logical operator nest, reset the MCDC temp to 0. if (CGF.MCDCLogOpStack.empty()) @@ -5140,11 +5175,17 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { CodeGenFunction::isInstrumentedCondition(E->getRHS())) { CGF.maybeUpdateMCDCCondBitmap(E->getRHS(), RHSCond); llvm::BasicBlock *FBlock = CGF.createBasicBlock("lor.end"); + llvm::BasicBlock *RHSSkip = + (HasRHSSkip.second ? CGF.createBasicBlock("lor.rhsskip") : FBlock); llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock("lor.rhscnt"); - Builder.CreateCondBr(RHSCond, FBlock, RHSBlockCnt); + Builder.CreateCondBr(RHSCond, RHSSkip, RHSBlockCnt); CGF.EmitBlock(RHSBlockCnt); - CGF.incrementProfileCounter(E->getRHS()); + CGF.incrementProfileCounter(CGF.UseExecPath, E->getRHS()); CGF.EmitBranch(FBlock); + if (HasRHSSkip.second) { + CGF.EmitBlock(RHSSkip); + CGF.incrementProfileCounter(CGF.UseSkipPath, E->getRHS()); + } CGF.EmitBlock(FBlock); } else CGF.markStmtMaybeUsed(E->getRHS()); @@ -5160,7 +5201,12 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { // 1 || RHS: If it is safe, just elide the RHS, and return 1/true. if (!CGF.ContainsLabel(E->getRHS())) { + CGF.markStmtAsUsed(false, E); + if (HasLHSSkip.second) + CGF.incrementProfileCounter(CGF.UseSkipPath, E); + CGF.markStmtMaybeUsed(E->getRHS()); + return llvm::ConstantInt::get(ResTy, 1); } } @@ -5173,14 +5219,22 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("lor.rhs"); + llvm::BasicBlock *LHSTrueBlock = + (HasLHSSkip.second ? CGF.createBasicBlock("lor.lhsskip") : ContBlock); CodeGenFunction::ConditionalEvaluation eval(CGF); // Branch on the LHS first. If it is true, go to the success (cont) block. - CGF.EmitBranchOnBoolExpr(E->getLHS(), ContBlock, RHSBlock, + CGF.EmitBranchOnBoolExpr(E->getLHS(), LHSTrueBlock, RHSBlock, CGF.getCurrentProfileCount() - CGF.getProfileCount(E->getRHS())); + if (HasLHSSkip.second) { + CGF.EmitBlock(LHSTrueBlock); + CGF.incrementProfileCounter(CGF.UseSkipPath, E); + CGF.EmitBranch(ContBlock); + } + // Any edges into the ContBlock are now from an (indeterminate number of) // edges from this first condition. All of these values will be true. Start // setting up the PHI node in the Cont Block for this. @@ -5194,7 +5248,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { // Emit the RHS condition as a bool value. CGF.EmitBlock(RHSBlock); - CGF.incrementProfileCounter(E); + CGF.incrementProfileCounter(CGF.UseExecPath, E); Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); eval.end(CGF); @@ -5205,21 +5259,30 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { // If we're generating for profiling or coverage, generate a branch on the // RHS to a block that increments the RHS true counter needed to track branch // condition coverage. + llvm::BasicBlock *ContIncoming = RHSBlock; if (InstrumentRegions && CodeGenFunction::isInstrumentedCondition(E->getRHS())) { CGF.maybeUpdateMCDCCondBitmap(E->getRHS(), RHSCond); llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock("lor.rhscnt"); - Builder.CreateCondBr(RHSCond, ContBlock, RHSBlockCnt); + llvm::BasicBlock *RHSTrueBlock = + (HasRHSSkip.second ? CGF.createBasicBlock("lor.rhsskip") : ContBlock); + Builder.CreateCondBr(RHSCond, RHSTrueBlock, RHSBlockCnt); CGF.EmitBlock(RHSBlockCnt); - CGF.incrementProfileCounter(E->getRHS()); + CGF.incrementProfileCounter(CGF.UseExecPath, E->getRHS()); CGF.EmitBranch(ContBlock); PN->addIncoming(RHSCond, RHSBlockCnt); + if (HasRHSSkip.second) { + CGF.EmitBlock(RHSTrueBlock); + CGF.incrementProfileCounter(CGF.UseSkipPath, E->getRHS()); + CGF.EmitBranch(ContBlock); + ContIncoming = RHSTrueBlock; + } } // Emit an unconditional branch from this block to ContBlock. Insert an entry // into the phi node for the edge with the value of RHSCond. CGF.EmitBlock(ContBlock); - PN->addIncoming(RHSCond, RHSBlock); + PN->addIncoming(RHSCond, ContIncoming); CGF.MCDCLogOpStack.pop_back(); // If the top of the logical operator nest, update the MCDC bitmap. diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 7900a575f6249..31044d85e60f0 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -43,10 +43,6 @@ using namespace CodeGen; // Statement Emission //===----------------------------------------------------------------------===// -namespace llvm { -extern cl::opt EnableSingleByteCoverage; -} // namespace llvm - void CodeGenFunction::EmitStopPoint(const Stmt *S) { if (CGDebugInfo *DI = getDebugInfo()) { SourceLocation Loc; diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 14c73fc5ffb5e..435d6a8b6271a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1769,6 +1769,7 @@ void CodeGenFunction::EmitBranchToCounterBlock( return EmitBranchOnBoolExpr(Cond, TrueBlock, FalseBlock, TrueCount, LH); const Stmt *CntrStmt = (CntrIdx ? CntrIdx : Cond); + auto HasSkip = getIsCounterPair(CntrStmt); llvm::BasicBlock *ThenBlock = nullptr; llvm::BasicBlock *ElseBlock = nullptr; @@ -1777,6 +1778,10 @@ void CodeGenFunction::EmitBranchToCounterBlock( // Create the block we'll use to increment the appropriate counter. llvm::BasicBlock *CounterIncrBlock = createBasicBlock("lop.rhscnt"); + llvm::BasicBlock *SkipIncrBlock = + (HasSkip.second ? createBasicBlock("lop.rhsskip") : nullptr); + llvm::BasicBlock *SkipNextBlock = nullptr; + // Set block pointers according to Logical-AND (BO_LAnd) semantics. This // means we need to evaluate the condition and increment the counter on TRUE: // @@ -1790,8 +1795,9 @@ void CodeGenFunction::EmitBranchToCounterBlock( // goto TrueBlock; if (LOp == BO_LAnd) { + SkipNextBlock = FalseBlock; ThenBlock = CounterIncrBlock; - ElseBlock = FalseBlock; + ElseBlock = (SkipIncrBlock ? SkipIncrBlock : SkipNextBlock); NextBlock = TrueBlock; } @@ -1808,7 +1814,8 @@ void CodeGenFunction::EmitBranchToCounterBlock( // goto FalseBlock; else if (LOp == BO_LOr) { - ThenBlock = TrueBlock; + SkipNextBlock = TrueBlock; + ThenBlock = (SkipIncrBlock ? SkipIncrBlock : SkipNextBlock); ElseBlock = CounterIncrBlock; NextBlock = FalseBlock; } else { @@ -1818,11 +1825,17 @@ void CodeGenFunction::EmitBranchToCounterBlock( // Emit Branch based on condition. EmitBranchOnBoolExpr(Cond, ThenBlock, ElseBlock, TrueCount, LH); + if (SkipIncrBlock) { + EmitBlock(SkipIncrBlock); + incrementProfileCounter(UseSkipPath, CntrStmt); + EmitBranch(SkipNextBlock); + } + // Emit the block containing the counter increment(s). EmitBlock(CounterIncrBlock); // Increment corresponding counter; if index not provided, use Cond as index. - incrementProfileCounter(CntrStmt); + incrementProfileCounter(UseExecPath, CntrStmt); // Go to the next block. EmitBranch(NextBlock); @@ -1841,6 +1854,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr( Cond = Cond->IgnoreParens(); if (const BinaryOperator *CondBOp = dyn_cast(Cond)) { + auto HasSkip = getIsCounterPair(CondBOp); + // Handle X && Y in a condition. if (CondBOp->getOpcode() == BO_LAnd) { MCDCLogOpStack.push_back(CondBOp); @@ -1872,6 +1887,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr( // Emit the LHS as a conditional. If the LHS conditional is false, we // want to jump to the FalseBlock. llvm::BasicBlock *LHSTrue = createBasicBlock("land.lhs.true"); + llvm::BasicBlock *LHSFalse = + (HasSkip.second ? createBasicBlock("land.lhsskip") : FalseBlock); // The counter tells us how often we evaluate RHS, and all of TrueCount // can be propagated to that branch. uint64_t RHSCount = getProfileCount(CondBOp->getRHS()); @@ -1882,12 +1899,17 @@ void CodeGenFunction::EmitBranchOnBoolExpr( // Propagate the likelihood attribute like __builtin_expect // __builtin_expect(X && Y, 1) -> X and Y are likely // __builtin_expect(X && Y, 0) -> only Y is unlikely - EmitBranchOnBoolExpr(CondBOp->getLHS(), LHSTrue, FalseBlock, RHSCount, + EmitBranchOnBoolExpr(CondBOp->getLHS(), LHSTrue, LHSFalse, RHSCount, LH == Stmt::LH_Unlikely ? Stmt::LH_None : LH); + if (HasSkip.second) { + EmitBlock(LHSFalse); + incrementProfileCounter(UseSkipPath, CondBOp); + EmitBranch(FalseBlock); + } EmitBlock(LHSTrue); } - incrementProfileCounter(CondBOp); + incrementProfileCounter(UseExecPath, CondBOp); setCurrentProfileCount(getProfileCount(CondBOp->getRHS())); // Any temporaries created here are conditional. @@ -1927,6 +1949,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr( } // Emit the LHS as a conditional. If the LHS conditional is true, we // want to jump to the TrueBlock. + llvm::BasicBlock *LHSTrue = + (HasSkip.second ? createBasicBlock("lor.lhsskip") : TrueBlock); llvm::BasicBlock *LHSFalse = createBasicBlock("lor.lhs.false"); // We have the count for entry to the RHS and for the whole expression // being true, so we can divy up True count between the short circuit and @@ -1941,12 +1965,17 @@ void CodeGenFunction::EmitBranchOnBoolExpr( // __builtin_expect(X || Y, 1) -> only Y is likely // __builtin_expect(X || Y, 0) -> both X and Y are unlikely ApplyDebugLocation DL(*this, Cond); - EmitBranchOnBoolExpr(CondBOp->getLHS(), TrueBlock, LHSFalse, LHSCount, + EmitBranchOnBoolExpr(CondBOp->getLHS(), LHSTrue, LHSFalse, LHSCount, LH == Stmt::LH_Likely ? Stmt::LH_None : LH); + if (HasSkip.second) { + EmitBlock(LHSTrue); + incrementProfileCounter(UseSkipPath, CondBOp); + EmitBranch(TrueBlock); + } EmitBlock(LHSFalse); } - incrementProfileCounter(CondBOp); + incrementProfileCounter(UseExecPath, CondBOp); setCurrentProfileCount(getProfileCount(CondBOp->getRHS())); // Any temporaries created here are conditional. diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index f6d0f156c694f..98187780c6f88 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -2236,9 +2236,6 @@ struct CounterCoverageMappingBuilder extendRegion(E->getRHS()); propagateCounts(getRegionCounter(E), E->getRHS()); - if (llvm::EnableSingleByteCoverage) - return; - // Track RHS True/False Decision. const auto DecisionRHS = MCDCBuilder.back(); @@ -2297,9 +2294,6 @@ struct CounterCoverageMappingBuilder extendRegion(E->getRHS()); propagateCounts(getRegionCounter(E), E->getRHS()); - if (llvm::EnableSingleByteCoverage) - return; - // Track RHS True/False Decision. const auto DecisionRHS = MCDCBuilder.back(); diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext index 1606f292c1786..0f89783360241 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext +++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext @@ -36,7 +36,7 @@ boolean_operators # Func Hash: 1245693242827665 # Num Counters: -14 +26 # Counter Values: 1 1 @@ -52,12 +52,24 @@ boolean_operators 1 1 1 +1 +1 +1 +0 +1 +1 +1 +1 +1 +1 +1 +0 boolop_loops # Func Hash: 12402604614320574815 # Num Counters: -13 +21 # Counter Values: 1 1 @@ -72,6 +84,14 @@ boolop_loops 1 1 1 +0 +1 +1 +1 +0 +1 +1 +1 branch-c-general.c:static_func # Func Hash: @@ -98,7 +118,7 @@ conditionals # Func Hash: 4904767535850050386 # Num Counters: -20 +24 # Counter Values: 1 1 @@ -119,6 +139,10 @@ conditionals 0 1 1 +0 +1 +1 +0 1 do_fallthrough diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml index 2d6324fad688c..ec5ab0a105ced 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml +++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml @@ -16,7 +16,7 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: 83AD05A5F1438E680C01000052D33558163C11444C551E9517F40F4F01010101052A0111150E02030113001A2005010013001A05001C001F05002000A1808080080500210B04050109000E2009350009000E09000F009080808008090010020609010B000C200D39000B000C0D000D008E808080080D000E0010350106008C8080800835000C0406350010001520113D00100015110016009780808008110017020611010B000C201541000B000C15000D008E8080800815000E00103D0106008C808080083D000C02063D010B000C201945000B000C19000D008E8080800819000E0010100201005B050109000A050009000F21000E000F1D00100091808080081D00110013050109000A050009000F2D000E000F29001000918080800829001100131002010001 + Content: 83AD05A5F1438E682801000052D33558163C11444C551E9517F40F4F01010101052E0111150E02030113001A2005010013001A05001C001F05002000A1808080080500210B04050109000E2009350009000E09000F009080808008090010020609010B000C200D39000B000C0D000D008E808080080D000E0010350106008C8080800835000C0406350010001520113D00100015110016009780808008110017020611010B000C201541000B000C15000D008E8080800815000E00103D0106008C808080083D000C02063D010B000C201945000B000C19000D008E8080800819000E0010100201005B050109000A050009000F2021000009000A21000E000F202551000E000F1D00100091808080081D00110013050109000A050009000F20002D0009000A2D000E000F205D31000E000F29001000918080800829001100131002010001 - Name: '__llvm_covfun (2)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] @@ -41,12 +41,12 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: 59A48AA8899AA3587B00000091E33C8FF36C04004C551E9517F40F4F01010101051601B4011A0C02030213001A2005010013001A05001C001F05002000A1808080080500210804050109000E0900120013100101005D050109000E1100120013100101005D050109000E0500090017210012001719001B001C1001010063050109000E0500090017310012001729001B001C1002010063 + Content: 59A48AA8899AA358C100000091E33C8FF36C04004C551E9517F40F4F01010101052001B4011A0C02030213001A2005010013001A05001C001F05002000A1808080080500210804050109000E2039090009000E0900120013203D0D00120013100101005D050109000E2011410009000E110012001320154500120013100101005D050109000E05000900172049210009000E2100120017204D250012001719001B001C20551D001B001C1001010063050109000E05000900172031590009000E310012001720355D0012001729001B001C202D65001B001C1002010063 - Name: '__llvm_covfun (7)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: F5953D044B505D139D0000005FD132562FE71EAC4C551E9517F40F4F010107010501110111011D011D012901291A01C201150D02100201000103010A000B03000A001509000F0015050016018580808008050105000810010100010B010A00110B000A001C150015001C11001D018580808008110105000810010100011301110012130011001C210016001C1D001E00211D0022002310010100611B010A00111B000A001C2D0015001C29001E002129002200231001010061 + Content: F5953D044B505D13D50000005FD132562FE71EAC4C551E9517F40F4F010107010501110111011D011D012901292201C201150D02100201000103010A000B03000A0015200935000A000B09000F0015200D39000F0015050016018580808008050105000810010100010B010A00110B000A001C203D15000A0011150015001C2041190015001C11001D018580808008110105000810010100011301110012130011001C20214500110012210016001C2025490016001C1D001E00211D0022002310010100611B010A00111B000A001C204D2D000A00112D0015001C2051310015001C29001E002129002200231001010061 - Name: '__llvm_covfun (8)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] @@ -112,7 +112,7 @@ Symbols: Type: STT_OBJECT Section: '__llvm_covfun (1)' Binding: STB_WEAK - Size: 0x128 + Size: 0x144 Other: [ STV_HIDDEN ] - Name: __covrec_6973C52804C74904u Type: STT_OBJECT @@ -142,13 +142,13 @@ Symbols: Type: STT_OBJECT Section: '__llvm_covfun (6)' Binding: STB_WEAK - Size: 0x97 + Size: 0xDD Other: [ STV_HIDDEN ] - Name: __covrec_135D504B043D95F5u Type: STT_OBJECT Section: '__llvm_covfun (7)' Binding: STB_WEAK - Size: 0xB9 + Size: 0xF1 Other: [ STV_HIDDEN ] - Name: __covrec_795CF1BD69C3E520u Type: STT_OBJECT diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c index 782d4572c63df..a44b3c8d79c74 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c +++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c @@ -23,10 +23,10 @@ void conditionals() { // CHECK: @LINE|{{.*}}conditionals() } else { if (i) {} // CHECK: Branch ([[@LINE]]:11): [True: [[#min(C,16)]], False: 1] } - // BRCOV: Branch ([[@LINE+1]]:9): [True: [[#min(C,100)]], Folded] - if (1 && i) {} // BRCOV: Branch ([[@LINE]]:14): [True: [[#min(C,99)]], False: 1] - if (0 || i) {} // BRCOV: Branch ([[@LINE]]:9): [Folded, False: [[#min(C,100)]]] - } // BRCOV: Branch ([[@LINE-1]]:14): [True: [[#min(C,99)]], False: 1] + // CHECK: Branch ([[@LINE+1]]:9): [True: [[#min(C,100)]], Folded] + if (1 && i) {} // CHECK: Branch ([[@LINE]]:14): [True: [[#min(C,99)]], False: 1] + if (0 || i) {} // CHECK: Branch ([[@LINE]]:9): [Folded, False: [[#min(C,100)]]] + } // CHECK: Branch ([[@LINE-1]]:14): [True: [[#min(C,99)]], False: 1] } @@ -180,30 +180,30 @@ void big_switch() { // CHECK: @LINE|{{.*}}big_switch() void boolean_operators() { // CHECK: @LINE|{{.*}}boolean_operators() int v; for (int i = 0; i < 100; ++i) { - v = i % 3 || i; // BRCOV: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] - // BRCOV: Branch ([[@LINE-1]]:18): [True: [[#min(C,33)]], False: 1] - v = i % 3 && i; // BRCOV: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] - // BRCOV: Branch ([[@LINE-1]]:18): [True: [[#min(C,66)]], False: 0] - v = i % 3 || i % 2 || i; // BRCOV: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] - // BRCOV: Branch ([[@LINE-1]]:18): [True: [[#min(C,17)]], False: [[#min(C,17)]]] - v = i % 2 && i % 3 && i; // BRCOV: Branch ([[@LINE-2]]:27): [True: [[#min(C,16)]], False: 1] - } // BRCOV: Branch ([[@LINE-1]]:9): [True: [[#min(C,50)]], False: [[#min(C,50)]]] - // BRCOV: Branch ([[@LINE-2]]:18): [True: [[#min(C,33)]], False: [[#min(C,17)]]] -} // BRCOV: Branch ([[@LINE-3]]:27): [True: [[#min(C,33)]], False: 0] + v = i % 3 || i; // CHECK: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] + // CHECK: Branch ([[@LINE-1]]:18): [True: [[#min(C,33)]], False: 1] + v = i % 3 && i; // CHECK: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] + // CHECK: Branch ([[@LINE-1]]:18): [True: [[#min(C,66)]], False: 0] + v = i % 3 || i % 2 || i; // CHECK: Branch ([[@LINE]]:9): [True: [[#min(C,66)]], False: [[#min(C,34)]]] + // CHECK: Branch ([[@LINE-1]]:18): [True: [[#min(C,17)]], False: [[#min(C,17)]]] + v = i % 2 && i % 3 && i; // CHECK: Branch ([[@LINE-2]]:27): [True: [[#min(C,16)]], False: 1] + } // CHECK: Branch ([[@LINE-1]]:9): [True: [[#min(C,50)]], False: [[#min(C,50)]]] + // CHECK: Branch ([[@LINE-2]]:18): [True: [[#min(C,33)]], False: [[#min(C,17)]]] +} // CHECK: Branch ([[@LINE-3]]:27): [True: [[#min(C,33)]], False: 0] void boolop_loops() { // CHECK: @LINE|{{.*}}boolop_loops() int i = 100; - while (i && i > 50) // BRCOV: Branch ([[@LINE]]:10): [True: [[#min(C,51)]], False: 0] - i--; // BRCOV: Branch ([[@LINE-1]]:15): [True: [[#min(C,50)]], False: 1] + while (i && i > 50) // CHECK: Branch ([[@LINE]]:10): [True: [[#min(C,51)]], False: 0] + i--; // CHECK: Branch ([[@LINE-1]]:15): [True: [[#min(C,50)]], False: 1] - while ((i % 2) || (i > 0)) // BRCOV: Branch ([[@LINE]]:10): [True: [[#min(C,25)]], False: [[#min(C,26)]]] - i--; // BRCOV: Branch ([[@LINE-1]]:21): [True: [[#min(C,25)]], False: 1] + while ((i % 2) || (i > 0)) // CHECK: Branch ([[@LINE]]:10): [True: [[#min(C,25)]], False: [[#min(C,26)]]] + i--; // CHECK: Branch ([[@LINE-1]]:21): [True: [[#min(C,25)]], False: 1] - for (i = 100; i && i > 50; --i); // BRCOV: Branch ([[@LINE]]:17): [True: [[#min(C,51)]], False: 0] - // BRCOV: Branch ([[@LINE-1]]:22): [True: [[#min(C,50)]], False: 1] - for (; (i % 2) || (i > 0); --i); // BRCOV: Branch ([[@LINE]]:10): [True: [[#min(C,25)]], False: [[#min(C,26)]]] - // BRCOV: Branch ([[@LINE-1]]:21): [True: [[#min(C,25)]], False: 1] + for (i = 100; i && i > 50; --i); // CHECK: Branch ([[@LINE]]:17): [True: [[#min(C,51)]], False: 0] + // CHECK: Branch ([[@LINE-1]]:22): [True: [[#min(C,50)]], False: 1] + for (; (i % 2) || (i > 0); --i); // CHECK: Branch ([[@LINE]]:10): [True: [[#min(C,25)]], False: [[#min(C,26)]]] + // CHECK: Branch ([[@LINE-1]]:21): [True: [[#min(C,25)]], False: 1] } void conditional_operator() { // CHECK: @LINE|{{.*}}conditional_operator() diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.proftext b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.proftext index 798e150d80a1a..7ebf85a88e869 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.proftext +++ b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.proftext @@ -4,7 +4,7 @@ _Z4funcii # Func Hash: 8468630735863722633 # Num Counters: -63 +127 # Counter Values: 4 0 @@ -65,6 +65,70 @@ _Z4funcii 4 1 3 +1 +1 +2 +0 +2 +2 +4 +0 +4 +0 +3 +0 +3 +1 +4 +0 +4 +0 +4 +0 +1 +2 +1 +2 +1 +0 +0 +3 +1 +0 +3 +0 +1 +0 +2 +1 +1 +0 +2 +1 +1 +0 +3 +1 +2 +1 +0 +0 +3 +0 +1 +0 +0 +3 +1 +0 +1 +2 +1 +0 +1 +2 +1 +0 4 0 3 diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.yaml b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.yaml index 0c36f48789a51..0fc3196210b09 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.yaml +++ b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed-single.yaml @@ -11,7 +11,7 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: F0A0ED2C305C0BB33C02000089B21C19C99E86758F2950E06FBD46E8010100610108194302100701000101010C000E01000C010E01000C020E01000C030E01000C040E25010C000E1D010C000E15010C000E0D010C000E05010C000E100101000101010C000E01000C010E01000C020E01000C030E01000C040E4D010C000E45010C000E3D010C000E35010C000E2D010C000E100101000101010C011001000C031001000C051001000C071001000C091001000D000F69010D000F65010C011065000D000F71010D000F61010C011061000D000F79010D000F5D010C01105D000D000F8101010D000F59010C011059000D000F8901010D000F55010C011055000D000F9101010D000F100101000101010C011001000C031001000C051001000C071001000C091001000D000FAD01010D000FA901010C0110A901000D000FB501010D000FA501010C0110A501000D000FBD01010D000FA101010C0110A101000D000FC501010D000F9D01010C01109D01000D000FCD01010D000F9901010C01109901000D000FD501010D000F1001010001010107000820DD01ED0100070008DD010009018580808008DD0101050016ED010017028580808008ED01020500161001010001010107000820E101F10100070008E1010009018580808008E10101050016F1010017028580808008F101020500161001010001010107000820E501F50100070008E5010009018580808008E50101050016F5010017028580808008F501020500161001010001010107000820E901F90100070008E9010009018580808008E90101050016F9010017028580808008F90102050016 + Content: F0A0ED2C305C0BB36F03000089B21C19C99E86758F2950E06FBD46E801010085010108194302100701000101010C000E01000C010E01000C020E01000C030E01000C040E2025ED01000C000E25010C000E2029F101000C000E1D010C000E2021F901000C000E15010C000E20198102000C000E0D010C000E20118902000C000E05010C000E20099102000C000E100101000101010C000E01000C010E01000C020E01000C030E01000C040E2095024D000C000E4D010C000E20990251000C000E45010C000E20A10249000C000E3D010C000E20A90241000C000E35010C000E20B10239000C000E2D010C000E20B90231000C000E100101000101010C011001000C031001000C051001000C071001000C091001000D000F2069BD02000D000F69010D000F206DC102000D000F65010C011065000D000F2071C502000D000F71010D000F2075C902000D000F61010C011061000D000F2079D502000D000F79010D000F207DD902000D000F5D010C01105D000D000F208101E502000D000F8101010D000F208501E902000D000F59010C011059000D000F208901F502000D000F8901010D000F208D01F902000D000F55010C011055000D000F2091018503000D000F9101010D000F2095018903000D000F100101000101010C011001000C031001000C051001000C071001000C091001000D000F209503AD01000D000FAD01010D000F209903B101000D000FA901010C0110A901000D000F209D03B501000D000FB501010D000F20A103B901000D000FA501010C0110A501000D000F20AD03BD01000D000FBD01010D000F20B103C101000D000FA101010C0110A101000D000F20BD03C501000D000FC501010D000F20C103C901000D000F9D01010C01109D01000D000F20CD03CD01000D000FCD01010D000F20D103D101000D000F9901010C01109901000D000F20DD03D501000D000FD501010D000F20E103D901000D000F1001010001010107000820DD01ED0300070008DD010009018580808008DD0101050016ED030017028580808008ED03020500161001010001010107000820E101F10300070008E1010009018580808008E10101050016F1030017028580808008F103020500161001010001010107000820E501F50300070008E5010009018580808008E50101050016F5030017028580808008F503020500161001010001010107000820E901F90300070008E9010009018580808008E90101050016F9030017028580808008F90302050016 - Name: '__llvm_covfun (1)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] @@ -46,7 +46,7 @@ Symbols: Type: STT_OBJECT Section: __llvm_covfun Binding: STB_WEAK - Size: 0x258 + Size: 0x38B Other: [ STV_HIDDEN ] - Name: __covrec_DB956436E78DD5FAu Type: STT_OBJECT diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed.cpp b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed.cpp index 8e9ea404116c9..ec571ee8b52bd 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed.cpp +++ b/llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed.cpp @@ -13,45 +13,45 @@ void func(int a, int b) { bool b4 = a > b; bool b5 = a != b; - bool c = b0 && // BRCOV: Branch ([[@LINE]]:12): [True: [[#min(C,3)]], False: 1] - b1 && // BRCOV: Branch ([[@LINE]]:12): [True: [[#min(C,2)]], False: 1] - b2 && // BRCOV: Branch ([[@LINE]]:12): [True: [[#min(C,2)]], False: 0] - b3 && // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: [[#min(C,2)]]] - b4 && // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 0] - b5; // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 0] + bool c = b0 && // CHECK: Branch ([[@LINE]]:12): [True: [[#min(C,3)]], False: 1] + b1 && // CHECK: Branch ([[@LINE]]:12): [True: [[#min(C,2)]], False: 1] + b2 && // CHECK: Branch ([[@LINE]]:12): [True: [[#min(C,2)]], False: 0] + b3 && // CHECK: Branch ([[@LINE]]:12): [True: 0, False: [[#min(C,2)]]] + b4 && // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0] + b5; // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0] - bool d = b0 || // BRCOV: Branch ([[@LINE]]:12): [True: [[#min(C,3)]], False: 1] - b1 || // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 1] - b2 || // BRCOV: Branch ([[@LINE]]:12): [True: 1, False: 0] - b3 || // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 0] - b4 || // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 0] - b5; // BRCOV: Branch ([[@LINE]]:12): [True: 0, False: 0] + bool d = b0 || // CHECK: Branch ([[@LINE]]:12): [True: [[#min(C,3)]], False: 1] + b1 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 1] + b2 || // CHECK: Branch ([[@LINE]]:12): [True: 1, False: 0] + b3 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0] + b4 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0] + b5; // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0] - bool e = (b0 && // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 1] - b5) || // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] - (b1 && // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 1] - b4) || // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,2)]]] - (b2 && // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] - b3) || // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] - (b3 && // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] - b2) || // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: 0] - (b4 && // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] - b1) || // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: 1] - (b5 && // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] - b0); // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: 1] + bool e = (b0 && // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 1] + b5) || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] + (b1 && // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 1] + b4) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,2)]]] + (b2 && // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] + b3) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] + (b3 && // CHECK: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] + b2) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 0] + (b4 && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] + b1) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 1] + (b5 && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] + b0); // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 1] - bool f = (b0 || // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 1] - b5) && // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: 0] - (b1 || // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: [[#min(C,2)]]] - b4) && // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: 1] - (b2 || // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] - b3) && // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: 0] - (b3 || // BRCOV: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] - b2) && // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] - (b4 || // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] - b1) && // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 0] - (b5 || // BRCOV: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] - b0); // BRCOV: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 0] + bool f = (b0 || // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 1] + b5) && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 0] + (b1 || // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: [[#min(C,2)]]] + b4) && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 1] + (b2 || // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] + b3) && // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 0] + (b3 || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: [[#min(C,3)]]] + b2) && // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,3)]], False: 0] + (b4 || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] + b1) && // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 0] + (b5 || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: [[#min(C,2)]]] + b0); // CHECK: Branch ([[@LINE]]:13): [True: [[#min(C,2)]], False: 0] if (c) // CHECK: Branch ([[@LINE]]:7): [True: 0, False: [[#min(C,4)]]] printf("case0\n"); diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.proftext b/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.proftext index 29dc4ef3bf5c2..1643936583df4 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.proftext +++ b/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.proftext @@ -4,7 +4,7 @@ _Z4funcii # Func Hash: 456046650042366162 # Num Counters: -19 +37 # Counter Values: 3 1 @@ -25,12 +25,30 @@ _Z4funcii 0 0 0 +2 +1 +2 +1 +2 +1 +2 +1 +2 +1 +3 +0 +3 +0 +3 +0 +3 +0 _Z5func2ii # Func Hash: 14151920320560143107 # Num Counters: -9 +15 # Counter Values: 3 3 @@ -40,7 +58,13 @@ _Z5func2ii 0 1 0 +2 +1 3 +2 +1 +0 +1 main # Func Hash: diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.yaml b/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.yaml index 7545e311af7ab..2951ae89d2b8d 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.yaml +++ b/llvm/test/tools/llvm-cov/Inputs/branch-macros-single.yaml @@ -11,12 +11,12 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: F0A0ED2C305C0BB33F010000D238C8100334540693E696313ECE8F5D15010101010101010101010101010101010101010101001501101911020C010C0011140015001A100101005C1C010C0011100101006224010C001210010100682C010C0012100101006E34010C0012100101007401010A000B01000A001001000A001501000A001A45000F00103D00140015350019001A2D001E001F10010104550201050F001701000F00170105060F00170301070F001F3C00100015440019001E014C0910001501540A100016015C0B1000160201050F001701000F0017010D060F00170301070F001F64001000156C0019001E017409100015017C0A1000160201050F001701000F00170115060F00170301070F001F8401001000158C010019001E019401091000150201050F001701000F0017011D060F00170301070F001F9C0100100015A4010019001E0201050F001701000F00170125060F0017 + Content: F0A0ED2C305C0BB3AB010000D238C8100334540693E696313ECE8F5D15010101010101010101010101010101010101010101001A01101911020C010C0011140015001A100101005C1C010C0011100101006224010C001210010100682C010C0012100101006E34010C0012100101007401010A000B01000A001001000A001501000A001A204575000A000B45000F0010204979000F00103D001400152041810100140015350019001A203989010019001A2D001E001F20319101001E001F10010104550301050F001701000F001720054D000F00170205060F0017200951000F00170301070F001F3C00100015440019001E014C0910001501540A100016015C0B1000160301050F001701000F0017200D55000F0017020D060F0017201159000F00170301070F001F64001000156C0019001E017409100015017C0A1000160301050F001701000F001720155D000F00170215060F0017201961000F00170301070F001F8401001000158C010019001E019401091000150301050F001701000F0017201D65000F0017021D060F0017202169000F00170301070F001F9C0100100015A4010019001E0301050F001701000F001720256D000F00170225060F0017202971000F0017 - Name: '__llvm_covfun (1)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] AddressAlign: 0x8 - Content: B01D983FC67363959E000000039B9E2C8DB865C493E696313ECE8F5D0D01010101010101010101010101000401241A07020C010E0014140018001D1001010365011C0B1000160405080F002624001000152C0018001D3400200025013C0A1000160305070F001F44001000154C0019001E0115060F00170121050F00170154091000150205050F001705000F00170119060F00170401070F001F01000F001F5C00100015640019001E0201050F001701000F0017010D060F0017 + Content: B01D983FC6736395C1000000039B9E2C8DB865C493E696313ECE8F5D0D01010101010101010101010101000401241A07020C010E0014140018001D1001010365011C0B1000160505080F0026203909000F002624001000152C0018001D3400200025013C0A1000160305070F001F44001000154C0019001E0115060F00170129050F00170154091000150305050F001705000F001720192D000F00170219060F0017201D31000F00170401070F001F01000F001F5C00100015640019001E0301050F001701000F0017200D21000F0017020D060F0017201125000F0017 - Name: '__llvm_covfun (2)' Type: SHT_PROGBITS Flags: [ SHF_GNU_RETAIN ] @@ -52,13 +52,13 @@ Symbols: Type: STT_OBJECT Section: __llvm_covfun Binding: STB_WEAK - Size: 0x15B + Size: 0x1C7 Other: [ STV_HIDDEN ] - Name: __covrec_956373C63F981DB0u Type: STT_OBJECT Section: '__llvm_covfun (1)' Binding: STB_WEAK - Size: 0xBA + Size: 0xDD Other: [ STV_HIDDEN ] - Name: __covrec_DB956436E78DD5FAu Type: STT_OBJECT diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-macros.cpp b/llvm/test/tools/llvm-cov/Inputs/branch-macros.cpp index ad627106f32bd..1534c22a926b0 100644 --- a/llvm/test/tools/llvm-cov/Inputs/branch-macros.cpp +++ b/llvm/test/tools/llvm-cov/Inputs/branch-macros.cpp @@ -5,7 +5,7 @@ #define COND1 (a == b) #define COND2 (a != b) #define COND3 (COND1 && COND2) -#define COND4 (COND3 ? COND2 : COND1) // BRCOV: | Branch ([[@LINE]]:15): [True: 1, False: [[#min(C,2)]]] +#define COND4 (COND3 ? COND2 : COND1) // CHECK: | Branch ([[@LINE]]:15): [True: 1, False: [[#min(C,2)]]] #define MACRO1 COND3 #define MACRO2 MACRO1 #define MACRO3 MACRO2 @@ -14,31 +14,31 @@ // CHECK: |{{ +}}[[#min(C,3)]]|bool func( bool func(int a, int b) { - bool c = COND1 && COND2; // BRCOV: | | | Branch ([[@LINE-12]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | Branch ([[@LINE-12]]:15): [True: 0, False: 1] - bool d = COND3; // BRCOV: | | | | | Branch ([[@LINE-14]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | Branch ([[@LINE-14]]:15): [True: 0, False: 1] - bool e = MACRO1; // BRCOV: | | | | | | | Branch ([[@LINE-16]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | | | Branch ([[@LINE-16]]:15): [True: 0, False: 1] - bool f = MACRO2; // BRCOV: | | | | | | | | | Branch ([[@LINE-18]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | | | | | Branch ([[@LINE-18]]:15): [True: 0, False: 1] - bool g = MACRO3; // BRCOV: | | | | | | | | | | | Branch ([[@LINE-20]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | | | | | | | Branch ([[@LINE-20]]:15): [True: 0, False: 1] + bool c = COND1 && COND2; // CHECK: | | | Branch ([[@LINE-12]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | Branch ([[@LINE-12]]:15): [True: 0, False: 1] + bool d = COND3; // CHECK: | | | | | Branch ([[@LINE-14]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | Branch ([[@LINE-14]]:15): [True: 0, False: 1] + bool e = MACRO1; // CHECK: | | | | | | | Branch ([[@LINE-16]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | | | Branch ([[@LINE-16]]:15): [True: 0, False: 1] + bool f = MACRO2; // CHECK: | | | | | | | | | Branch ([[@LINE-18]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | | | | | Branch ([[@LINE-18]]:15): [True: 0, False: 1] + bool g = MACRO3; // CHECK: | | | | | | | | | | | Branch ([[@LINE-20]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | | | | | | | Branch ([[@LINE-20]]:15): [True: 0, False: 1] return c && d && e && f && g; - // BRCOV: | Branch ([[@LINE-1]]:10): [True: 0, False: [[#min(C,3)]]] - // BRCOV: | Branch ([[@LINE-2]]:15): [True: 0, False: 0] - // BRCOV: | Branch ([[@LINE-3]]:20): [True: 0, False: 0] - // BRCOV: | Branch ([[@LINE-4]]:25): [True: 0, False: 0] - // BRCOV: | Branch ([[@LINE-5]]:30): [True: 0, False: 0] + // CHECK: | Branch ([[@LINE-1]]:10): [True: 0, False: [[#min(C,3)]]] + // CHECK: | Branch ([[@LINE-2]]:15): [True: 0, False: 0] + // CHECK: | Branch ([[@LINE-3]]:20): [True: 0, False: 0] + // CHECK: | Branch ([[@LINE-4]]:25): [True: 0, False: 0] + // CHECK: | Branch ([[@LINE-5]]:30): [True: 0, False: 0] } bool func2(int a, int b) { - bool h = MACRO3 || COND4; // BRCOV: | | | | | | | | | | | Branch ([[@LINE-32]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | | | | | | | Branch ([[@LINE-32]]:15): [True: 0, False: 1] - // BRCOV: | | | | | | | Branch ([[@LINE-34]]:15): [True: 1, False: [[#min(C,2)]]] - // BRCOV: | | | | | | | Branch ([[@LINE-34]]:15): [True: 0, False: 1] - // BRCOV: | | | Branch ([[@LINE-33]]:15): [True: 1, False: [[#min(C,2)]]] + bool h = MACRO3 || COND4; // CHECK: | | | | | | | | | | | Branch ([[@LINE-32]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | | | | | | | Branch ([[@LINE-32]]:15): [True: 0, False: 1] + // CHECK: | | | | | | | Branch ([[@LINE-34]]:15): [True: 1, False: [[#min(C,2)]]] + // CHECK: | | | | | | | Branch ([[@LINE-34]]:15): [True: 0, False: 1] + // CHECK: | | | Branch ([[@LINE-33]]:15): [True: 1, False: [[#min(C,2)]]] return h; } diff --git a/llvm/test/tools/llvm-cov/branch-macros.test b/llvm/test/tools/llvm-cov/branch-macros.test index b16ef9d4846d8..311d6d803fd3d 100644 --- a/llvm/test/tools/llvm-cov/branch-macros.test +++ b/llvm/test/tools/llvm-cov/branch-macros.test @@ -1,6 +1,6 @@ // RUN: llvm-profdata merge %S/Inputs/branch-macros.proftext -o %t.profdata -// RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=999 -// RUN: llvm-cov show --binary-counters --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -check-prefixes=CHECK,BRCOV -D#C=1 +// RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -D#C=999 +// RUN: llvm-cov show --binary-counters --show-expansions --show-branches=count %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -D#C=1 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-macros.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S/Inputs %S/Inputs/branch-macros.cpp | FileCheck %s -check-prefix=REPORT // RUN: yaml2obj %S/Inputs/branch-macros-single.yaml -o %t.o