<p class="p1">I've implemented a function pass, and some associated hacks to llvm and clang, and am hitting an error in a DAG pass when my transformed IR is processed.  That transformed bytecode attempts to insert a call around a load of a 'long double'.  The error is:<br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>3.<span class="Apple-converted-space">      </span>Running pass 'Function Pass Manager' on module 'big.c'.</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>4.<span class="Apple-converted-space">      </span>Running pass 'X86 DAG->DAG Instruction Selection' on function '@ld'</span><br></p><div class="protonmail_signature_block "><div class="protonmail_signature_block-user "><div style="color: rgb(34, 34, 34); font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The assert is after a failure to lookup a BestRC pointer in this function:<br></div></div></div><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span></span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>(gdb) b 141 if (BestRC == 0)</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>Breakpoint 3 at 0x7ffff6755436: file /home/pjoot/llvm/lib/CodeGen/TargetRegisterInfo.cpp, line 141.</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>(gdb) c</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>Continuing.</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>Breakpoint 3, llvm::TargetRegisterInfo::getMinimalPhysRegClass (this=0x5cc4f8, reg=44, VT=...) at /home/pjoot/llvm/lib/CodeGen/TargetRegisterInfo.cpp:141</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>141 <span class="Apple-converted-space">      </span>assert(BestRC && "Couldn't find the register class");</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>(gdb) p reg</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>$4 = 44</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>(gdb) p c</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>$5 = (const llvm::TargetRegisterClass *) 0x0</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>(gdb) p VT</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>$6 = {SimpleTy = llvm::MVT::SimpleValueType::i32}</span><br></p><div><br></div><div>The bytecode that my pass is producing is:<br></div><div><br></div><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>; Function Attrs: nounwind uwtable</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>define x86_fp80 @ld(x86_fp80* nocapture readonly %d) local_unnamed_addr #0 </span><span class="s2">{</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>entry:</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>%0 = load x86_fp80, x86_fp80* %d, align 16, !tbaa !1</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>%swap16 = tail call x86_fp80 @__lz_bswapld(x86_fp80 %0) #1</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>ret x86_fp80 %swap16</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span></span><span class="s2">}</span><br></p><div>where the untransformed bytecode was:<br></div><div><br></div><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>define x86_fp80 @ld(x86_fp80* nocapture readonly %d) local_unnamed_addr #0 </span><span class="s2">{</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span>entry:</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>%0 = load x86_fp80, x86_fp80* %d, align 16, !tbaa !1</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">      </span>ret x86_fp80 %0</span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">    </span></span><span class="s2">}</span><br></p><div>What about this transformed bytecode does the later DAG->DAG pass dislike?  What is the valid range of registers in this function (i.e. is the reg=45 value that I see in this function valid)?</div><div><br></div><div class="protonmail_signature_block "><div class="protonmail_signature_block-user "><div>--<br></div><div>Peeter<br></div></div><div class="protonmail_signature_block-proton protonmail_signature_block-empty"><br></div></div><div><br></div>