<div dir="ltr">Since the steps on how to create a new instruction in <a href="http://llvm.org/docs/ExtendingLLVM.html" style="font-family:arial,sans-serif;font-size:13px" target="_blank">http://llvm.org/docs/ExtendingLLVM.html</a><span style="font-family:arial,sans-serif;font-size:13px"> point to files which are not present in LLVM 3.2, I looked at the diffs for a couple of new instructions (fence, resume etc) that were added some time back, to create my own SwitchCodeInst. </span><div>


<br></div><div><font face="arial, sans-serif">The following command works fine </font></div><div><font face="arial, sans-serif">opt -load /home/silkyar/Workspace/32b_llvm/llvm/Debug+Asserts/lib/LLVMTestSwitchCore.so -testswitchcore test.bc > test_new.bc<br>


but conversion to assembly crashes with the following error - </font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div><div>llc: test_new.bc: error: Invalid ALLOCA record</div>


<div>While deleting: i32 %</div><div>Use still stuck around after Def is destroyed:  switchcore i32 1</div></div><div>llc: Value.cpp:79: virtual llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed.<br>


</div><div><br></div><div>The code to insert the new instruction is straight forward - </div><div><div>Value* coreType = ConstantInt::get(llvm::Type::getInt32Ty(F.getContext()), 1); </div><div>Instruction* fnp = bbIter->getFirstNonPHI();<br>


</div><div>SwitchCoreInst::Create(coreType, fnp);</div></div><div><br></div><div>Could someone help me out with this? Does llc require certain files to be changed for the assembly which are not part of the diff for 'ResumeInst' that I followed<br>


<a href="https://github.com/clang-omp/llvm/commit/dccc03b2423fe65efb5963ae816b99c24fc53374" target="_blank">https://github.com/clang-omp/llvm/commit/dccc03b2423fe65efb5963ae816b99c24fc53374</a></div><div><br></div><div>Thanks,</div>

<div>
Silky </div></font></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 9, 2014 at 1:04 PM, Silky Arora <span dir="ltr"><<a href="mailto:silkyar@umich.edu" target="_blank">silkyar@umich.edu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi,<br><br></div>I am working on a project that requires me to suggest to the hardware simulator (gem5) switch cores from one to another at the start of certain basic blocks. Could someone advice me if I should go with introducing a new Intrinsic instruction for this purpose. I will be following <a href="http://llvm.org/docs/ExtendingLLVM.html" target="_blank">http://llvm.org/docs/ExtendingLLVM.html</a> for this. Gem5 has certain reserved op-codes which I can use. <br>




<br></div>I was thinking of adding the new instruction to Other Ops type but haven't quite figured out the whole procedure yet. The instruction requires to have one intty argument (that can take values from 0-2) specifying the core type.<br>




</div>Any help or suggestions would be appreciated. <br><br></div>Regards,<br></div>Silky Arora<br></div><div>Graduate Student Research Assistant<br></div>University of Michigan<br></div>
</blockquote></div><br></div></div>