[llvm] [LLVM-Reduce] - Distinct Metadata Reduction (PR #104624)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 09:15:01 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c4bf949171a72383d5ba4d2b587d4cc496aacebb c158a38d724e635ff296c0c76aa860ec4733fb6e --extensions cpp,h -- llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h llvm/tools/llvm-reduce/DeltaManager.cpp llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp
index ebdc0fba06..6711fe94d8 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.cpp
@@ -1,4 +1,5 @@
-//===- ReduceDistinctMetadata.cpp - Specialized Delta Pass ------------------------===//
+//===- ReduceDistinctMetadata.cpp - Specialized Delta Pass
+//------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,8 +24,10 @@
using namespace llvm;
// Traverse the graph breadth-first and try to remove unnamed metadata nodes
-static void reduceNodes(MDNode *Root, SetVector<std::pair<unsigned int, MDNode *>> &NodesToDelete,
- MDNode *TemporaryNode, Oracle &O, Module &Program) {
+static void
+reduceNodes(MDNode *Root,
+ SetVector<std::pair<unsigned int, MDNode *>> &NodesToDelete,
+ MDNode *TemporaryNode, Oracle &O, Module &Program) {
std::queue<MDNode *> NodesToTraverse{};
// Keep track of visited nodes not to get into loops
SetVector<MDNode *> VisitedNodes{};
@@ -62,7 +65,8 @@ static void reduceNodes(MDNode *Root, SetVector<std::pair<unsigned int, MDNode *
// After reducing metadata, we need to remove references to the temporary node,
// this is also done with BFS
-static void cleanUpTemporaries(NamedMDNode &NamedNode, MDTuple *TemporaryTuple, Module &Program) {
+static void cleanUpTemporaries(NamedMDNode &NamedNode, MDTuple *TemporaryTuple,
+ Module &Program) {
std::queue<MDTuple *> NodesToTraverse{};
SetVector<MDTuple *> VisitedNodes{};
@@ -82,8 +86,9 @@ static void cleanUpTemporaries(NamedMDNode &NamedNode, MDTuple *TemporaryTuple,
MDTuple *CurrentTuple = NodesToTraverse.front();
NodesToTraverse.pop();
- // Shift all of the interesting elements to the left, pop remaining afterwards
- if (CurrentTuple ->isDistinct()) {
+ // Shift all of the interesting elements to the left, pop remaining
+ // afterwards
+ if (CurrentTuple->isDistinct()) {
// Do resizing and cleaning operations only if the node is distinct,
// as resizing is not supported for unique nodes and is redundant.
unsigned int NotToRemove = 0;
@@ -122,8 +127,8 @@ static void cleanUpTemporaries(NamedMDNode &NamedNode, MDTuple *TemporaryTuple,
static void extractDistinctMetadataFromModule(Oracle &O,
ReducerWorkItem &WorkItem) {
Module &Program = WorkItem.getModule();
- MDTuple *TemporaryTuple = MDTuple::getDistinct(
- Program.getContext(), SmallVector<Metadata *, 1>{});
+ MDTuple *TemporaryTuple =
+ MDTuple::getDistinct(Program.getContext(), SmallVector<Metadata *, 1>{});
SetVector<std::pair<unsigned int, MDNode *>> NodesToDelete{};
for (NamedMDNode &NamedNode :
Program.named_metadata()) { // Iterate over the named nodes
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h b/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h
index d02e8e6107..f60cb1a19a 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h
+++ b/llvm/tools/llvm-reduce/deltas/ReduceDistinctMetadata.h
@@ -1,4 +1,5 @@
-//===- ReduceDistinctMetadata.h - Specialized Delta Pass ------------------------===//
+//===- ReduceDistinctMetadata.h - Specialized Delta Pass
+//------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
index c0f9c0eac7..316c748760 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
@@ -54,7 +54,9 @@ static void reduceNamedMetadataOperands(Oracle &O, ReducerWorkItem &WorkItem) {
for (NamedMDNode &I : M.named_metadata()) {
// If we don't want to reduce mindlessly, check if our node is part of
// ListNamedMetadata before reducing it
- if (!AggressiveMetadataReduction && !is_contained(ListNamedMetadata, I.getName())) continue;
+ if (!AggressiveMetadataReduction &&
+ !is_contained(ListNamedMetadata, I.getName()))
+ continue;
bool MadeChange = false;
SmallVector<MDNode *> KeptOperands;
``````````
</details>
https://github.com/llvm/llvm-project/pull/104624
More information about the llvm-commits
mailing list