[llvm] [RFC] Memory Model Relaxation Annotations (PR #78569)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 01:02:57 PST 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 5fcf907b34355980f77d7665a175b05fea7a6b7b 914491192e11ea4f4622169d03de4a7496b028ca -- llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp llvm/unittests/IR/MemoryModelRelaxationAnnotationsTest.cpp llvm/include/llvm/Analysis/VectorUtils.h llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h llvm/include/llvm/CodeGen/MachineFunction.h llvm/include/llvm/CodeGen/MachineInstr.h llvm/include/llvm/CodeGen/MachineInstrBuilder.h llvm/include/llvm/CodeGen/SelectionDAG.h llvm/lib/Analysis/VectorUtils.cpp llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp llvm/lib/CodeGen/MIRPrinter.cpp llvm/lib/CodeGen/MachineFunction.cpp llvm/lib/CodeGen/MachineInstr.cpp llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/lib/IR/Instruction.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Transforms/Scalar/GVNHoist.cpp llvm/lib/Transforms/Utils/FunctionComparator.cpp llvm/lib/Transforms/Utils/Local.cpp llvm/unittests/CodeGen/MachineInstrTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h b/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h
index 96a5621b24..cbe87c9de9 100644
--- a/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h
+++ b/llvm/include/llvm/IR/MemoryModelRelaxationAnnotations.h
@@ -17,10 +17,10 @@
#ifndef LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
#define LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
-#include <vector>
+#include <set>
#include <string>
#include <tuple>
-#include <set>
+#include <vector>
namespace llvm {
diff --git a/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp b/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
index b7f76e2db6..9e069027cc 100644
--- a/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
+++ b/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
@@ -73,8 +73,8 @@ bool MMRAMetadata::isCompatibleWith(const MMRAMetadata &Other) const {
for (const auto &[P, S] : Other)
PrefixStatuses[P] |= (hasTag(P, S) || !hasTagWithPrefix(P));
- for(auto &[Prefix, Status]: PrefixStatuses) {
- if(!Status)
+ for (auto &[Prefix, Status] : PrefixStatuses) {
+ if (!Status)
return false;
}
diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp
index 17bbc43f6b..33b410bc96 100644
--- a/llvm/unittests/CodeGen/MachineInstrTest.cpp
+++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp
@@ -16,9 +16,9 @@
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
-#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h"
diff --git a/llvm/unittests/IR/MemoryModelRelaxationAnnotationsTest.cpp b/llvm/unittests/IR/MemoryModelRelaxationAnnotationsTest.cpp
index 62bda7306a..2b9f6df5cc 100644
--- a/llvm/unittests/IR/MemoryModelRelaxationAnnotationsTest.cpp
+++ b/llvm/unittests/IR/MemoryModelRelaxationAnnotationsTest.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
-#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"
using namespace llvm;
@@ -39,7 +39,8 @@ TEST(MMRATest, MDParse) {
// No nesting:
// !{!"foo", "!bar"}
- MDNode *FooBar = MDTuple::get(Ctx, { MDString::get(Ctx, "foo"), MDString::get(Ctx, "bar")});
+ MDNode *FooBar =
+ MDTuple::get(Ctx, {MDString::get(Ctx, "foo"), MDString::get(Ctx, "bar")});
MMRAMetadata FooBarMMRA(FooBar);
EXPECT_EQ(FooBarMMRA.size(), 1u);
@@ -47,12 +48,14 @@ TEST(MMRATest, MDParse) {
// Nested:
// !{!{!"foo", "!bar"}, !{!"bux", !"qux"}}
- MDNode *BuxQux = MDTuple::get(Ctx, { MDString::get(Ctx, "bux"), MDString::get(Ctx, "qux")});
+ MDNode *BuxQux =
+ MDTuple::get(Ctx, {MDString::get(Ctx, "bux"), MDString::get(Ctx, "qux")});
MDNode *Nested = MDTuple::get(Ctx, {FooBar, BuxQux});
MMRAMetadata NestedMMRA(Nested);
EXPECT_EQ(NestedMMRA.size(), 2u);
- EXPECT_EQ(NestedMMRA, MMRAMetadata().addTag("foo", "bar").addTag("bux", "qux"));
+ EXPECT_EQ(NestedMMRA,
+ MMRAMetadata().addTag("foo", "bar").addTag("bux", "qux"));
}
TEST(MMRATest, MDEmit) {
@@ -62,7 +65,7 @@ TEST(MMRATest, MDEmit) {
// !{!"foo", "!bar"}
{
MMRAMetadata FooBarMMRA = MMRAMetadata().addTag("foo", "bar");
- MDTuple* FooBar = FooBarMMRA.getAsMD(Ctx);
+ MDTuple *FooBar = FooBarMMRA.getAsMD(Ctx);
ASSERT_NE(FooBar, nullptr);
ASSERT_EQ(FooBar->getNumOperands(), 2u);
@@ -74,12 +77,12 @@ TEST(MMRATest, MDEmit) {
EXPECT_EQ(Bar->getString(), std::string("bar"));
}
-
// Nested MD
// !{!{!"foo", "!bar"}, !{!"bux", !"qux"}}
{
- MMRAMetadata NestedMMRA = MMRAMetadata().addTag("foo", "bar").addTag("bux", "qux");
- MDTuple* Nested = NestedMMRA.getAsMD(Ctx);
+ MMRAMetadata NestedMMRA =
+ MMRAMetadata().addTag("foo", "bar").addTag("bux", "qux");
+ MDTuple *Nested = NestedMMRA.getAsMD(Ctx);
ASSERT_NE(Nested, nullptr);
ASSERT_EQ(Nested->getNumOperands(), 2u);
@@ -143,7 +146,6 @@ TEST(MMRATest, Operators) {
B.addTag("foo", "0");
B.addTag("bar", "y");
-
// ensure we have different objects by creating copies.
EXPECT_EQ(MMRAMetadata(A), MMRAMetadata(A));
EXPECT_TRUE((bool)A);
@@ -216,7 +218,8 @@ TEST(MMRATest, Compatibility) {
Multiple2.addTag("foo", "x");
Multiple2.addTag("bux", "y");
- // Multiple0 and Multiple1 are not compatible because "bar" is getting in the way.
+ // Multiple0 and Multiple1 are not compatible because "bar" is getting in the
+ // way.
EXPECT_FALSE(Multiple0.isCompatibleWith(Multiple1));
EXPECT_FALSE(Multiple1.isCompatibleWith(Multiple0));
@@ -225,7 +228,8 @@ TEST(MMRATest, Compatibility) {
EXPECT_TRUE(Multiple1.isCompatibleWith(Empty));
EXPECT_TRUE(Empty.isCompatibleWith(Multiple1));
- // Multiple2 is compatible with both 1/0 because there is always "foo:x" in common, and the other prefixes are unique to each set.
+ // Multiple2 is compatible with both 1/0 because there is always "foo:x" in
+ // common, and the other prefixes are unique to each set.
EXPECT_TRUE(Multiple2.isCompatibleWith(Multiple0));
EXPECT_TRUE(Multiple0.isCompatibleWith(Multiple2));
EXPECT_TRUE(Multiple2.isCompatibleWith(Multiple1));
@@ -253,14 +257,12 @@ TEST(MMRATest, Combine) {
EXPECT_EQ(Combined, Foo0);
}
-
{
// nothing is common
MMRAMetadata Combined = Foo0.combine(Bar0);
EXPECT_TRUE(Combined.empty());
}
-
{
// only foo:0 is common
MMRAMetadata Combined = BarFoo0.combine(Foo0);
``````````
</details>
https://github.com/llvm/llvm-project/pull/78569
More information about the llvm-commits
mailing list