[llvm] DXIL: Use correct type ID when writing ValueAsMetadata. (PR #94337)
Tim Besard via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 05:08:17 PDT 2024
maleadt wrote:
A similar case for loading pointer values:
```llvm
define void @kernel(ptr %0) {
%box = alloca ptr addrspace(1)
%x = load ptr addrspace(1), ptr %box, align 8
ret void
}
```
This currently throws a `Mismatch in load/store type: expected i8* but found i8 addrspace(1)*` when reading the bitcode because the `load` type is set to `i8*`, while `i8 addrspace(1)*` is expected. Passing the instruction along similarly to the change proposed here makes this work:
```patch
diff --git a/llvm/lib/Bitcode/Writer50/BitcodeWriter50.cpp b/llvm/lib/Bitcode/Writer50/BitcodeWriter50.cpp
index c5c52932512f..20b58f7d1846 100644
--- a/llvm/lib/Bitcode/Writer50/BitcodeWriter50.cpp
+++ b/llvm/lib/Bitcode/Writer50/BitcodeWriter50.cpp
@@ -2845,7 +2845,7 @@ void ModuleBitcodeWriter50::writeInstruction(const Instruction &I,
if (!pushValueAndType(I.getOperand(0), InstID, Vals)) // ptr
AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
}
- Vals.push_back(getTypeID(I.getType()));
+ Vals.push_back(getTypeID(I.getType(), &I));
Vals.push_back(getEncodedAlign(cast<LoadInst>(I).getAlign()));
Vals.push_back(cast<LoadInst>(I).isVolatile());
if (cast<LoadInst>(I).isAtomic()) {
```
https://github.com/llvm/llvm-project/pull/94337
More information about the llvm-commits
mailing list