[llvm-dev] Pseudo-instruction that overwrites its input register

Dr. ERDI Gergo via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 3 20:37:51 PDT 2017


Sorry, that was a complete red herring (the cast<ConstantSDNode> failed), 
here's the real error message I get with the below approach:

llc: CodeGen/SelectionDAG/SelectionDAG.cpp:6518: 
void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*, llvm::SDNode*): 
Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i))
&& "Cannot use this version of ReplaceAllUsesWith!"' 
failed.

which I assume is because of the type difference I mentioned ((i16, i16, 
ch) vs (i16, ch) on the output ports)

On Sat, 3 Jun 2017, Dr. ERDI Gergo wrote:

> In my ISelDATToDAG, if I match something like
>
> Selecting: t17: i16,ch = load<LD2[%v25](align=1)(dereferenceable)> t16:1, t2, 
> undef:i16
>
> then whatever I return as the machine node, it will have to be of the same 
> type, i.e. (i16, ch), right? But if I have this extra output port for the 
> changed address register, that means my output is now (i16, i16, ch). It is 
> unclear to me how to reconcile that with the original abstract node that I'm 
> matching on.
>
> In more concrete terms, I tried ignoring this and just copying the address 
> argument and the chain:
>
>    const LoadSDNode *LD = cast<LoadSDNode>(N);
>    int Offs = cast<ConstantSDNode>(LD->getOffset())->getSExtValue();
>    if (AM == ISD::UNINDEXED && Offs == 0) {
>      SDNode* LDW = CurDAG->getMachineNode(
>        AVR::LDWRdPtr, SDLoc(N), VT, PtrVT, MVT::Other,
>        LD->getBasePtr(), LD->getChain());
>
>      ReplaceNode(N, LDW);
>      return true;
>    }
>
> but this fails with
>
> /home/cactus/prog/rust/rust-avr/llvm/include/llvm/Support/Casting.h:222: 
> typename std::enable_if<(! llvm::is_simple_type<Y>::value), typename 
> llvm::cast_retty<X, const Y>::ret_type>::type llvm::cast(const Y&)
> [with X = llvm::ConstantSDNode;
>      Y = llvm::SDValue;
>      typename std::enable_if<(!llvm::is_simple_type<Y>::value),
>      typename llvm::cast_retty<X, const Y>::ret_type>::type = 
> llvm::ConstantSDNode*]:
> Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' 
> failed.
>
> Any more hints, please?
>
> Thanks,
> 	Gergo


More information about the llvm-dev mailing list