[llvm] [NVPTX] Check Before inserting AddrSpaceCastInst in NVPTXLoweringAlloca (PR #106127)
weiwei chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 26 13:47:38 PDT 2024
weiweichen wrote:
> > do an explicit cast which will actually fail assertion with `AddrSpaceCastInst`
>
> @weiweichen, where is this assertion? Maybe it needs to be changed.
It comes from [here](https://github.com/llvm/llvm-project/blob/7854b16d2699ca7cc02d4ea066230d370c751ba9/llvm/lib/IR/Instructions.cpp#L3416)
```
AddrSpaceCastInst::AddrSpaceCastInst(Value *S, Type *Ty, const Twine &Name,
InsertPosition InsertBefore)
: CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
assert(castIsValid(getOpcode(), S, Ty) && "Illegal AddrSpaceCast");
}
```
where `castIsValid(getOpcode(), S, Ty)` returns `false` if `S` is already in the same address space which is from the logic [here](https://github.com/llvm/llvm-project/blob/7854b16d2699ca7cc02d4ea066230d370c751ba9/llvm/lib/IR/Instructions.cpp#L3333-L3334)
```
if (SrcPtrTy->getAddressSpace() == DstPtrTy->getAddressSpace())
return false;
```
@justinfargnoli, would it be better to remove ☝️ instead?
https://github.com/llvm/llvm-project/pull/106127
More information about the llvm-commits
mailing list