aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorRuiling, Song <ruiling.song@amd.com>2025-09-02 21:50:47 +0800
committerGitHub <noreply@github.com>2025-09-02 21:50:47 +0800
commit45dec71725bd57831051c27e43da698c23de1a52 (patch)
treea949956e79338aed79a0352d128edaf4ec6297f1 /llvm/lib/IR/Value.cpp
parent89f53af3fffed3e41167fbb7bc10d4885cd97c7f (diff)
downloadllvm-45dec71725bd57831051c27e43da698c23de1a52.zip
llvm-45dec71725bd57831051c27e43da698c23de1a52.tar.gz
llvm-45dec71725bd57831051c27e43da698c23de1a52.tar.bz2
[IR] Allow nofree metadata to inttoptr (#153149)
Our GPU compiler usually construct pointers through inttoptr. The memory was pre-allocated before the shader function execution and remains valid through the execution of the shader function. This brings back the expected behavior of instruction hoisting for the test `hoist-speculatable-load.ll`, which was broken by #126117.
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 5928c89..4e8f359 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -836,6 +836,9 @@ bool Value::canBeFreed() const {
return false;
}
+ if (isa<IntToPtrInst>(this) && getMetadata(LLVMContext::MD_nofree))
+ return false;
+
const Function *F = nullptr;
if (auto *I = dyn_cast<Instruction>(this))
F = I->getFunction();