[llvm-branch-commits] [llvm] release/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread Orlando Cazalet-Hyams via llvm-branch-commits

OCHyams wrote:

Edge-case `BasicBlock::end()` iterator dereference, depends on 
https://github.com/llvm/llvm-project/pull/106690

https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end edge case (#105670) (PR #106690)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: None (llvmbot)


Changes

Backport f5815534d180c544bffd46f09c28b6fc334260fb

Requested by: @OCHyams

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


2 Files Affected:

- (modified) llvm/lib/IR/BasicBlock.cpp (+10-14) 
- (modified) llvm/unittests/IR/BasicBlockDbgInfoTest.cpp (+2-2) 


``diff
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index bf19934da047c4..0a9498f051cb59 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -961,9 +961,13 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator 
Dest, BasicBlock *Src,
   // Detach the marker at Dest -- this lets us move the "" DbgRecords
   // around.
   DbgMarker *DestMarker = nullptr;
-  if (Dest != end()) {
-if ((DestMarker = getMarker(Dest)))
+  if ((DestMarker = getMarker(Dest))) {
+if (Dest == end()) {
+  assert(DestMarker == getTrailingDbgRecords());
+  deleteTrailingDbgRecords();
+} else {
   DestMarker->removeFromParent();
+}
   }
 
   // If we're moving the tail range of DbgRecords (":::"), absorb them into the
@@ -1005,22 +1009,14 @@ void 
BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
 } else {
   // Insert them right at the start of the range we moved, ahead of First
   // and the "" DbgRecords.
+  // This also covers the rare circumstance where we insert at end(), and 
we
+  // did not generate the iterator with begin() / getFirstInsertionPt(),
+  // meaning any trailing debug-info at the end of the block would
+  // "normally" have been pushed in front of "First". We move it there now.
   DbgMarker *FirstMarker = createMarker(First);
   FirstMarker->absorbDebugValues(*DestMarker, true);
 }
 DestMarker->eraseFromParent();
-  } else if (Dest == end() && !InsertAtHead) {
-// In the rare circumstance where we insert at end(), and we did not
-// generate the iterator with begin() / getFirstInsertionPt(), it means
-// any trailing debug-info at the end of the block would "normally" have
-// been pushed in front of "First". Move it there now.
-DbgMarker *TrailingDbgRecords = getTrailingDbgRecords();
-if (TrailingDbgRecords) {
-  DbgMarker *FirstMarker = createMarker(First);
-  FirstMarker->absorbDebugValues(*TrailingDbgRecords, true);
-  TrailingDbgRecords->eraseFromParent();
-  deleteTrailingDbgRecords();
-}
   }
 }
 
diff --git a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp 
b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
index 91a0745a0cc76e..835780e63aaf4f 100644
--- a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
+++ b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
@@ -141,11 +141,11 @@ TEST(BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
   Function *F = M->getFunction("func");
 
   BasicBlock &BB = F->getEntryBlock();
-  auto I = std::prev(BB.end(), 2);
+  auto I = std::prev(BB.end(), 2); // store i32 2, ptr %1.
   BB.splitBasicBlockBefore(I, "before");
 
   BasicBlock &BBBefore = F->getEntryBlock();
-  auto I2 = std::prev(BBBefore.end(), 2);
+  auto I2 = std::prev(BBBefore.end()); // br label %1 (new).
   ASSERT_TRUE(I2->hasDbgRecords());
 }
 

``




https://github.com/llvm/llvm-project/pull/106690
___
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/19.x: [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end edge case (#105670) (PR #106690)

2024-08-30 Thread via llvm-branch-commits

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

Backport f5815534d180c544bffd46f09c28b6fc334260fb

Requested by: @OCHyams

>From ebc702875f0680a65386ba84501096c6a20341eb Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Wed, 28 Aug 2024 14:20:33 +0100
Subject: [PATCH] [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end
 edge case (#105670)

Not quite NFC, fixes splitBasicBlockBefore case when we split before an
instruction with debug records (but without the headBit set, i.e., we are
splitting before the instruction but after the debug records that come before
it). splitBasicBlockBefore splices the instructions before the split point into
a new block. Prior to this patch, the debug records would get shifted up to the
front of the spliced instructions (as seen in the modified unittest - I believe
the unittest was checking erroneous behaviour). We instead want to leave those
debug records at the end of the spliced instructions.

The functionality of the deleted `else if` branch is covered by the remaining
`if` now that `DestMarker` is set to the trailing marker if `Dest` is `end()`.
Previously the "===" markers were sometimes detached, now we always detach
them and always reattach them.

Note: `deleteTrailingDbgRecords` only "unlinks" the tailing marker from the
block, it doesn't delete anything. The trailing marker is still cleaned up
properly inside the final `if` body with `DestMarker->eraseFromParent();`.

Part 1 of 2 needed for #105571

(cherry picked from commit f5815534d180c544bffd46f09c28b6fc334260fb)
---
 llvm/lib/IR/BasicBlock.cpp  | 24 +
 llvm/unittests/IR/BasicBlockDbgInfoTest.cpp |  4 ++--
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index bf19934da047c4..0a9498f051cb59 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -961,9 +961,13 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator 
Dest, BasicBlock *Src,
   // Detach the marker at Dest -- this lets us move the "" DbgRecords
   // around.
   DbgMarker *DestMarker = nullptr;
-  if (Dest != end()) {
-if ((DestMarker = getMarker(Dest)))
+  if ((DestMarker = getMarker(Dest))) {
+if (Dest == end()) {
+  assert(DestMarker == getTrailingDbgRecords());
+  deleteTrailingDbgRecords();
+} else {
   DestMarker->removeFromParent();
+}
   }
 
   // If we're moving the tail range of DbgRecords (":::"), absorb them into the
@@ -1005,22 +1009,14 @@ void 
BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
 } else {
   // Insert them right at the start of the range we moved, ahead of First
   // and the "" DbgRecords.
+  // This also covers the rare circumstance where we insert at end(), and 
we
+  // did not generate the iterator with begin() / getFirstInsertionPt(),
+  // meaning any trailing debug-info at the end of the block would
+  // "normally" have been pushed in front of "First". We move it there now.
   DbgMarker *FirstMarker = createMarker(First);
   FirstMarker->absorbDebugValues(*DestMarker, true);
 }
 DestMarker->eraseFromParent();
-  } else if (Dest == end() && !InsertAtHead) {
-// In the rare circumstance where we insert at end(), and we did not
-// generate the iterator with begin() / getFirstInsertionPt(), it means
-// any trailing debug-info at the end of the block would "normally" have
-// been pushed in front of "First". Move it there now.
-DbgMarker *TrailingDbgRecords = getTrailingDbgRecords();
-if (TrailingDbgRecords) {
-  DbgMarker *FirstMarker = createMarker(First);
-  FirstMarker->absorbDebugValues(*TrailingDbgRecords, true);
-  TrailingDbgRecords->eraseFromParent();
-  deleteTrailingDbgRecords();
-}
   }
 }
 
diff --git a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp 
b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
index 91a0745a0cc76e..835780e63aaf4f 100644
--- a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
+++ b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
@@ -141,11 +141,11 @@ TEST(BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
   Function *F = M->getFunction("func");
 
   BasicBlock &BB = F->getEntryBlock();
-  auto I = std::prev(BB.end(), 2);
+  auto I = std::prev(BB.end(), 2); // store i32 2, ptr %1.
   BB.splitBasicBlockBefore(I, "before");
 
   BasicBlock &BBBefore = F->getEntryBlock();
-  auto I2 = std::prev(BBBefore.end(), 2);
+  auto I2 = std::prev(BBBefore.end()); // br label %1 (new).
   ASSERT_TRUE(I2->hasDbgRecords());
 }
 

___
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/19.x: [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end edge case (#105670) (PR #106690)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/106690
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: None (llvmbot)


Changes

Backport 43661a1214353ea1773a711f403f8d1118e9ca0f

Requested by: @OCHyams

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


2 Files Affected:

- (modified) llvm/lib/IR/BasicBlock.cpp (+10-2) 
- (modified) llvm/unittests/IR/BasicBlockDbgInfoTest.cpp (+54) 


``diff
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index bf19934da047c4..103ec0da4763fd 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -971,8 +971,16 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator 
Dest, BasicBlock *Src,
   if (ReadFromTail && Src->getMarker(Last)) {
 DbgMarker *FromLast = Src->getMarker(Last);
 if (LastIsEnd) {
-  Dest->adoptDbgRecords(Src, Last, true);
-  // adoptDbgRecords will release any trailers.
+  if (Dest == end()) {
+// Abosrb the trailing markers from Src.
+assert(FromLast == Src->getTrailingDbgRecords());
+createMarker(Dest)->absorbDebugValues(*FromLast, true);
+FromLast->eraseFromParent();
+Src->deleteTrailingDbgRecords();
+  } else {
+// adoptDbgRecords will release any trailers.
+Dest->adoptDbgRecords(Src, Last, true);
+  }
   assert(!Src->getTrailingDbgRecords());
 } else {
   // FIXME: can we use adoptDbgRecords here to reduce allocations?
diff --git a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp 
b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
index 91a0745a0cc76e..e6f8df2762e81e 100644
--- a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
+++ b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
@@ -1525,4 +1525,58 @@ TEST(BasicBlockDbgInfoTest, DbgMoveToEnd) {
   EXPECT_FALSE(Ret->hasDbgRecords());
 }
 
+TEST(BasicBlockDbgInfoTest, CloneTrailingRecordsToEmptyBlock) {
+  LLVMContext C;
+  std::unique_ptr M = parseIR(C, R"(
+define i16 @foo(i16 %a) !dbg !6 {
+entry:
+  %b = add i16 %a, 0
+#dbg_value(i16 %b, !9, !DIExpression(), !11)
+  ret i16 0, !dbg !11
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: 
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, 
enums: !2)
+!1 = !DIFile(filename: "t.ll", directory: "/")
+!2 = !{}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, 
file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | 
DISPFlagOptimized, unit: !0, retainedNodes: !8)
+!7 = !DISubroutineType(types: !2)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
+!10 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_unsigned)
+!11 = !DILocation(line: 1, column: 1, scope: !6)
+)");
+  ASSERT_TRUE(M);
+
+  Function *F = M->getFunction("foo");
+  BasicBlock &BB = F->getEntryBlock();
+  // Start with no trailing records.
+  ASSERT_FALSE(BB.getTrailingDbgRecords());
+
+  BasicBlock::iterator Ret = std::prev(BB.end());
+  BasicBlock::iterator B = std::prev(Ret);
+
+  // Delete terminator which has debug records: we now get trailing records.
+  Ret->eraseFromParent();
+  EXPECT_TRUE(BB.getTrailingDbgRecords());
+
+  BasicBlock *NewBB = BasicBlock::Create(C, "NewBB", F);
+  NewBB->splice(NewBB->end(), &BB, B, BB.end());
+
+  // The trailing records should've been absorbed into NewBB.
+  EXPECT_FALSE(BB.getTrailingDbgRecords());
+  EXPECT_TRUE(NewBB->getTrailingDbgRecords());
+  if (NewBB->getTrailingDbgRecords()) {
+EXPECT_EQ(
+llvm::range_size(NewBB->getTrailingDbgRecords()->getDbgRecordRange()),
+1u);
+  }
+
+  // Drop the trailing records now, to prevent a cleanup assertion.
+  NewBB->deleteTrailingDbgRecords();
+}
+
 } // End anonymous namespace.

``




https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread via llvm-branch-commits

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

Backport 43661a1214353ea1773a711f403f8d1118e9ca0f

Requested by: @OCHyams

>From e94bf3824c082f2bfe77a84c2470814d89fb6de6 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 29 Aug 2024 14:12:02 +0100
Subject: [PATCH] [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case
 (#105671)

Fix #105571 which demonstrates an end() iterator dereference when
performing a non-empty splice to end() from a region that ends at
Src::end().

Rather than calling Instruction::adoptDbgRecords from Dest, create a marker
(which takes an iterator) and absorbDebugValues onto that. The "absorb" variant
doesn't clean up the source marker, which in this case we know is a trailing
marker, so we have to do that manually.

(cherry picked from commit 43661a1214353ea1773a711f403f8d1118e9ca0f)
---
 llvm/lib/IR/BasicBlock.cpp  | 12 -
 llvm/unittests/IR/BasicBlockDbgInfoTest.cpp | 54 +
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index bf19934da047c4..103ec0da4763fd 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -971,8 +971,16 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator 
Dest, BasicBlock *Src,
   if (ReadFromTail && Src->getMarker(Last)) {
 DbgMarker *FromLast = Src->getMarker(Last);
 if (LastIsEnd) {
-  Dest->adoptDbgRecords(Src, Last, true);
-  // adoptDbgRecords will release any trailers.
+  if (Dest == end()) {
+// Abosrb the trailing markers from Src.
+assert(FromLast == Src->getTrailingDbgRecords());
+createMarker(Dest)->absorbDebugValues(*FromLast, true);
+FromLast->eraseFromParent();
+Src->deleteTrailingDbgRecords();
+  } else {
+// adoptDbgRecords will release any trailers.
+Dest->adoptDbgRecords(Src, Last, true);
+  }
   assert(!Src->getTrailingDbgRecords());
 } else {
   // FIXME: can we use adoptDbgRecords here to reduce allocations?
diff --git a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp 
b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
index 91a0745a0cc76e..e6f8df2762e81e 100644
--- a/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
+++ b/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
@@ -1525,4 +1525,58 @@ TEST(BasicBlockDbgInfoTest, DbgMoveToEnd) {
   EXPECT_FALSE(Ret->hasDbgRecords());
 }
 
+TEST(BasicBlockDbgInfoTest, CloneTrailingRecordsToEmptyBlock) {
+  LLVMContext C;
+  std::unique_ptr M = parseIR(C, R"(
+define i16 @foo(i16 %a) !dbg !6 {
+entry:
+  %b = add i16 %a, 0
+#dbg_value(i16 %b, !9, !DIExpression(), !11)
+  ret i16 0, !dbg !11
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: 
"debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, 
enums: !2)
+!1 = !DIFile(filename: "t.ll", directory: "/")
+!2 = !{}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, 
file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | 
DISPFlagOptimized, unit: !0, retainedNodes: !8)
+!7 = !DISubroutineType(types: !2)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
+!10 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_unsigned)
+!11 = !DILocation(line: 1, column: 1, scope: !6)
+)");
+  ASSERT_TRUE(M);
+
+  Function *F = M->getFunction("foo");
+  BasicBlock &BB = F->getEntryBlock();
+  // Start with no trailing records.
+  ASSERT_FALSE(BB.getTrailingDbgRecords());
+
+  BasicBlock::iterator Ret = std::prev(BB.end());
+  BasicBlock::iterator B = std::prev(Ret);
+
+  // Delete terminator which has debug records: we now get trailing records.
+  Ret->eraseFromParent();
+  EXPECT_TRUE(BB.getTrailingDbgRecords());
+
+  BasicBlock *NewBB = BasicBlock::Create(C, "NewBB", F);
+  NewBB->splice(NewBB->end(), &BB, B, BB.end());
+
+  // The trailing records should've been absorbed into NewBB.
+  EXPECT_FALSE(BB.getTrailingDbgRecords());
+  EXPECT_TRUE(NewBB->getTrailingDbgRecords());
+  if (NewBB->getTrailingDbgRecords()) {
+EXPECT_EQ(
+llvm::range_size(NewBB->getTrailingDbgRecords()->getDbgRecordRange()),
+1u);
+  }
+
+  // Drop the trailing records now, to prevent a cleanup assertion.
+  NewBB->deleteTrailingDbgRecords();
+}
+
 } // End anonymous namespace.

___
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/19.x: [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end edge case (#105670) (PR #106690)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106690
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread Jeremy Morse via llvm-branch-commits

jmorse wrote:

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

I feel this is safe to go into the release branch; I don't think it should 
block the 19.0.0 release though, better to have it in a point release. This 
fault has been present for roughly five months and has only just been 
uncovered, so IMHO it's not a pressing issue.

https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread Danial Klimkin via llvm-branch-commits

dklimkin wrote:

We are seeing ASAN errors past 
[43661a1214353ea1773a711f403f8d1118e9ca0f](https://github.com/llvm/llvm-project/commit/43661a1214353ea1773a711f403f8d1118e9ca0f):

AddressSanitizer: 120 byte(s) leaked in 2 allocation(s).
```
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
#0 0x55661863b59d in operator new(unsigned long) 
llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
#1 0x7fe8882b642e in 
llvm::DbgVariableRecord::createUnresolvedDbgVariableRecord(llvm::DbgVariableRecord::LocationType,
 llvm::Metadata*, llvm::MDNode*, llvm::MDNode*, llvm::MDNode*, llvm::Metadata*, 
llvm::MDNode*, llvm::MDNode*) 
llvm-project/llvm/lib/IR/DebugProgramInstruction.cpp:174:10
#2 0x7fe88c37fdc3 in llvm::LLParser::parseDebugRecord(llvm::DbgRecord*&, 
llvm::LLParser::PerFunctionState&) 
llvm-project/llvm/lib/AsmParser/LLParser.cpp:6832:8
#3 0x7fe88c37ef4c in 
llvm::LLParser::parseBasicBlock(llvm::LLParser::PerFunctionState&) 
llvm-project/llvm/lib/AsmParser/LLParser.cpp:6673:11
#4 0x7fe88c344e2b in llvm::LLParser::parseFunctionBody(llvm::Function&, 
unsigned int, llvm::ArrayRef) 
llvm-project/llvm/lib/AsmParser/LLParser.cpp:6618:9
#5 0x7fe88c33cbe3 in llvm::LLParser::parseDefine() 
llvm-project/llvm/lib/AsmParser/LLParser.cpp:762:10
#6 0x7fe88c335623 in llvm::LLParser::parseTopLevelEntities() 
llvm-project/llvm/lib/AsmParser/LLParser.cpp:566:11
#7 0x7fe88c334e42 in llvm::LLParser::Run(bool, 
llvm::function_ref, std::__u::allocator>> (llvm::StringRef, 
llvm::StringRef)>) llvm-project/llvm/lib/AsmParser/LLParser.cpp:94:10
#8 0x7fe88c3c757e in parseAssemblyInto(llvm::MemoryBufferRef, 
llvm::Module*, llvm::ModuleSummaryIndex*, llvm::SMDiagnostic&, 
llvm::SlotMapping*, bool, 
llvm::function_ref, std::__u::allocator>> (llvm::StringRef, 
llvm::StringRef)>) llvm-project/llvm/lib/AsmParser/Parser.cpp:35:8
#9 0x7fe88c3c914b in parseAssemblyInto 
llvm-project/llvm/lib/AsmParser/Parser.cpp:42:10
#10 0x7fe88c3c914b in parseAssembly 
llvm-project/llvm/lib/AsmParser/Parser.cpp:53:7
#11 0x7fe88c3c914b in llvm::parseAssemblyString(llvm::StringRef, 
llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*) 
llvm-project/llvm/lib/AsmParser/Parser.cpp:141:10
#12 0x7fe89ea5fd0d in parseIR 
llvm-project/llvm/unittests/IR/BasicBlockDbgInfoTest.cpp:30:33

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x55661863b59d in operator new(unsigned long) 
llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
#1 0x7fe888182813 in 
llvm::BasicBlock::createMarker(llvm::ilist_iterator_w_bits, false, false>) 
llvm-project/llvm/lib/IR/BasicBlock.cpp:71:8
#2 0x7fe88818af8c in 
llvm::BasicBlock::spliceDebugInfoImpl(llvm::ilist_iterator_w_bits, false, false>, llvm::BasicBlock*, 
llvm::ilist_iterator_w_bits, false, false>, 
llvm::ilist_iterator_w_bits, false, false>) 
llvm-project/llvm/lib/IR/BasicBlock.cpp:981:9
#3 0x7fe88818a544 in 
llvm::BasicBlock::spliceDebugInfo(llvm::ilist_iterator_w_bits, false, false>, llvm::BasicBlock*, 
llvm::ilist_iterator_w_bits, false, false>, 
llvm::ilist_iterator_w_bits, false, false>) 
llvm-project/llvm/lib/IR/BasicBlock.cpp:873:3
#4 0x7fe888188da2 in 
llvm::BasicBlock::splice(llvm::ilist_iterator_w_bits, false, false>, llvm::BasicBlock*, 
llvm::ilist_iterator_w_bits, false, false>, 
llvm::ilist_iterator_w_bits, false, false>) 
llvm-project/llvm/lib/IR/BasicBlock.cpp:1051:5
```


https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [RemoveDIs] Fix spliceDebugInfo splice-to-end edge case (#105671) (PR #106691)

2024-08-30 Thread Orlando Cazalet-Hyams via llvm-branch-commits

OCHyams wrote:

Thanks for the report, I'll look at that now

https://github.com/llvm/llvm-project/pull/106691
___
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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)

2024-08-30 Thread via llvm-branch-commits

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

Backport 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713

Requested by: @aykevl

>From 15118db62fd8942ac10422be673743d2c0edf4e8 Mon Sep 17 00:00:00 2001
From: Patryk Wychowaniec 
Date: Fri, 30 Aug 2024 15:25:54 +0200
Subject: [PATCH] [AVR] Fix parsing & emitting relative jumps (#106722)

Ever since 6859685a87ad093d60c8bed60b116143c0a684c7 (or, precisely,
84428dafc0941e3a31303fa1b286835ab2b8e234) relative jumps emitted by the
AVR codegen are off by two bytes - this pull request fixes it.

## Abstract

As compared to absolute jumps, relative jumps - such as rjmp, rcall or
brsh - have an implied `pc+2` behavior; that is, `jmp 100` is `pc =
100`, but `rjmp 100` gets understood as `pc = pc + 100 + 2`.

This is not reflected in the AVR codegen:

https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L89

... which always emits relative jumps that are two bytes too far - or
rather it _would_ emit such jumps if not for this check:

https://github.com/llvm/llvm-project/blob/f95026dbf66e353128a3a3d7b55f3e52d5985535/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp#L517

... which causes most of the relative jumps to be actually resolved
late, by the linker, which applies the offsetting logic on its own,
hiding the issue within LLVM.

[Some time
ago](https://github.com/llvm/llvm-project/commit/697a162fa63df328ec9ca334636c5e85390b2bf0)
we've had a similar "jumps are off" problem that got solved by touching
`shouldForceRelocation()`, but I think that has worked only by accident.
It's exploited the fact that absolute vs relative jumps in the parsed
assembly can be distinguished through a "side channel" check relying on
the existence of labels (i.e. absolute jumps happen to named labels, but
relative jumps are anonymous, so to say). This was an alright idea back
then, but it got broken by 6859685a87ad093d60c8bed60b116143c0a684c7.

I propose a different approach:
- when emitting relative jumps, offset them by `-2` (well, `-1`,
strictly speaking, because those instructions rely on right-shifted
offset),
- when parsing relative jumps, treat `.` as `+2` and read `rjmp .+1234`
as `rjmp (1234 + 2)`.

This approach seems to be sound and now we generate the same assembly as
avr-gcc, which can be confirmed with:

```cpp
// avr-gcc test.c -O3 && avr-objdump -d a.out

int main() {
asm(
"  foo:\n\t"
"rjmp  .+2\n\t"
"rjmp  .-2\n\t"
"rjmp  foo\n\t"
"rjmp  .+8\n\t"
"rjmp  end\n\t"
"rjmp  .+0\n\t"
"  end:\n\t"
"rjmp .-4\n\t"
"rjmp .-6\n\t"
"  x:\n\t"
"rjmp x\n\t"
".short 0xc00f\n\t"
);
}
```

avr-gcc is also how I got the opcodes for all new tests like `inst-brbc.s`, so 
we should be good.

(cherry picked from commit 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713)
---
 .../lib/Target/AVR/AsmParser/AVRAsmParser.cpp |  15 +-
 .../Target/AVR/MCTargetDesc/AVRAsmBackend.cpp |  12 +-
 llvm/test/CodeGen/AVR/jmp.ll  |  25 ++
 llvm/test/MC/AVR/inst-brbc.s  |  23 +-
 llvm/test/MC/AVR/inst-brbs.s  |  22 +-
 llvm/test/MC/AVR/inst-brcc.s  |  28 ++
 llvm/test/MC/AVR/inst-brcs.s  |  28 ++
 llvm/test/MC/AVR/inst-breq.s  |  28 ++
 llvm/test/MC/AVR/inst-brge.s  |  24 ++
 llvm/test/MC/AVR/inst-brhc.s  |  24 ++
 llvm/test/MC/AVR/inst-brhs.s  |  24 ++
 llvm/test/MC/AVR/inst-brid.s  |  24 ++
 llvm/test/MC/AVR/inst-brie.s  |  24 ++
 llvm/test/MC/AVR/inst-brlo.s  |  24 ++
 llvm/test/MC/AVR/inst-brlt.s  |  24 ++
 llvm/test/MC/AVR/inst-brmi.s  |  24 ++
 llvm/test/MC/AVR/inst-brne.s  |  28 ++
 llvm/test/MC/AVR/inst-brpl.s  |  24 ++
 llvm/test/MC/AVR/inst-brsh.s  |  24 ++
 llvm/test/MC/AVR/inst-brtc.s  |  24 ++
 llvm/test/MC/AVR/inst-brts.s  |  24 ++
 llvm/test/MC/AVR/inst-brvc.s  |  24 ++
 llvm/test/MC/AVR/inst-brvs.s  |  24 ++
 llvm/test/MC/AVR/inst-family-cond-branch.s| 321 --
 llvm/test/MC/AVR/inst-rcall.s |  33 +-
 llvm/test/MC/AVR/inst-rjmp.s  |  69 ++--
 26 files changed, 567 insertions(+), 401 deletions(-)
 create mode 100644 llvm/test/CodeGen/AVR/jmp.ll
 create mode 100644 llvm/test/MC/AVR/inst-brcc.s
 create mode 100644 llvm/test/MC/AVR/inst-brcs.s
 create mode 100644 llvm/test/MC/AVR/inst-breq.s
 create mode 100644 llvm/test/MC/AVR/inst-brge.s
 create mode 100644 llvm/test/MC/AVR/inst-brhc.s
 create mode 100644 llvm/test/MC/AVR/inst-brhs.s
 create mode 100644 llvm/test/MC/AVR/inst-brid.s
 create mode 100644 llvm/test/MC/AVR/inst-brie.s
 create mode 100644 llvm/test/MC/AVR/inst-brlo.s
 create mode 100644 llvm/test/MC/AVR/inst-br

[llvm-branch-commits] [llvm] release/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106729
___
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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (llvmbot)


Changes

Backport 86a60e7f1e8f361f84ccb6e656e848dd4fbaa713

Requested by: @aykevl

---

Patch is 46.04 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/106729.diff


26 Files Affected:

- (modified) llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp (+11-4) 
- (modified) llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp (+5-7) 
- (added) llvm/test/CodeGen/AVR/jmp.ll (+25) 
- (modified) llvm/test/MC/AVR/inst-brbc.s (+12-11) 
- (modified) llvm/test/MC/AVR/inst-brbs.s (+11-11) 
- (added) llvm/test/MC/AVR/inst-brcc.s (+28) 
- (added) llvm/test/MC/AVR/inst-brcs.s (+28) 
- (added) llvm/test/MC/AVR/inst-breq.s (+28) 
- (added) llvm/test/MC/AVR/inst-brge.s (+24) 
- (added) llvm/test/MC/AVR/inst-brhc.s (+24) 
- (added) llvm/test/MC/AVR/inst-brhs.s (+24) 
- (added) llvm/test/MC/AVR/inst-brid.s (+24) 
- (added) llvm/test/MC/AVR/inst-brie.s (+24) 
- (added) llvm/test/MC/AVR/inst-brlo.s (+24) 
- (added) llvm/test/MC/AVR/inst-brlt.s (+24) 
- (added) llvm/test/MC/AVR/inst-brmi.s (+24) 
- (added) llvm/test/MC/AVR/inst-brne.s (+28) 
- (added) llvm/test/MC/AVR/inst-brpl.s (+24) 
- (added) llvm/test/MC/AVR/inst-brsh.s (+24) 
- (added) llvm/test/MC/AVR/inst-brtc.s (+24) 
- (added) llvm/test/MC/AVR/inst-brts.s (+24) 
- (added) llvm/test/MC/AVR/inst-brvc.s (+24) 
- (added) llvm/test/MC/AVR/inst-brvs.s (+24) 
- (removed) llvm/test/MC/AVR/inst-family-cond-branch.s (-321) 
- (modified) llvm/test/MC/AVR/inst-rcall.s (+17-16) 
- (modified) llvm/test/MC/AVR/inst-rjmp.s (+38-31) 


``diff
diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp 
b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 383dfcc31117c1..c016b2dd91dc67 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -72,7 +72,7 @@ class AVRAsmParser : public MCTargetAsmParser {
   int parseRegisterName();
   int parseRegister(bool RestoreOnFailure = false);
   bool tryParseRegisterOperand(OperandVector &Operands);
-  bool tryParseExpression(OperandVector &Operands);
+  bool tryParseExpression(OperandVector &Operands, int64_t offset);
   bool tryParseRelocExpression(OperandVector &Operands);
   void eatComma();
 
@@ -418,7 +418,7 @@ bool AVRAsmParser::tryParseRegisterOperand(OperandVector 
&Operands) {
   return false;
 }
 
-bool AVRAsmParser::tryParseExpression(OperandVector &Operands) {
+bool AVRAsmParser::tryParseExpression(OperandVector &Operands, int64_t offset) 
{
   SMLoc S = Parser.getTok().getLoc();
 
   if (!tryParseRelocExpression(Operands))
@@ -437,6 +437,11 @@ bool AVRAsmParser::tryParseExpression(OperandVector 
&Operands) {
   if (getParser().parseExpression(Expression))
 return true;
 
+  if (offset) {
+Expression = MCBinaryExpr::createAdd(
+Expression, MCConstantExpr::create(offset, getContext()), 
getContext());
+  }
+
   SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
   Operands.push_back(AVROperand::CreateImm(Expression, S, E));
   return false;
@@ -529,8 +534,9 @@ bool AVRAsmParser::parseOperand(OperandVector &Operands, 
bool maybeReg) {
 [[fallthrough]];
   case AsmToken::LParen:
   case AsmToken::Integer:
+return tryParseExpression(Operands, 0);
   case AsmToken::Dot:
-return tryParseExpression(Operands);
+return tryParseExpression(Operands, 2);
   case AsmToken::Plus:
   case AsmToken::Minus: {
 // If the sign preceeds a number, parse the number,
@@ -540,7 +546,7 @@ bool AVRAsmParser::parseOperand(OperandVector &Operands, 
bool maybeReg) {
 case AsmToken::BigNum:
 case AsmToken::Identifier:
 case AsmToken::Real:
-  if (!tryParseExpression(Operands))
+  if (!tryParseExpression(Operands, 0))
 return false;
   break;
 default:
@@ -643,6 +649,7 @@ bool AVRAsmParser::ParseInstruction(ParseInstructionInfo 
&Info,
 // These specific operands should be treated as addresses/symbols/labels,
 // other than registers.
 bool maybeReg = true;
+
 if (OperandNum == 1) {
   std::array Insts = {"lds", "adiw", "sbiw", "ldi"};
   for (auto Inst : Insts) {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp 
b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
index 0d29912bee2646..388d58a82214d1 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
@@ -94,6 +94,9 @@ static void adjustRelativeBranch(unsigned Size, const MCFixup 
&Fixup,
 
   // Rightshifts the value by one.
   AVR::fixups::adjustBranchTarget(Value);
+
+  // Jumps are relative to the current instruction.
+  Value -= 1;
 }
 
 /// 22-bit absolute fixup.
@@ -513,15 +516,10 @@ bool AVRAsmBackend::shouldForceRelocation(const 
MCAssembler &Asm,
   switch ((unsigned)Fixup.getKind()) {
   default:
 return Fixup.getKind() >= FirstLiteralRelocationKind;
-  // Fixups which should always be recorded as relocations.
   case AVR::f

[llvm-branch-commits] [llvm] release/19.x: [RemoveDIs] Simplify spliceDebugInfo, fixing splice-to-end edge case (#105670) (PR #106690)

2024-08-30 Thread Stephen Tozer via llvm-branch-commits

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

This is a straightforward bugfix.

https://github.com/llvm/llvm-project/pull/106690
___
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] [LoongArch] Optimize for immediate value materialization using BSTRINS_D instruction (PR #106332)

2024-08-30 Thread David Spickett via llvm-branch-commits

DavidSpickett wrote:

We have some tests failing on our 32 bit single stage Arm builder. I'm looking 
into it locally. Usually this is some assumption about type sizes such as 
size_t.

https://lab.llvm.org/buildbot/#/builders/39/builds/1338

https://github.com/llvm/llvm-project/pull/106332
___
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] [LoongArch] Optimize for immediate value materialization using BSTRINS_D instruction (PR #106332)

2024-08-30 Thread David Spickett via llvm-branch-commits

DavidSpickett wrote:

Fixed with 
https://github.com/llvm/llvm-project/commit/c55e24b8507d47a8cc04b5d9570e8e3d02be1ca3.

Some UL that should have been ULL, very easy mistake to make.

https://github.com/llvm/llvm-project/pull/106332
___
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/19.x: [AVR] Fix parsing & emitting relative jumps (#106722) (PR #106729)

2024-08-30 Thread via llvm-branch-commits

aykevl wrote:

This PR should probably be combined with 
https://github.com/llvm/llvm-project/pull/106722 
(https://github.com/llvm/llvm-project/commit/a3816b5a573dbf57ba3082a919ca2de6b47257e9)
 to avoid a build failure.

https://github.com/llvm/llvm-project/pull/106729
___
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] 3f438c3 - Revert "[llvm-lit] Add precommit test to verify current behavior of glob expa…"

2024-08-30 Thread via llvm-branch-commits

Author: Harini0924
Date: 2024-08-30T10:05:09-07:00
New Revision: 3f438c3e7f40f09118d4e1fa8a81b596f3ada5d1

URL: 
https://github.com/llvm/llvm-project/commit/3f438c3e7f40f09118d4e1fa8a81b596f3ada5d1
DIFF: 
https://github.com/llvm/llvm-project/commit/3f438c3e7f40f09118d4e1fa8a81b596f3ada5d1.diff

LOG: Revert "[llvm-lit] Add precommit test to verify current behavior of glob 
expa…"

This reverts commit 9764cf888502fe6dd15ab21de5c2f73cae47a2c0.

Added: 


Modified: 


Removed: 
llvm/utils/lit/tests/Inputs/shtest-glob/example_file1.input
llvm/utils/lit/tests/Inputs/shtest-glob/example_file2.input
llvm/utils/lit/tests/Inputs/shtest-glob/glob-echo.txt
llvm/utils/lit/tests/Inputs/shtest-glob/glob-mkdir.txt
llvm/utils/lit/tests/Inputs/shtest-glob/lit.cfg
llvm/utils/lit/tests/shtest-glob.py



diff  --git a/llvm/utils/lit/tests/Inputs/shtest-glob/example_file1.input 
b/llvm/utils/lit/tests/Inputs/shtest-glob/example_file1.input
deleted file mode 100644
index 0987c9081ca1f3..00
--- a/llvm/utils/lit/tests/Inputs/shtest-glob/example_file1.input
+++ /dev/null
@@ -1,2 +0,0 @@
-## This is the first example file used for testing glob pattern matching.
-This is the first example file.

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-glob/example_file2.input 
b/llvm/utils/lit/tests/Inputs/shtest-glob/example_file2.input
deleted file mode 100644
index f1a843f308262e..00
--- a/llvm/utils/lit/tests/Inputs/shtest-glob/example_file2.input
+++ /dev/null
@@ -1,2 +0,0 @@
-## This is the second example file used for testing glob pattern matching.
-This is the second example file.

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-glob/glob-echo.txt 
b/llvm/utils/lit/tests/Inputs/shtest-glob/glob-echo.txt
deleted file mode 100644
index b69f5e74fd7281..00
--- a/llvm/utils/lit/tests/Inputs/shtest-glob/glob-echo.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-## Tests glob pattern expansion by listing matching files.
-# RUN: echo %S/example_file*.input

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-glob/glob-mkdir.txt 
b/llvm/utils/lit/tests/Inputs/shtest-glob/glob-mkdir.txt
deleted file mode 100644
index d1329f5dbfaaed..00
--- a/llvm/utils/lit/tests/Inputs/shtest-glob/glob-mkdir.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-## Tests glob pattern handling in the mkdir command.
-# RUN: not mkdir %S/example_file*.input

diff  --git a/llvm/utils/lit/tests/Inputs/shtest-glob/lit.cfg 
b/llvm/utils/lit/tests/Inputs/shtest-glob/lit.cfg
deleted file mode 100644
index 4e5f4cac4c4653..00
--- a/llvm/utils/lit/tests/Inputs/shtest-glob/lit.cfg
+++ /dev/null
@@ -1,8 +0,0 @@
-import lit.formats
-
-config.name = "shtest-glob"
-config.suffixes = [".txt"]
-config.test_format = lit.formats.ShTest()
-config.test_source_root = None
-config.test_exec_root = None
-config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))

diff  --git a/llvm/utils/lit/tests/shtest-glob.py 
b/llvm/utils/lit/tests/shtest-glob.py
deleted file mode 100644
index 551331cb38e259..00
--- a/llvm/utils/lit/tests/shtest-glob.py
+++ /dev/null
@@ -1,12 +0,0 @@
-## Tests glob pattern handling in echo command.
-
-# RUN: not %{lit} -a -v %{inputs}/shtest-glob \
-# RUN: | FileCheck -dump-input=fail -match-full-lines %s
-#
-# END.
-
-# CHECK: UNRESOLVED: shtest-glob :: glob-echo.txt ({{[^)]*}})
-# CHECK: TypeError: string argument expected, got 'GlobItem'
-
-# CHECK: FAIL: shtest-glob :: glob-mkdir.txt ({{[^)]*}}
-# CHECK: # error: command failed with exit status: 1



___
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] [lldb] c6ff3f0 - Revert "[LLDB][DWARF] Add an option to silence unsupported DW_FORM warnings (…"

2024-08-30 Thread via llvm-branch-commits

Author: Walter Erquinigo
Date: 2024-08-30T13:17:47-04:00
New Revision: c6ff3f00afa70a47853af3e420aa8a99f76db3a9

URL: 
https://github.com/llvm/llvm-project/commit/c6ff3f00afa70a47853af3e420aa8a99f76db3a9
DIFF: 
https://github.com/llvm/llvm-project/commit/c6ff3f00afa70a47853af3e420aa8a99f76db3a9.diff

LOG: Revert "[LLDB][DWARF] Add an option to silence unsupported DW_FORM 
warnings (…"

This reverts commit 9aa25b8c15c99d8e717121837a2559801e311e2d.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 2af6dc880842a4..ff44329d081caa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -87,7 +87,7 @@
 #include 
 #include 
 
-// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
 
 #ifdef ENABLE_DEBUG_PRINTF
 #include 
@@ -129,11 +129,6 @@ class PluginProperties : public Properties {
   bool IgnoreFileIndexes() const {
 return GetPropertyAtIndexAs(ePropertyIgnoreIndexes, false);
   }
-
-  bool EmitUnsupportedDWFormValueWarning() const {
-return GetPropertyAtIndexAs(
-ePropertyEmitUnsupportedDWFormValueWarning, true);
-  }
 };
 
 } // namespace
@@ -629,14 +624,12 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
   llvm::DWARFDebugAbbrev *abbrev = DebugAbbrev();
   std::set unsupported_forms = GetUnsupportedForms(abbrev);
   if (!unsupported_forms.empty()) {
-if (GetGlobalPluginProperties().EmitUnsupportedDWFormValueWarning()) {
-  StreamString error;
-  error.Printf("unsupported DW_FORM value%s:",
-   unsupported_forms.size() > 1 ? "s" : "");
-  for (auto form : unsupported_forms)
-error.Printf(" %#x", form);
-  m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
-}
+StreamString error;
+error.Printf("unsupported DW_FORM value%s:",
+ unsupported_forms.size() > 1 ? "s" : "");
+for (auto form : unsupported_forms)
+  error.Printf(" %#x", form);
+m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
 return 0;
   }
 
@@ -1777,17 +1770,16 @@ SymbolFileDWARF 
*SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
 return this;
 
   if (file_index) {
-// We have a SymbolFileDWARFDebugMap, so let it find the right file
+  // We have a SymbolFileDWARFDebugMap, so let it find the right file
 if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile())
   return debug_map->GetSymbolFileByOSOIndex(*file_index);
-
+
 // Handle the .dwp file case correctly
 if (*file_index == DIERef::k_file_index_mask)
   return GetDwpSymbolFile().get(); // DWP case
 
 // Handle the .dwo file case correctly
-return DebugInfo()
-.GetUnitAtIndex(*die_ref.file_index())
+return DebugInfo().GetUnitAtIndex(*die_ref.file_index())
 ->GetDwoSymbolFile(); // DWO case
   }
   return this;
@@ -3629,7 +3621,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
 lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
 if (!location_is_const_value_data) {
   bool op_error = false;
-  const DWARFExpression *location = location_list.GetAlwaysValidExpr();
+  const DWARFExpression* location = location_list.GetAlwaysValidExpr();
   if (location)
 location_DW_OP_addr =
 location->GetLocation_DW_OP_addr(location_form.GetUnit(), 
op_error);

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
index 0f980a514b6720..2f1ce88808b763 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
@@ -5,8 +5,4 @@ let Definition = "symbolfiledwarf" in {
 Global,
 DefaultFalse,
 Desc<"Ignore indexes present in the object files and always index DWARF 
manually.">;
-  def EmitUnsupportedDWFormValueWarning: 
Property<"emit-unsupported-dwform-value", "Boolean">,
-Global,
-DefaultTrue,
-Desc<"Emit warnings about unsupported DW_Form values.">;
 }



___
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] [mlir] f985500 - Revert "[mlir][Transforms] Dialect conversion: Make materializations optional…"

2024-08-30 Thread via llvm-branch-commits

Author: Matthias Springer
Date: 2024-08-30T11:53:51-07:00
New Revision: f98550056573efff12b2fb44980f210312b1db8d

URL: 
https://github.com/llvm/llvm-project/commit/f98550056573efff12b2fb44980f210312b1db8d
DIFF: 
https://github.com/llvm/llvm-project/commit/f98550056573efff12b2fb44980f210312b1db8d.diff

LOG: Revert "[mlir][Transforms] Dialect conversion: Make materializations 
optional…"

This reverts commit d7073c527457dc0a71126381afb3c6f0efa1821c.

Added: 


Modified: 
mlir/include/mlir/Transforms/DialectConversion.h
mlir/lib/Transforms/Utils/DialectConversion.cpp
mlir/test/Conversion/NVGPUToNVVM/nvgpu-to-nvvm.mlir
mlir/test/Dialect/Bufferization/Transforms/finalizing-bufferize.mlir
mlir/test/Transforms/test-legalize-type-conversion.mlir

Removed: 




diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h 
b/mlir/include/mlir/Transforms/DialectConversion.h
index 5f680e8eca7559..60113bdef16a23 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -1124,17 +1124,6 @@ struct ConversionConfig {
   // already been modified) and iterators into past IR state cannot be
   // represented at the moment.
   RewriterBase::Listener *listener = nullptr;
-
-  /// If set to "true", the dialect conversion attempts to build source/target/
-  /// argument materializations through the type converter API in lieu of
-  /// builtin.unrealized_conversion_cast ops. The conversion process fails if
-  /// at least one materialization could not be built.
-  ///
-  /// If set to "false", the dialect conversion does not does not build any
-  /// custom materializations and instead inserts
-  /// builtin.unrealized_conversion_cast ops to ensure that the resulting IR
-  /// is valid.
-  bool buildMaterializations = true;
 };
 
 
//===--===//

diff  --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp 
b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index cc9c9495e5155c..b23fb97959ed67 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -702,12 +702,14 @@ class UnresolvedMaterializationRewrite : public 
OperationRewrite {
 return rewrite->getKind() == Kind::UnresolvedMaterialization;
   }
 
-  void rollback() override;
-
   UnrealizedConversionCastOp getOperation() const {
 return cast(op);
   }
 
+  void rollback() override;
+
+  void cleanup(RewriterBase &rewriter) override;
+
   /// Return the type converter of this materialization (which may be null).
   const TypeConverter *getConverter() const {
 return converterAndKind.getPointer();
@@ -764,7 +766,7 @@ namespace detail {
 struct ConversionPatternRewriterImpl : public RewriterBase::Listener {
   explicit ConversionPatternRewriterImpl(MLIRContext *ctx,
  const ConversionConfig &config)
-  : context(ctx), eraseRewriter(ctx), config(config) {}
+  : context(ctx), config(config) {}
 
   
//======//
   // State Management
@@ -832,7 +834,6 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
   
//======//
   // Materializations
   
//======//
-
   /// Build an unresolved materialization operation given an output type and 
set
   /// of input operands.
   Value buildUnresolvedMaterialization(MaterializationKind kind,
@@ -881,7 +882,7 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
 
 /// Erase the given op (unless it was already erased).
 void eraseOp(Operation *op) override {
-  if (wasErased(op))
+  if (erased.contains(op))
 return;
   op->dropAllUses();
   RewriterBase::eraseOp(op);
@@ -889,24 +890,17 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {
 
 /// Erase the given block (unless it was already erased).
 void eraseBlock(Block *block) override {
-  if (wasErased(block))
+  if (erased.contains(block))
 return;
   assert(block->empty() && "expected empty block");
   block->dropAllDefinedValueUses();
   RewriterBase::eraseBlock(block);
 }
 
-bool wasErased(void *ptr) const { return erased.contains(ptr); }
-
-bool wasErased(OperationRewrite *rewrite) const {
-  return wasErased(rewrite->getOperation());
-}
-
 void notifyOperationErased(Operation *op) override { erased.insert(op); }
 
 void notifyBlockErased(Block *block) override { erased.insert(block); }
 
-  private:
 /// Pointers to all erased operations and blocks.
 DenseSet erased;
   };
@@ -918,11 +912,6 @@ struct ConversionPatternRewriterImpl : public 
RewriterBase::Listener {

[llvm-branch-commits] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread via llvm-branch-commits

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

Backport ec56790c3b27df4fa1513594ca9a74fd8ad5bf7f

Requested by: @ldionne

>From 914676e671ecff9bab6dfb65af7eadc87efe6542 Mon Sep 17 00:00:00 2001
From: Ties Stuij 
Date: Tue, 23 Jul 2024 14:09:34 +0100
Subject: [PATCH] [libcxx] don't `#include ` if wide chars aren't
 enabled (#99911)

Pull request #96032 unconditionall adds the `cwchar` include in the
`format` umbrella header. However support for wchar_t can be disabled in
the build system (LIBCXX_ENABLE_WIDE_CHARACTERS).

This patch guards against inclusion of `cwchar` in `format` by checking
the `_LIBCPP_HAS_NO_WIDE_CHARACTERS` define.

For clarity I've also merged the include header section that `cwchar`
was in with the one above as they were both guarded by the same `#if`
logic.

(cherry picked from commit ec56790c3b27df4fa1513594ca9a74fd8ad5bf7f)
---
 libcxx/include/format | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/format b/libcxx/include/format
index c3f2b45f0f7305..a88b3ef8528e2d 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -237,21 +237,21 @@ namespace std {
 #  include 
 #  include 
 #  include 
-#  include 
 #  include 
 #  include 
+#  include 
 #  include 
 #  include 
+#  include 
+#  include 
 #  include 
 #  include 
 #  include 
 #  include 
-#endif
 
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
-#  include 
-#  include 
-#  include 
+#  if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#include 
+#  endif
 #endif
 
 #endif // _LIBCPP_FORMAT

___
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] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106788
___
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] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/106788
___
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] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: None (llvmbot)


Changes

Backport ec56790c3b27df4fa1513594ca9a74fd8ad5bf7f

Requested by: @ldionne

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


1 Files Affected:

- (modified) libcxx/include/format (+6-6) 


``diff
diff --git a/libcxx/include/format b/libcxx/include/format
index c3f2b45f0f7305..a88b3ef8528e2d 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -237,21 +237,21 @@ namespace std {
 #  include 
 #  include 
 #  include 
-#  include 
 #  include 
 #  include 
+#  include 
 #  include 
 #  include 
+#  include 
+#  include 
 #  include 
 #  include 
 #  include 
 #  include 
-#endif
 
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
-#  include 
-#  include 
-#  include 
+#  if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#include 
+#  endif
 #endif
 
 #endif // _LIBCPP_FORMAT

``




https://github.com/llvm/llvm-project/pull/106788
___
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] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread Louis Dionne via llvm-branch-commits

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

We saw some breakage internally that is fixed by this patch and that's why I 
believe this regression fix is worth cherry-picking.

https://github.com/llvm/llvm-project/pull/106788
___
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] [libcxx] release/19.x: [libcxx] don't `#include ` if wide chars aren't enabled (#99911) (PR #106788)

2024-08-30 Thread Ties Stuij via llvm-branch-commits

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

Yup, makes sense to cherry-pick.

https://github.com/llvm/llvm-project/pull/106788
___
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] 1eea362 - Revert "[AArch64][AsmParser] Directives should clear transitively implied fea…"

2024-08-30 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-08-30T14:31:59-07:00
New Revision: 1eea36277229abd8954d1ca94ece60f378fff35f

URL: 
https://github.com/llvm/llvm-project/commit/1eea36277229abd8954d1ca94ece60f378fff35f
DIFF: 
https://github.com/llvm/llvm-project/commit/1eea36277229abd8954d1ca94ece60f378fff35f.diff

LOG: Revert "[AArch64][AsmParser] Directives should clear transitively implied 
fea…"

This reverts commit 24977395592fb3a47d0356b6e9e6d25358a521c5.

Added: 


Modified: 
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s
llvm/test/MC/AArch64/SVE/directive-cpu-negative.s
llvm/test/MC/AArch64/directive-arch-negative.s
llvm/test/MC/AArch64/directive-arch_extension-negative.s

Removed: 
llvm/test/MC/AArch64/SVE/directive-arch-negative.s



diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 34c0fad45fc499..37add682b150e7 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6947,14 +6947,10 @@ static void ExpandCryptoAEK(const AArch64::ArchInfo 
&ArchInfo,
   }
 }
 
-static SMLoc incrementLoc(SMLoc L, int Offset) {
-  return SMLoc::getFromPointer(L.getPointer() + Offset);
-}
-
 /// parseDirectiveArch
 ///   ::= .arch token
 bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
-  SMLoc CurLoc = getLoc();
+  SMLoc ArchLoc = getLoc();
 
   StringRef Arch, ExtensionString;
   std::tie(Arch, ExtensionString) =
@@ -6962,7 +6958,7 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
 
   const AArch64::ArchInfo *ArchInfo = AArch64::parseArch(Arch);
   if (!ArchInfo)
-return Error(CurLoc, "unknown arch name");
+return Error(ArchLoc, "unknown arch name");
 
   if (parseToken(AsmToken::EndOfStatement))
 return true;
@@ -6982,30 +6978,27 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
 ExtensionString.split(RequestedExtensions, '+');
 
   ExpandCryptoAEK(*ArchInfo, RequestedExtensions);
-  CurLoc = incrementLoc(CurLoc, Arch.size());
 
+  FeatureBitset Features = STI.getFeatureBits();
+  setAvailableFeatures(ComputeAvailableFeatures(Features));
   for (auto Name : RequestedExtensions) {
-// Advance source location past '+'.
-CurLoc = incrementLoc(CurLoc, 1);
-
 bool EnableFeature = !Name.consume_front_insensitive("no");
 
-auto It = llvm::find_if(ExtensionMap, [&Name](const auto &Extension) {
-  return Extension.Name == Name;
-});
-
-if (It == std::end(ExtensionMap))
-  Error(CurLoc, "unsupported architectural extension: " + Name);
+for (const auto &Extension : ExtensionMap) {
+  if (Extension.Name != Name)
+continue;
 
-if (EnableFeature)
-  STI.SetFeatureBitsTransitively(It->Features);
-else
-  STI.ClearFeatureBitsTransitively(It->Features);
+  if (Extension.Features.none())
+report_fatal_error("unsupported architectural extension: " + Name);
 
-CurLoc = incrementLoc(CurLoc, Name.size());
+  FeatureBitset ToggleFeatures =
+  EnableFeature
+  ? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
+  : STI.ToggleFeature(Features & Extension.Features);
+  setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
+  break;
+}
   }
-  FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
-  setAvailableFeatures(Features);
   return false;
 }
 
@@ -7025,21 +7018,28 @@ bool 
AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) {
 Name = Name.substr(2);
   }
 
-  auto It = llvm::find_if(ExtensionMap, [&Name](const auto &Extension) {
-return Extension.Name == Name;
-  });
+  MCSubtargetInfo &STI = copySTI();
+  FeatureBitset Features = STI.getFeatureBits();
+  for (const auto &Extension : ExtensionMap) {
+if (Extension.Name != Name)
+  continue;
+
+if (Extension.Features.none())
+  return Error(ExtLoc, "unsupported architectural extension: " + Name);
+
+FeatureBitset ToggleFeatures =
+EnableFeature
+? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
+: STI.ToggleFeature(Features & Extension.Features);
+setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
+return false;
+  }
 
-  if (It == std::end(ExtensionMap))
-return Error(ExtLoc, "unsupported architectural extension: " + Name);
+  return Error(ExtLoc, "unknown architectural extension: " + Name);
+}
 
-  MCSubtargetInfo &STI = copySTI();
-  if (EnableFeature)
-STI.SetFeatureBitsTransitively(It->Features);
-  else
-STI.ClearFeatureBitsTransitively(It->Features);
-  FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
-  setAvailableFeatures(Features);
-  return false;
+static SMLoc incrementLoc(SMLoc L, int Offset) {
+  return SMLoc::getFromPoint

[llvm-branch-commits] [llvm] release/19.x: [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99064) (PR #106823)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/106823
___
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/19.x: [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99064) (PR #106823)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106823
___
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/19.x: [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99064) (PR #106823)

2024-08-30 Thread via llvm-branch-commits

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

Backport 46a4132e167aa44d8ec7776262ce2a0e6d47de59

Requested by: @tchaikov

>From c1dec103dfc9fd51fa937141133ed7558c3b3f0a Mon Sep 17 00:00:00 2001
From: Avi Kivity 
Date: Mon, 26 Aug 2024 17:56:45 +0300
Subject: [PATCH] [Instrumentation] Fix EdgeCounts vector size in
 SetBranchWeights (#99064)

(cherry picked from commit 46a4132e167aa44d8ec7776262ce2a0e6d47de59)
---
 .../Instrumentation/PGOInstrumentation.cpp| 14 +--
 .../Coroutines/coro-pgo-setbranchweights.ll   | 42 +++
 2 files changed, 52 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll

diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp 
b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 1ce8f58c1aa140..4924d5a317478f 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1625,11 +1625,17 @@ void PGOUseFunc::setBranchWeights() {
   continue;
 
 // We have a non-zero Branch BB.
-unsigned Size = BBCountInfo.OutEdges.size();
-SmallVector EdgeCounts(Size, 0);
+
+// SuccessorCount can be greater than OutEdgesCount, because
+// removed edges don't appear in OutEdges.
+unsigned OutEdgesCount = BBCountInfo.OutEdges.size();
+unsigned SuccessorCount = BB.getTerminator()->getNumSuccessors();
+assert(OutEdgesCount <= SuccessorCount);
+
+SmallVector EdgeCounts(SuccessorCount, 0);
 uint64_t MaxCount = 0;
-for (unsigned s = 0; s < Size; s++) {
-  const PGOUseEdge *E = BBCountInfo.OutEdges[s];
+for (unsigned It = 0; It < OutEdgesCount; It++) {
+  const PGOUseEdge *E = BBCountInfo.OutEdges[It];
   const BasicBlock *SrcBB = E->SrcBB;
   const BasicBlock *DestBB = E->DestBB;
   if (DestBB == nullptr)
diff --git a/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll 
b/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll
new file mode 100644
index 00..4f5f936606ca3f
--- /dev/null
+++ b/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll
@@ -0,0 +1,42 @@
+; RUN: rm -rf %t && split-file %s %t
+
+; RUN: llvm-profdata merge %t/a.proftext -o %t/a.profdata
+; RUN: opt < %t/a.ll --passes=pgo-instr-use 
-pgo-test-profile-file=%t/a.profdata
+
+;--- a.ll
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-redhat-linux-gnu"
+
+define void @_bar() presplitcoroutine personality ptr null {
+  %1 = call token @llvm.coro.save(ptr null)
+  %2 = call i8 @llvm.coro.suspend(token none, i1 false)
+  switch i8 %2, label %5 [
+i8 0, label %3
+i8 1, label %4
+  ]
+
+3:; preds = %0
+  ret void
+
+4:; preds = %0
+  ret void
+
+5:; preds = %0
+  ret void
+}
+
+declare token @llvm.coro.save(ptr)
+
+declare i8 @llvm.coro.suspend(token, i1)
+
+;--- a.proftext
+# IR level Instrumentation Flag
+:ir
+
+_bar
+# Func Hash:
+1063705160175073211
+# Num Counters:
+2
+1
+0

___
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] release/19.x: [clang-format] Correctly annotate braces in ObjC square brackets (#106654) (PR #106819)

2024-08-30 Thread via llvm-branch-commits

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

Backport e0f2368cdeb7312973a92fb2d22199d1de540db8

Requested by: @owenca

>From 258712c564c3cb4d240e62253ca162ef5e452e7c Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 30 Aug 2024 19:23:45 -0700
Subject: [PATCH] [clang-format] Correctly annotate braces in ObjC square
 brackets (#106654)

See
https://github.com/llvm/llvm-project/pull/88238#issuecomment-2316954781.

(cherry picked from commit e0f2368cdeb7312973a92fb2d22199d1de540db8)
---
 clang/lib/Format/UnwrappedLineParser.cpp  | 1 +
 clang/unittests/Format/TokenAnnotatorTest.cpp | 9 +
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 688c7c5b1e977f..37ce3319997554 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2668,6 +2668,7 @@ void UnwrappedLineParser::parseSquare(bool 
LambdaIntroducer) {
   break;
 }
 case tok::at:
+case tok::colon:
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
 nextToken();
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index c20b50d14b80b1..1176db79ae288a 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3219,6 +3219,15 @@ TEST_F(TokenAnnotatorTest, BlockLBrace) {
   EXPECT_BRACE_KIND(Tokens[4], BK_Block);
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_BlockLBrace);
   EXPECT_BRACE_KIND(Tokens[5], BK_Block);
+
+  Tokens = annotate("[foo bar:{{0, 1}} baz:baz];",
+getLLVMStyle(FormatStyle::LK_ObjC));
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown); // Not TT_BlockLBrace.
+  EXPECT_BRACE_KIND(Tokens[4], BK_Unknown);  // Not BK_Block.
+  EXPECT_BRACE_KIND(Tokens[5], BK_BracedInit);
+  EXPECT_BRACE_KIND(Tokens[9], BK_Unknown);  // Not BK_Block.
+  EXPECT_BRACE_KIND(Tokens[10], BK_Unknown); // Not BK_Block.
 }
 
 TEST_F(TokenAnnotatorTest, SwitchExpression) {

___
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] [flang] dcb1265 - Revert "[MLIR][LLVM] Make DISubprogramAttr cyclic (#106571)"

2024-08-30 Thread via llvm-branch-commits

Author: Tobias Gysi
Date: 2024-08-31T07:44:01+02:00
New Revision: dcb1265cdefd5e712a395cbcac632f8898ba4e2d

URL: 
https://github.com/llvm/llvm-project/commit/dcb1265cdefd5e712a395cbcac632f8898ba4e2d
DIFF: 
https://github.com/llvm/llvm-project/commit/dcb1265cdefd5e712a395cbcac632f8898ba4e2d.diff

LOG: Revert "[MLIR][LLVM] Make DISubprogramAttr cyclic (#106571)"

This reverts commit d884b77c662374bd779ccbf20ba3b31cb9949a18.

Added: 


Modified: 
flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
mlir/include/mlir-c/Dialect/LLVM.h
mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td
mlir/lib/CAPI/Dialect/LLVM.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
mlir/lib/Target/LLVMIR/DebugImporter.cpp
mlir/lib/Target/LLVMIR/DebugTranslation.cpp
mlir/lib/Target/LLVMIR/DebugTranslation.h
mlir/test/CAPI/llvm.c
mlir/test/Target/LLVMIR/Import/debug-info.ll
mlir/test/Target/LLVMIR/llvmir-debug.mlir

Removed: 




diff  --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp 
b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index 029d3776bcc0b8..54f2a12d800085 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -146,8 +146,8 @@ mlir::LLVM::DITypeAttr 
DebugTypeGenerator::convertBoxedSequenceType(
 elements.push_back(subrangeTy);
   }
   return mlir::LLVM::DICompositeTypeAttr::get(
-  context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
-  /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
+  context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
+  /*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, 
elemTy,
   mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
   dataLocation, /*rank=*/nullptr, allocated, associated);
 }
@@ -188,7 +188,7 @@ mlir::LLVM::DITypeAttr 
DebugTypeGenerator::convertRecordType(
   }
 
   return mlir::LLVM::DICompositeTypeAttr::get(
-  context, llvm::dwarf::DW_TAG_structure_type,
+  context, llvm::dwarf::DW_TAG_structure_type, /*recursive_id=*/{},
   mlir::StringAttr::get(context, result.second.name), fileAttr, line, 
scope,
   /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
   /*alignInBits=*/0, elements, /*dataLocation=*/nullptr, /*rank=*/nullptr,
@@ -236,8 +236,8 @@ mlir::LLVM::DITypeAttr 
DebugTypeGenerator::convertSequenceType(
   // have been set to some valid default values.
 
   return mlir::LLVM::DICompositeTypeAttr::get(
-  context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
-  /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
+  context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
+  /*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, 
elemTy,
   mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
   /*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
   /*associated=*/nullptr);

diff  --git a/mlir/include/mlir-c/Dialect/LLVM.h 
b/mlir/include/mlir-c/Dialect/LLVM.h
index 38bd4d2f3587be..5eb96a86e472d6 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -234,13 +234,10 @@ MLIR_CAPI_EXPORTED MlirAttribute 
mlirLLVMDIBasicTypeAttrGet(
 MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
 MlirLLVMTypeEncoding encoding);
 
-/// Creates a self-referencing LLVM DICompositeType attribute.
-MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId);
-
 /// Creates a LLVM DICompositeType attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
-MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
-MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
+MlirContext ctx, unsigned int tag, MlirAttribute recId, MlirAttribute name,
+MlirAttribute file, uint32_t line, MlirAttribute scope,
 MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
 uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
 MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
@@ -314,16 +311,13 @@ MLIR_CAPI_EXPORTED MlirAttribute 
mlirLLVMDILocalVariableAttrGet(
 MlirAttribute diFile, unsigned int line, unsigned int arg,
 unsigned int alignInBits, MlirAttribute diType, int64_t flags);
 
-/// Creates a self-referencing LLVM DISubprogramAttr attribute.
-MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId);
-
 /// Creates a LLVM DISubprogramAttr attribute.
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDISubprogramAttrGet(
-MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
- 

[llvm-branch-commits] [clang] [clang-format] Revert "[clang-format][NFC] Delete TT_LambdaArrow (#70… (PR #106482)

2024-08-30 Thread Owen Pan via llvm-branch-commits

owenca wrote:

@HazardyKnusperkeks @mydeveloperday @rymiel please see 
https://github.com/llvm/llvm-project/pull/105923#issuecomment-2316563384.

https://github.com/llvm/llvm-project/pull/106482
___
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] 05a3894 - Revert "Revert "[AArch64][AsmParser] Directives should clear transitively imp…"

2024-08-30 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-08-30T17:37:52-07:00
New Revision: 05a38948ba9f498d46045e4239e0a61e0ae512f7

URL: 
https://github.com/llvm/llvm-project/commit/05a38948ba9f498d46045e4239e0a61e0ae512f7
DIFF: 
https://github.com/llvm/llvm-project/commit/05a38948ba9f498d46045e4239e0a61e0ae512f7.diff

LOG: Revert "Revert "[AArch64][AsmParser] Directives should clear transitively 
imp…"

This reverts commit d8bffa9018c88ef6ce441bb44d7b7d7a9091e583.

Added: 
llvm/test/MC/AArch64/SVE/directive-arch-negative.s

Modified: 
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s
llvm/test/MC/AArch64/SVE/directive-cpu-negative.s
llvm/test/MC/AArch64/directive-arch-negative.s
llvm/test/MC/AArch64/directive-arch_extension-negative.s

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp 
b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 37add682b150e7..373f844b239081 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6947,10 +6947,14 @@ static void ExpandCryptoAEK(const AArch64::ArchInfo 
&ArchInfo,
   }
 }
 
+static SMLoc incrementLoc(SMLoc L, int Offset) {
+  return SMLoc::getFromPointer(L.getPointer() + Offset);
+}
+
 /// parseDirectiveArch
 ///   ::= .arch token
 bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
-  SMLoc ArchLoc = getLoc();
+  SMLoc CurLoc = getLoc();
 
   StringRef Arch, ExtensionString;
   std::tie(Arch, ExtensionString) =
@@ -6958,7 +6962,7 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
 
   const AArch64::ArchInfo *ArchInfo = AArch64::parseArch(Arch);
   if (!ArchInfo)
-return Error(ArchLoc, "unknown arch name");
+return Error(CurLoc, "unknown arch name");
 
   if (parseToken(AsmToken::EndOfStatement))
 return true;
@@ -6978,27 +6982,30 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
 ExtensionString.split(RequestedExtensions, '+');
 
   ExpandCryptoAEK(*ArchInfo, RequestedExtensions);
+  CurLoc = incrementLoc(CurLoc, Arch.size());
 
-  FeatureBitset Features = STI.getFeatureBits();
-  setAvailableFeatures(ComputeAvailableFeatures(Features));
   for (auto Name : RequestedExtensions) {
+// Advance source location past '+'.
+CurLoc = incrementLoc(CurLoc, 1);
+
 bool EnableFeature = !Name.consume_front_insensitive("no");
 
-for (const auto &Extension : ExtensionMap) {
-  if (Extension.Name != Name)
-continue;
+auto It = llvm::find_if(ExtensionMap, [&Name](const auto &Extension) {
+  return Extension.Name == Name;
+});
 
-  if (Extension.Features.none())
-report_fatal_error("unsupported architectural extension: " + Name);
+if (It == std::end(ExtensionMap))
+  return Error(CurLoc, "unsupported architectural extension: " + Name);
 
-  FeatureBitset ToggleFeatures =
-  EnableFeature
-  ? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
-  : STI.ToggleFeature(Features & Extension.Features);
-  setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
-  break;
-}
+if (EnableFeature)
+  STI.SetFeatureBitsTransitively(It->Features);
+else
+  STI.ClearFeatureBitsTransitively(It->Features);
+
+CurLoc = incrementLoc(CurLoc, Name.size());
   }
+  FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
+  setAvailableFeatures(Features);
   return false;
 }
 
@@ -7018,28 +7025,21 @@ bool 
AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) {
 Name = Name.substr(2);
   }
 
-  MCSubtargetInfo &STI = copySTI();
-  FeatureBitset Features = STI.getFeatureBits();
-  for (const auto &Extension : ExtensionMap) {
-if (Extension.Name != Name)
-  continue;
-
-if (Extension.Features.none())
-  return Error(ExtLoc, "unsupported architectural extension: " + Name);
-
-FeatureBitset ToggleFeatures =
-EnableFeature
-? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
-: STI.ToggleFeature(Features & Extension.Features);
-setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
-return false;
-  }
+  auto It = llvm::find_if(ExtensionMap, [&Name](const auto &Extension) {
+return Extension.Name == Name;
+  });
 
-  return Error(ExtLoc, "unknown architectural extension: " + Name);
-}
+  if (It == std::end(ExtensionMap))
+return Error(ExtLoc, "unsupported architectural extension: " + Name);
 
-static SMLoc incrementLoc(SMLoc L, int Offset) {
-  return SMLoc::getFromPointer(L.getPointer() + Offset);
+  MCSubtargetInfo &STI = copySTI();
+  if (EnableFeature)
+STI.SetFeatureBitsTransitively(It->Features);
+  else
+STI.ClearFeatureBitsTransitively(It->Features);
+  FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
+  setAvailableF

[llvm-branch-commits] [llvm] release/19.x: workflows/release-binaries: Remove .git/config file from artifacts (#106310) (PR #106821)

2024-08-30 Thread via llvm-branch-commits

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


[clang] [clang-format] Revert "[clang-format][NFC] Delete TT_LambdaArrow (#70… (PR #106482)

2024-08-30 Thread Björn Schäpers via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/106482
___
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/19.x: workflows/release-binaries: Remove .git/config file from artifacts (#106310) (PR #106821)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-github-workflow

Author: None (llvmbot)


Changes

Backport ef50970204384643acca42ba4c7ca8f14865a0c2

Requested by: @tstellar

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


1 Files Affected:

- (modified) .github/workflows/release-binaries-save-stage/action.yml (+6) 


``diff
diff --git a/.github/workflows/release-binaries-save-stage/action.yml 
b/.github/workflows/release-binaries-save-stage/action.yml
index e2f3eeadd15bea..f08088c7bc56f1 100644
--- a/.github/workflows/release-binaries-save-stage/action.yml
+++ b/.github/workflows/release-binaries-save-stage/action.yml
@@ -10,6 +10,9 @@ inputs:
 required: true
 type: 'string'
 
+permissions:
+  contents: read
+
 runs:
   using: "composite"
   steps:
@@ -18,6 +21,9 @@ runs:
 - name: Package Build and Source Directories
   shell: bash
   run: |
+# Remove .git/config to avoid leaking GITHUB_TOKEN stored there.
+# See 
https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/
+rm -Rf .git/config
 # Windows does not support symlinks, so we need to dereference them.
 tar --exclude build/ ${{ (runner.os == 'Windows' && '-h') || '' }} -c 
. | zstd -T0 -c > ../llvm-project.tar.zst
 mv ../llvm-project.tar.zst .

``




https://github.com/llvm/llvm-project/pull/106821
___
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] release/19.x: [clang-format] Correctly annotate braces in ObjC square brackets (#106654) (PR #106819)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (llvmbot)


Changes

Backport e0f2368cdeb7312973a92fb2d22199d1de540db8

Requested by: @owenca

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


2 Files Affected:

- (modified) clang/lib/Format/UnwrappedLineParser.cpp (+1) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+9) 


``diff
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 688c7c5b1e977f..37ce3319997554 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2668,6 +2668,7 @@ void UnwrappedLineParser::parseSquare(bool 
LambdaIntroducer) {
   break;
 }
 case tok::at:
+case tok::colon:
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
 nextToken();
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index c20b50d14b80b1..1176db79ae288a 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3219,6 +3219,15 @@ TEST_F(TokenAnnotatorTest, BlockLBrace) {
   EXPECT_BRACE_KIND(Tokens[4], BK_Block);
   EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_BlockLBrace);
   EXPECT_BRACE_KIND(Tokens[5], BK_Block);
+
+  Tokens = annotate("[foo bar:{{0, 1}} baz:baz];",
+getLLVMStyle(FormatStyle::LK_ObjC));
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown); // Not TT_BlockLBrace.
+  EXPECT_BRACE_KIND(Tokens[4], BK_Unknown);  // Not BK_Block.
+  EXPECT_BRACE_KIND(Tokens[5], BK_BracedInit);
+  EXPECT_BRACE_KIND(Tokens[9], BK_Unknown);  // Not BK_Block.
+  EXPECT_BRACE_KIND(Tokens[10], BK_Unknown); // Not BK_Block.
 }
 
 TEST_F(TokenAnnotatorTest, SwitchExpression) {

``




https://github.com/llvm/llvm-project/pull/106819
___
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] release/19.x: [clang-format] Correctly annotate braces in ObjC square brackets (#106654) (PR #106819)

2024-08-30 Thread Owen Pan via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/106819
___
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] release/19.x: [clang-format] Correctly annotate braces in ObjC square brackets (#106654) (PR #106819)

2024-08-30 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106819
___
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/19.x: [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99064) (PR #106823)

2024-08-30 Thread Mircea Trofin via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/106823
___
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/19.x: [Instrumentation] Fix EdgeCounts vector size in SetBranchWeights (#99064) (PR #106823)

2024-08-30 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport 46a4132e167aa44d8ec7776262ce2a0e6d47de59

Requested by: @tchaikov

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


2 Files Affected:

- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+10-4) 
- (added) llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll (+42) 


``diff
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp 
b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 1ce8f58c1aa140..4924d5a317478f 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1625,11 +1625,17 @@ void PGOUseFunc::setBranchWeights() {
   continue;
 
 // We have a non-zero Branch BB.
-unsigned Size = BBCountInfo.OutEdges.size();
-SmallVector EdgeCounts(Size, 0);
+
+// SuccessorCount can be greater than OutEdgesCount, because
+// removed edges don't appear in OutEdges.
+unsigned OutEdgesCount = BBCountInfo.OutEdges.size();
+unsigned SuccessorCount = BB.getTerminator()->getNumSuccessors();
+assert(OutEdgesCount <= SuccessorCount);
+
+SmallVector EdgeCounts(SuccessorCount, 0);
 uint64_t MaxCount = 0;
-for (unsigned s = 0; s < Size; s++) {
-  const PGOUseEdge *E = BBCountInfo.OutEdges[s];
+for (unsigned It = 0; It < OutEdgesCount; It++) {
+  const PGOUseEdge *E = BBCountInfo.OutEdges[It];
   const BasicBlock *SrcBB = E->SrcBB;
   const BasicBlock *DestBB = E->DestBB;
   if (DestBB == nullptr)
diff --git a/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll 
b/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll
new file mode 100644
index 00..4f5f936606ca3f
--- /dev/null
+++ b/llvm/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll
@@ -0,0 +1,42 @@
+; RUN: rm -rf %t && split-file %s %t
+
+; RUN: llvm-profdata merge %t/a.proftext -o %t/a.profdata
+; RUN: opt < %t/a.ll --passes=pgo-instr-use 
-pgo-test-profile-file=%t/a.profdata
+
+;--- a.ll
+target datalayout = 
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-redhat-linux-gnu"
+
+define void @_bar() presplitcoroutine personality ptr null {
+  %1 = call token @llvm.coro.save(ptr null)
+  %2 = call i8 @llvm.coro.suspend(token none, i1 false)
+  switch i8 %2, label %5 [
+i8 0, label %3
+i8 1, label %4
+  ]
+
+3:; preds = %0
+  ret void
+
+4:; preds = %0
+  ret void
+
+5:; preds = %0
+  ret void
+}
+
+declare token @llvm.coro.save(ptr)
+
+declare i8 @llvm.coro.suspend(token, i1)
+
+;--- a.proftext
+# IR level Instrumentation Flag
+:ir
+
+_bar
+# Func Hash:
+1063705160175073211
+# Num Counters:
+2
+1
+0

``




https://github.com/llvm/llvm-project/pull/106823
___
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/19.x: workflows/release-binaries: Remove .git/config file from artifacts (#106310) (PR #106821)

2024-08-30 Thread via llvm-branch-commits

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

Backport ef50970204384643acca42ba4c7ca8f14865a0c2

Requested by: @tstellar

>From b2f366f82553049b460848a1f2e38c5cff0e0661 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 30 Aug 2024 19:46:33 -0700
Subject: [PATCH] workflows/release-binaries: Remove .git/config file from
 artifacts (#106310)

The .git/config file contains an auth token that can be leaked if the
.git directory is included in a workflow artifact.

(cherry picked from commit ef50970204384643acca42ba4c7ca8f14865a0c2)
---
 .github/workflows/release-binaries-save-stage/action.yml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/.github/workflows/release-binaries-save-stage/action.yml 
b/.github/workflows/release-binaries-save-stage/action.yml
index e2f3eeadd15bea..f08088c7bc56f1 100644
--- a/.github/workflows/release-binaries-save-stage/action.yml
+++ b/.github/workflows/release-binaries-save-stage/action.yml
@@ -10,6 +10,9 @@ inputs:
 required: true
 type: 'string'
 
+permissions:
+  contents: read
+
 runs:
   using: "composite"
   steps:
@@ -18,6 +21,9 @@ runs:
 - name: Package Build and Source Directories
   shell: bash
   run: |
+# Remove .git/config to avoid leaking GITHUB_TOKEN stored there.
+# See 
https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/
+rm -Rf .git/config
 # Windows does not support symlinks, so we need to dereference them.
 tar --exclude build/ ${{ (runner.os == 'Windows' && '-h') || '' }} -c 
. | zstd -T0 -c > ../llvm-project.tar.zst
 mv ../llvm-project.tar.zst .

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