[Mlir-commits] [llvm] [mlir] [IR][NFC] Inline Value::getContext() (PR #176662)
Alexis Engelke
llvmlistbot at llvm.org
Sun Jan 18 22:23:50 PST 2026
https://github.com/aengelke updated https://github.com/llvm/llvm-project/pull/176662
>From 65f91bbcba46afcec31554b1719b7b8c6bc2411c Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Sun, 18 Jan 2026 17:12:31 +0000
Subject: [PATCH 1/3] inline Value::getContext
---
llvm/include/llvm/IR/Value.h | 4 ++--
llvm/lib/IR/Value.cpp | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index 58822a0645747..f3199905066ab 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/CBindingWrapping.h"
@@ -50,7 +51,6 @@ class ModuleSlotTracker;
class raw_ostream;
template<typename ValueTy> class StringMapEntry;
class Twine;
-class Type;
class User;
using ValueName = StringMapEntry<Value *>;
@@ -256,7 +256,7 @@ class Value {
Type *getType() const { return VTy; }
/// All values hold a context through their type.
- LLVM_ABI LLVMContext &getContext() const;
+ LLVM_ABI LLVMContext &getContext() const { return VTy->getContext(); }
// All values can potentially be named.
bool hasName() const { return HasName; }
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index a43d63077bf9f..81a6ddec4918c 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -1103,8 +1103,6 @@ const Value *Value::DoPHITranslation(const BasicBlock *CurBB,
return this;
}
-LLVMContext &Value::getContext() const { return VTy->getContext(); }
-
void Value::reverseUseList() {
if (!UseList || !UseList->Next)
// No need to reverse 0 or 1 uses.
>From d641a27f685909ae3af9ea0ff7e64d2495619d6b Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Sun, 18 Jan 2026 18:10:44 +0000
Subject: [PATCH 2/3] LLVM_ABI?
---
llvm/include/llvm/IR/Value.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index f3199905066ab..4a15251f0b945 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -256,7 +256,7 @@ class Value {
Type *getType() const { return VTy; }
/// All values hold a context through their type.
- LLVM_ABI LLVMContext &getContext() const { return VTy->getContext(); }
+ LLVMContext &getContext() const { return VTy->getContext(); }
// All values can potentially be named.
bool hasName() const { return HasName; }
>From 8dcec070ad29068ff26ecd541366dd1948caba1e Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Mon, 19 Jan 2026 06:23:36 +0000
Subject: [PATCH 3/3] fix MLIR
---
mlir/unittests/IR/RemarkTest.cpp | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/mlir/unittests/IR/RemarkTest.cpp b/mlir/unittests/IR/RemarkTest.cpp
index f33d3caebad37..dca86632071d4 100644
--- a/mlir/unittests/IR/RemarkTest.cpp
+++ b/mlir/unittests/IR/RemarkTest.cpp
@@ -23,7 +23,6 @@
#include "gtest/gtest.h"
#include <optional>
-using namespace llvm;
using namespace mlir;
using namespace testing;
namespace {
@@ -35,9 +34,9 @@ TEST(Remark, TestOutputOptimizationRemark) {
std::string categoryInliner("Inliner");
std::string categoryReroller("Reroller");
std::string myPassname1("myPass1");
- SmallString<64> tmpPathStorage;
- sys::fs::createUniquePath("remarks-%%%%%%.yaml", tmpPathStorage,
- /*MakeAbsolute=*/true);
+ llvm::SmallString<64> tmpPathStorage;
+ llvm::sys::fs::createUniquePath("remarks-%%%%%%.yaml", tmpPathStorage,
+ /*MakeAbsolute=*/true);
std::string yamlFile =
std::string(tmpPathStorage.data(), tmpPathStorage.size());
ASSERT_FALSE(yamlFile.empty());
@@ -96,7 +95,7 @@ TEST(Remark, TestOutputOptimizationRemark) {
}
// Read the file
- auto bufferOrErr = MemoryBuffer::getFile(yamlFile);
+ auto bufferOrErr = llvm::MemoryBuffer::getFile(yamlFile);
ASSERT_TRUE(static_cast<bool>(bufferOrErr)) << "Failed to open remarks file";
std::string content = bufferOrErr.get()->getBuffer().str();
@@ -154,8 +153,8 @@ TEST(Remark, TestNoOutputOptimizationRemark) {
std::string categoryFailName("myImportantCategory");
std::string myPassname1("myPass1");
SmallString<64> tmpPathStorage;
- sys::fs::createUniquePath("remarks-%%%%%%.yaml", tmpPathStorage,
- /*MakeAbsolute=*/true);
+ llvm::sys::fs::createUniquePath("remarks-%%%%%%.yaml", tmpPathStorage,
+ /*MakeAbsolute=*/true);
std::string yamlFile =
std::string(tmpPathStorage.data(), tmpPathStorage.size());
ASSERT_FALSE(yamlFile.empty());
@@ -383,7 +382,7 @@ TEST(Remark, TestRemarkFinal) {
TEST(Remark, TestArgWithAttribute) {
MLIRContext context;
- SmallVector<Attribute> elements;
+ llvm::SmallVector<Attribute> elements;
elements.push_back(IntegerAttr::get(IntegerType::get(&context, 32), 1));
elements.push_back(IntegerAttr::get(IntegerType::get(&context, 32), 2));
elements.push_back(IntegerAttr::get(IntegerType::get(&context, 32), 3));
More information about the Mlir-commits
mailing list