[llvm] [IR] Allow type change in ValueAsMetadata::handleRAUW (PR #76969)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 08:12:57 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Jannik Silvanus (jasilvanus)
<details>
<summary>Changes</summary>
`ValueAsMetadata::handleRAUW` is a mechanism to replace all metadata referring to one value by a different value.
Relax an assert that used to enforce the old and new value to have the same type.
This seems to be a sanity plausibility assert only, as the implementation actually supports mismatching types.
This is motivated by a downstream mechanism where we use poison ValueAsMetadata values to annotate pointee types of opaque pointer function arguments.
When replacing one type with a different one to work around DXIL vs LLVM incompatibilities, we need to update type annotations, and handleRAUW is more efficient than creating new MD nodes.
---
Full diff: https://github.com/llvm/llvm-project/pull/76969.diff
1 Files Affected:
- (modified) llvm/lib/IR/Metadata.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 515893d079b8cb..bdfbd8829186d9 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -503,7 +503,7 @@ void ValueAsMetadata::handleRAUW(Value *From, Value *To) {
assert(From && "Expected valid value");
assert(To && "Expected valid value");
assert(From != To && "Expected changed value");
- assert(From->getType() == To->getType() && "Unexpected type change");
+ assert(&From->getContext() == &To->getContext() && "Expected same context");
LLVMContext &Context = From->getType()->getContext();
auto &Store = Context.pImpl->ValuesAsMetadata;
``````````
</details>
https://github.com/llvm/llvm-project/pull/76969
More information about the llvm-commits
mailing list