[llvm] [SPIR-V] Emit SPIR-V bitcasts between source/expected pointer type (PR #69621)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 04:30:21 PST 2023
================
@@ -255,7 +259,19 @@ Instruction *SPIRVEmitIntrinsics::visitGetElementPtrInst(GetElementPtrInst &I) {
}
Instruction *SPIRVEmitIntrinsics::visitBitCastInst(BitCastInst &I) {
- SmallVector<Type *, 2> Types = {I.getType(), I.getOperand(0)->getType()};
+ Value *Source = I.getOperand(0);
+
+ // SPIR-V, contrary to LLVM 17+ IR, supports bitcasts between pointers of
+ // varying element types. In case of IR coming from older versions of LLVM
+ // such bitcasts do not provide sufficient information, should be just skipped
+ // here, and handled in insertPtrCastInstr.
+ if (I.getType()->isPointerTy()) {
+ I.replaceAllUsesWith(Source);
+ I.eraseFromParent();
+ return &I;
----------------
Keenuts wrote:
If you go the `nullptr` way, maybe it would be time to add a comment on those visitors to explain `Returns the newly created intrinsic, nullptr otherwise`?
It just seem to contradict what `visitSwitchInst` is doing tho.
https://github.com/llvm/llvm-project/pull/69621
More information about the llvm-commits
mailing list