[llvm] [IR][NFC] Inline Value::getContext() (PR #176662)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 18 09:57:53 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
For non-LTO builds, this is a frequently called function consisting of just two instructions. Most files that include Value.h also include Type.h, so the added compile time cost is very low.
http://llvm-compile-time-tracker.com/compare.php?from=7b6751916cf74692df9c331ecdc731c42addafdf&to=65f91bbcba46afcec31554b1719b7b8c6bc2411c&stat=instructions:u
---
Full diff: https://github.com/llvm/llvm-project/pull/176662.diff
2 Files Affected:
- (modified) llvm/include/llvm/IR/Value.h (+2-2)
- (modified) llvm/lib/IR/Value.cpp (-2)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/176662
More information about the llvm-commits
mailing list