[llvm-branch-commits] [clang] fix links on clang 18.1.0rc release page (PR #82739)

2024-02-25 Thread via llvm-branch-commits

h-vetinari wrote:

Thanks for the reviews! I don't have commit rights on the repo, so someone will 
please have to push the button for me.

https://github.com/llvm/llvm-project/pull/82739
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-02-25 Thread NAKAMURA Takumi via llvm-branch-commits

https://github.com/chapuni updated 
https://github.com/llvm/llvm-project/pull/82448

>From b5ecfcc22cffdd560dc5b6a050889b6c6deacbdb Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi 
Date: Fri, 16 Feb 2024 00:09:41 +0900
Subject: [PATCH 1/3] [MC/DC][Coverage] Loosen the limit of NumConds from 6

---
 clang/lib/CodeGen/CodeGenPGO.cpp  |  61 +-
 clang/lib/CodeGen/CoverageMappingGen.cpp  | 115 +-
 clang/lib/CodeGen/MCDCState.h |  18 ++-
 .../CoverageMapping/branch-constfolded.cpp|  34 +++---
 clang/test/CoverageMapping/logical.cpp|   8 +-
 clang/test/CoverageMapping/mcdc-class.cpp |   4 +-
 .../CoverageMapping/mcdc-error-conditions.cpp |  86 -
 .../mcdc-logical-scalar-ids.cpp   |  30 ++---
 .../mcdc-logical-stmt-ids-all.cpp |  32 ++---
 .../CoverageMapping/mcdc-logical-stmt-ids.cpp |  30 ++---
 clang/test/Profile/c-mcdc-logicalop-ternary.c |   6 +-
 .../ProfileData/Coverage/CoverageMapping.cpp  |  32 ++---
 .../llvm-cov/Inputs/mcdc-const-folding.o  | Bin 34504 -> 34528 bytes
 .../Inputs/mcdc-const-folding.proftext|  36 +++---
 llvm/test/tools/llvm-cov/Inputs/mcdc-const.o  | Bin 5112 -> 5112 bytes
 .../tools/llvm-cov/Inputs/mcdc-const.proftext |   6 +-
 .../test/tools/llvm-cov/Inputs/mcdc-general.o | Bin 6200 -> 6232 bytes
 .../llvm-cov/Inputs/mcdc-general.proftext |  11 +-
 llvm/test/tools/llvm-cov/Inputs/mcdc-macro.o  | Bin 6424 -> 6480 bytes
 .../tools/llvm-cov/Inputs/mcdc-macro.proftext |  15 +--
 llvm/test/tools/llvm-cov/Inputs/mcdc-maxbs.o  | Bin 4632 -> 4112 bytes
 llvm/test/tools/llvm-cov/mcdc-maxbs.test  |   2 +-
 .../ProfileData/CoverageMappingTest.cpp   |   2 +-
 23 files changed, 348 insertions(+), 180 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 48c5e68a3b7ba4..b004bf45fa75d7 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -163,8 +163,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
   PGOHash Hash;
   /// The map of statements to counters.
   llvm::DenseMap &CounterMap;
-  /// The next bitmap byte index to assign.
-  unsigned NextMCDCBitmapIdx;
+  /// The state of MC/DC Coverage in this function.
   MCDC::State &MCDCState;
   /// Maximum number of supported MC/DC conditions in a boolean expression.
   unsigned MCDCMaxCond;
@@ -178,7 +177,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 MCDC::State &MCDCState, unsigned MCDCMaxCond,
 DiagnosticsEngine &Diag)
   : NextCounter(0), Hash(HashVersion), CounterMap(CounterMap),
-NextMCDCBitmapIdx(0), MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond),
+MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond),
 ProfileVersion(ProfileVersion), Diag(Diag) {}
 
   // Blocks and lambdas are handled as separate functions, so we need not
@@ -306,11 +305,8 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 return false;
   }
 
-  // Otherwise, allocate the number of bytes required for the bitmap
-  // based on the number of conditions. Must be at least 1-byte long.
-  MCDCState.BitmapMap[BinOp] = NextMCDCBitmapIdx;
-  unsigned SizeInBits = std::max(1L << NumCond, CHAR_BIT);
-  NextMCDCBitmapIdx += SizeInBits / CHAR_BIT;
+  // Otherwise, allocate the Decision.
+  MCDCState.BitmapMap[BinOp].BitmapIdx = 0;
 }
 return true;
   }
@@ -983,7 +979,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
   // for most embedded applications. Setting a maximum value prevents the
   // bitmap footprint from growing too large without the user's knowledge. In
   // the future, this value could be adjusted with a command-line option.
-  unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 6 : 0;
+  unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 32767 : 0;
 
   RegionCounterMap.reset(new llvm::DenseMap);
   RegionMCDCState.reset(new MCDC::State);
@@ -999,7 +995,6 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
 Walker.TraverseDecl(const_cast(CD));
   assert(Walker.NextCounter > 0 && "no entry counter mapped for decl");
   NumRegionCounters = Walker.NextCounter;
-  RegionMCDCState->BitmapBytes = Walker.NextMCDCBitmapIdx;
   FunctionHash = Walker.Hash.finalize();
 }
 
@@ -1124,9 +1119,11 @@ void CodeGenPGO::emitMCDCParameters(CGBuilderTy 
&Builder) {
   // Emit intrinsic representing MCDC bitmap parameters at function entry.
   // This is used by the instrumentation pass, but it isn't actually lowered to
   // anything.
-  llvm::Value *Args[3] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
-  Builder.getInt64(FunctionHash),
-  Builder.getInt32(RegionMCDCState->BitmapBytes)};
+  llvm::Value *Args[3] = {
+  llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+  Buil

[llvm-branch-commits] [clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)

2024-02-25 Thread NAKAMURA Takumi via llvm-branch-commits

https://github.com/chapuni updated 
https://github.com/llvm/llvm-project/pull/82448

>From b5ecfcc22cffdd560dc5b6a050889b6c6deacbdb Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi 
Date: Fri, 16 Feb 2024 00:09:41 +0900
Subject: [PATCH 1/4] [MC/DC][Coverage] Loosen the limit of NumConds from 6

---
 clang/lib/CodeGen/CodeGenPGO.cpp  |  61 +-
 clang/lib/CodeGen/CoverageMappingGen.cpp  | 115 +-
 clang/lib/CodeGen/MCDCState.h |  18 ++-
 .../CoverageMapping/branch-constfolded.cpp|  34 +++---
 clang/test/CoverageMapping/logical.cpp|   8 +-
 clang/test/CoverageMapping/mcdc-class.cpp |   4 +-
 .../CoverageMapping/mcdc-error-conditions.cpp |  86 -
 .../mcdc-logical-scalar-ids.cpp   |  30 ++---
 .../mcdc-logical-stmt-ids-all.cpp |  32 ++---
 .../CoverageMapping/mcdc-logical-stmt-ids.cpp |  30 ++---
 clang/test/Profile/c-mcdc-logicalop-ternary.c |   6 +-
 .../ProfileData/Coverage/CoverageMapping.cpp  |  32 ++---
 .../llvm-cov/Inputs/mcdc-const-folding.o  | Bin 34504 -> 34528 bytes
 .../Inputs/mcdc-const-folding.proftext|  36 +++---
 llvm/test/tools/llvm-cov/Inputs/mcdc-const.o  | Bin 5112 -> 5112 bytes
 .../tools/llvm-cov/Inputs/mcdc-const.proftext |   6 +-
 .../test/tools/llvm-cov/Inputs/mcdc-general.o | Bin 6200 -> 6232 bytes
 .../llvm-cov/Inputs/mcdc-general.proftext |  11 +-
 llvm/test/tools/llvm-cov/Inputs/mcdc-macro.o  | Bin 6424 -> 6480 bytes
 .../tools/llvm-cov/Inputs/mcdc-macro.proftext |  15 +--
 llvm/test/tools/llvm-cov/Inputs/mcdc-maxbs.o  | Bin 4632 -> 4112 bytes
 llvm/test/tools/llvm-cov/mcdc-maxbs.test  |   2 +-
 .../ProfileData/CoverageMappingTest.cpp   |   2 +-
 23 files changed, 348 insertions(+), 180 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 48c5e68a3b7ba4..b004bf45fa75d7 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -163,8 +163,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
   PGOHash Hash;
   /// The map of statements to counters.
   llvm::DenseMap &CounterMap;
-  /// The next bitmap byte index to assign.
-  unsigned NextMCDCBitmapIdx;
+  /// The state of MC/DC Coverage in this function.
   MCDC::State &MCDCState;
   /// Maximum number of supported MC/DC conditions in a boolean expression.
   unsigned MCDCMaxCond;
@@ -178,7 +177,7 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 MCDC::State &MCDCState, unsigned MCDCMaxCond,
 DiagnosticsEngine &Diag)
   : NextCounter(0), Hash(HashVersion), CounterMap(CounterMap),
-NextMCDCBitmapIdx(0), MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond),
+MCDCState(MCDCState), MCDCMaxCond(MCDCMaxCond),
 ProfileVersion(ProfileVersion), Diag(Diag) {}
 
   // Blocks and lambdas are handled as separate functions, so we need not
@@ -306,11 +305,8 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
 return false;
   }
 
-  // Otherwise, allocate the number of bytes required for the bitmap
-  // based on the number of conditions. Must be at least 1-byte long.
-  MCDCState.BitmapMap[BinOp] = NextMCDCBitmapIdx;
-  unsigned SizeInBits = std::max(1L << NumCond, CHAR_BIT);
-  NextMCDCBitmapIdx += SizeInBits / CHAR_BIT;
+  // Otherwise, allocate the Decision.
+  MCDCState.BitmapMap[BinOp].BitmapIdx = 0;
 }
 return true;
   }
@@ -983,7 +979,7 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
   // for most embedded applications. Setting a maximum value prevents the
   // bitmap footprint from growing too large without the user's knowledge. In
   // the future, this value could be adjusted with a command-line option.
-  unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 6 : 0;
+  unsigned MCDCMaxConditions = (CGM.getCodeGenOpts().MCDCCoverage) ? 32767 : 0;
 
   RegionCounterMap.reset(new llvm::DenseMap);
   RegionMCDCState.reset(new MCDC::State);
@@ -999,7 +995,6 @@ void CodeGenPGO::mapRegionCounters(const Decl *D) {
 Walker.TraverseDecl(const_cast(CD));
   assert(Walker.NextCounter > 0 && "no entry counter mapped for decl");
   NumRegionCounters = Walker.NextCounter;
-  RegionMCDCState->BitmapBytes = Walker.NextMCDCBitmapIdx;
   FunctionHash = Walker.Hash.finalize();
 }
 
@@ -1124,9 +1119,11 @@ void CodeGenPGO::emitMCDCParameters(CGBuilderTy 
&Builder) {
   // Emit intrinsic representing MCDC bitmap parameters at function entry.
   // This is used by the instrumentation pass, but it isn't actually lowered to
   // anything.
-  llvm::Value *Args[3] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
-  Builder.getInt64(FunctionHash),
-  Builder.getInt32(RegionMCDCState->BitmapBytes)};
+  llvm::Value *Args[3] = {
+  llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
+  Buil

[llvm-branch-commits] [llvm] release/18.x: [FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987) (PR #82925)

2024-02-25 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987) (PR #82925)

2024-02-25 Thread via llvm-branch-commits

llvmbot wrote:

@arsenm What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/82925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987) (PR #82925)

2024-02-25 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82925

Backport f920b746ea818f1d21f317116cbb105e3e85979a

Requested by: @dtcxzyw

>From c743fe292f65829e9608ffe067100dad8f61a89a Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Sun, 25 Feb 2024 22:01:13 +0800
Subject: [PATCH] [FlattenCFG] Fix the miscompilation where phi nodes exist in
 the merge point (#81987)

When there are phi nodes in the merge point of the if-region, we cannot
do the merge.
Alive2: https://alive2.llvm.org/ce/z/DbgEan
Fixes #70900.

(cherry picked from commit f920b746ea818f1d21f317116cbb105e3e85979a)
---
 llvm/lib/Transforms/Utils/FlattenCFG.cpp | 14 --
 llvm/test/Transforms/Util/flattencfg.ll  | 15 +--
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp 
b/llvm/lib/Transforms/Utils/FlattenCFG.cpp
index 1925b91c4da7ec..c5cb3748a52f8d 100644
--- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp
+++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp
@@ -407,6 +407,10 @@ bool FlattenCFGOpt::CompareIfRegionBlock(BasicBlock 
*Block1, BasicBlock *Block2,
 /// form, by inverting the condition and the branch successors. The same
 /// approach goes for the opposite case.
 bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) {
+  // We cannot merge the if-region if the merge point has phi nodes.
+  if (isa(BB->front()))
+return false;
+
   BasicBlock *IfTrue2, *IfFalse2;
   BranchInst *DomBI2 = GetIfCondition(BB, IfTrue2, IfFalse2);
   if (!DomBI2)
@@ -493,16 +497,6 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, 
IRBuilder<> &Builder) {
   PBI->replaceUsesOfWith(PBI->getCondition(), NC);
   Builder.SetInsertPoint(SaveInsertBB, SaveInsertPt);
 
-  // Handle PHI node to replace its predecessors to FirstEntryBlock.
-  for (BasicBlock *Succ : successors(PBI)) {
-for (PHINode &Phi : Succ->phis()) {
-  for (unsigned i = 0, e = Phi.getNumIncomingValues(); i != e; ++i) {
-if (Phi.getIncomingBlock(i) == SecondEntryBlock)
-  Phi.setIncomingBlock(i, FirstEntryBlock);
-  }
-}
-  }
-
   // Remove IfTrue1
   if (IfTrue1 != FirstEntryBlock) {
 IfTrue1->dropAllReferences();
diff --git a/llvm/test/Transforms/Util/flattencfg.ll 
b/llvm/test/Transforms/Util/flattencfg.ll
index 4a4d4279f360d6..5f8dd981293345 100644
--- a/llvm/test/Transforms/Util/flattencfg.ll
+++ b/llvm/test/Transforms/Util/flattencfg.ll
@@ -77,13 +77,16 @@ define void @test_not_crash3(i32 %a) #0 {
 ; CHECK-SAME: (i32 [[A:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT:br i1 [[A_EQ_0]], label [[BB0:%.*]], label [[BB1:%.*]]
+; CHECK:   bb0:
+; CHECK-NEXT:br label [[BB1]]
+; CHECK:   bb1:
 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1
-; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]]
-; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]]
+; CHECK-NEXT:br i1 [[A_EQ_1]], label [[BB2:%.*]], label [[BB3:%.*]]
 ; CHECK:   bb2:
 ; CHECK-NEXT:br label [[BB3]]
 ; CHECK:   bb3:
-; CHECK-NEXT:[[CHECK_BADREF:%.*]] = phi i32 [ 17, [[ENTRY:%.*]] ], [ 11, 
[[BB2]] ]
+; CHECK-NEXT:[[CHECK_BADREF:%.*]] = phi i32 [ 17, [[BB1]] ], [ 11, [[BB2]] 
]
 ; CHECK-NEXT:ret void
 ;
 entry:
@@ -278,9 +281,9 @@ define i1 @test_cond_multi_use(i32 %x, i32 %y, i32 %z) {
 ; CHECK-NEXT:  entry.x:
 ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0
 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0
-; CHECK-NEXT:[[TMP0:%.*]] = xor i1 [[CMP_Y]], true
-; CHECK-NEXT:[[TMP1:%.*]] = or i1 [[CMP_X]], [[TMP0]]
-; CHECK-NEXT:br i1 [[TMP1]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
+; CHECK-NEXT:[[CMP_Y_NOT:%.*]] = xor i1 [[CMP_Y]], true
+; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y_NOT]]
+; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
 ; CHECK:   if.then.y:
 ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4
 ; CHECK-NEXT:br label [[EXIT]]

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987) (PR #82925)

2024-02-25 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport f920b746ea818f1d21f317116cbb105e3e85979a

Requested by: @dtcxzyw

---
Full diff: https://github.com/llvm/llvm-project/pull/82925.diff


2 Files Affected:

- (modified) llvm/lib/Transforms/Utils/FlattenCFG.cpp (+4-10) 
- (modified) llvm/test/Transforms/Util/flattencfg.ll (+9-6) 


``diff
diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp 
b/llvm/lib/Transforms/Utils/FlattenCFG.cpp
index 1925b91c4da7ec..c5cb3748a52f8d 100644
--- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp
+++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp
@@ -407,6 +407,10 @@ bool FlattenCFGOpt::CompareIfRegionBlock(BasicBlock 
*Block1, BasicBlock *Block2,
 /// form, by inverting the condition and the branch successors. The same
 /// approach goes for the opposite case.
 bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder) {
+  // We cannot merge the if-region if the merge point has phi nodes.
+  if (isa(BB->front()))
+return false;
+
   BasicBlock *IfTrue2, *IfFalse2;
   BranchInst *DomBI2 = GetIfCondition(BB, IfTrue2, IfFalse2);
   if (!DomBI2)
@@ -493,16 +497,6 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, 
IRBuilder<> &Builder) {
   PBI->replaceUsesOfWith(PBI->getCondition(), NC);
   Builder.SetInsertPoint(SaveInsertBB, SaveInsertPt);
 
-  // Handle PHI node to replace its predecessors to FirstEntryBlock.
-  for (BasicBlock *Succ : successors(PBI)) {
-for (PHINode &Phi : Succ->phis()) {
-  for (unsigned i = 0, e = Phi.getNumIncomingValues(); i != e; ++i) {
-if (Phi.getIncomingBlock(i) == SecondEntryBlock)
-  Phi.setIncomingBlock(i, FirstEntryBlock);
-  }
-}
-  }
-
   // Remove IfTrue1
   if (IfTrue1 != FirstEntryBlock) {
 IfTrue1->dropAllReferences();
diff --git a/llvm/test/Transforms/Util/flattencfg.ll 
b/llvm/test/Transforms/Util/flattencfg.ll
index 4a4d4279f360d6..5f8dd981293345 100644
--- a/llvm/test/Transforms/Util/flattencfg.ll
+++ b/llvm/test/Transforms/Util/flattencfg.ll
@@ -77,13 +77,16 @@ define void @test_not_crash3(i32 %a) #0 {
 ; CHECK-SAME: (i32 [[A:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT:br i1 [[A_EQ_0]], label [[BB0:%.*]], label [[BB1:%.*]]
+; CHECK:   bb0:
+; CHECK-NEXT:br label [[BB1]]
+; CHECK:   bb1:
 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1
-; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]]
-; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]]
+; CHECK-NEXT:br i1 [[A_EQ_1]], label [[BB2:%.*]], label [[BB3:%.*]]
 ; CHECK:   bb2:
 ; CHECK-NEXT:br label [[BB3]]
 ; CHECK:   bb3:
-; CHECK-NEXT:[[CHECK_BADREF:%.*]] = phi i32 [ 17, [[ENTRY:%.*]] ], [ 11, 
[[BB2]] ]
+; CHECK-NEXT:[[CHECK_BADREF:%.*]] = phi i32 [ 17, [[BB1]] ], [ 11, [[BB2]] 
]
 ; CHECK-NEXT:ret void
 ;
 entry:
@@ -278,9 +281,9 @@ define i1 @test_cond_multi_use(i32 %x, i32 %y, i32 %z) {
 ; CHECK-NEXT:  entry.x:
 ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0
 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0
-; CHECK-NEXT:[[TMP0:%.*]] = xor i1 [[CMP_Y]], true
-; CHECK-NEXT:[[TMP1:%.*]] = or i1 [[CMP_X]], [[TMP0]]
-; CHECK-NEXT:br i1 [[TMP1]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
+; CHECK-NEXT:[[CMP_Y_NOT:%.*]] = xor i1 [[CMP_Y]], true
+; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y_NOT]]
+; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
 ; CHECK:   if.then.y:
 ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4
 ; CHECK-NEXT:br label [[EXIT]]

``




https://github.com/llvm/llvm-project/pull/82925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/18.x: [FlattenCFG] Fix the miscompilation where phi nodes exist in the merge point (#81987) (PR #82925)

2024-02-25 Thread Nikita Popov via llvm-branch-commits

https://github.com/nikic approved this pull request.


https://github.com/llvm/llvm-project/pull/82925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP] Implement __kmp_is_address_mapped on DragonFlyBSD. (#82895) (PR #82940)

2024-02-25 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/82940

Backport 9e7c0b1385baa1acffb62e0589ff100dd972cc0d

Requested by: @brad0

>From 0c5badd55387e36245ba735aee1d22b941e5c09f Mon Sep 17 00:00:00 2001
From: David CARLIER 
Date: Sun, 25 Feb 2024 14:13:04 +
Subject: [PATCH] [OpenMP] Implement __kmp_is_address_mapped on DragonFlyBSD.
 (#82895)

implement internal __kmp_is_address_mapped.

(cherry picked from commit 9e7c0b1385baa1acffb62e0589ff100dd972cc0d)
---
 openmp/runtime/cmake/LibompHandleFlags.cmake |  3 ++
 openmp/runtime/src/z_Linux_util.cpp  | 51 ++--
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/openmp/runtime/cmake/LibompHandleFlags.cmake 
b/openmp/runtime/cmake/LibompHandleFlags.cmake
index e5c7a3ec6aaa90..eed98036dd51a6 100644
--- a/openmp/runtime/cmake/LibompHandleFlags.cmake
+++ b/openmp/runtime/cmake/LibompHandleFlags.cmake
@@ -144,6 +144,9 @@ function(libomp_get_libflags libflags)
 libomp_append(libflags_local "-Wl,--no-as-needed" 
LIBOMP_HAVE_AS_NEEDED_FLAG)
 libomp_append(libflags_local "-lm")
 libomp_append(libflags_local "-Wl,--as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
+if (${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
+  libomp_append(libflags_local "-lkvm")
+endif()
   elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|NetBSD|Solaris")
 libomp_append(libflags_local -lm)
   endif()
diff --git a/openmp/runtime/src/z_Linux_util.cpp 
b/openmp/runtime/src/z_Linux_util.cpp
index 513ec6517d00bd..3636266677d99e 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -59,6 +59,9 @@
 #include 
 #include 
 #include 
+#if KMP_OS_DRAGONFLY
+#include 
+#endif
 #elif KMP_OS_NETBSD || KMP_OS_OPENBSD
 #include 
 #include 
@@ -1042,9 +1045,7 @@ extern "C" void __kmp_reap_monitor(kmp_info_t *th) {
 #else
 // Empty symbol to export (see exports_so.txt) when
 // monitor thread feature is disabled
-extern "C" void __kmp_reap_monitor(kmp_info_t *th) {
-  (void)th;
-}
+extern "C" void __kmp_reap_monitor(kmp_info_t *th) { (void)th; }
 #endif // KMP_USE_MONITOR
 
 void __kmp_reap_worker(kmp_info_t *th) {
@@ -2133,7 +2134,47 @@ int __kmp_is_address_mapped(void *addr) {
 lw += cursz;
   }
   kmpc_free(buf);
+#elif KMP_OS_DRAGONFLY
+  char err[_POSIX2_LINE_MAX];
+  kinfo_proc *proc;
+  vmspace sp;
+  vm_map *cur;
+  vm_map_entry entry, *c;
+  struct proc p;
+  kvm_t *fd;
+  uintptr_t uaddr;
+  int num;
+
+  fd = kvm_openfiles(nullptr, nullptr, nullptr, O_RDONLY, err);
+  if (!fd) {
+return 0;
+  }
+
+  proc = kvm_getprocs(fd, KERN_PROC_PID, getpid(), &num);
+
+  if (kvm_read(fd, static_cast(proc->kp_paddr), &p, sizeof(p)) !=
+  sizeof(p) ||
+  kvm_read(fd, reinterpret_cast(p.p_vmspace), &sp, sizeof(sp)) 
!=
+  sizeof(sp)) {
+kvm_close(fd);
+return 0;
+  }
+
+  (void)rc;
+  cur = &sp.vm_map;
+  uaddr = reinterpret_cast(addr);
+  for (c = kvm_vm_map_entry_first(fd, cur, &entry); c;
+   c = kvm_vm_map_entry_next(fd, c, &entry)) {
+if ((uaddr >= entry.ba.start) && (uaddr <= entry.ba.end)) {
+  if ((entry.protection & VM_PROT_READ) != 0 &&
+  (entry.protection & VM_PROT_WRITE) != 0) {
+found = 1;
+break;
+  }
+}
+  }
 
+  kvm_close(fd);
 #elif KMP_OS_DARWIN
 
   /* On OS X*, /proc pseudo filesystem is not available. Try to read memory
@@ -2212,9 +2253,9 @@ int __kmp_is_address_mapped(void *addr) {
   }
 #elif KMP_OS_WASI
   found = (int)addr < (__builtin_wasm_memory_size(0) * PAGESIZE);
-#elif KMP_OS_DRAGONFLY || KMP_OS_SOLARIS || KMP_OS_AIX
+#elif KMP_OS_SOLARIS || KMP_OS_AIX
 
-  // FIXME(DragonFly, Solaris, AIX): Implement this
+  // FIXME(Solaris, AIX): Implement this
   found = 1;
 
 #else

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [openmp] release/18.x: [OpenMP] Implement __kmp_is_address_mapped on DragonFlyBSD. (#82895) (PR #82940)

2024-02-25 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/82940
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [llvm] A copy of https://github.com/llvm/llvm-project/pull/66825. Actually this is a superset (a copy plus the thinlto-import change) (PR #80761)

2024-02-25 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 edited 
https://github.com/llvm/llvm-project/pull/80761
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits