<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="font-family: Calibri; font-size: 16px;"><div><span style="font-size: 12pt;">Hi,</span></div><div><br></div><div>So I included this in my code:</div><div><br></div><div><span style="font-size: 12pt;">ArrayType* b = ArrayType::get(IntegerType::get(getGlobalContext(), 8), 10);</span></div><div>AllocaInst* pa = new AllocaInst(b, "arr");</div><div><br></div><div>//Considering that <b>I</b> represents the instruction iterator pointing to the instruction that I want to replace (i.e. <span style="font-size: 12pt;">%arr = alloca [30 x i8], align 1</span><span style="font-size: 12pt;">)</span></div><div><br></div><div><span style="font-size: 12pt;">I->replaceAllUsesWith(pa); </span></div><div>I->eraseFromParent();</div><div>I->getParent()->getInstList().insert(*I, pa); </div><div><br></div><div>I'm running into the following error: </div><div><br></div><div>Stack dump:</div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">Return code not zero; aborting</span></div><div><span style="font-size: 12pt;">void llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.</span></div><div>0 opt 0x08fc4996 llvm::sys::PrintStackTrace(_IO_FILE*) + 50</div><div>1 opt 0x08fc4be9</div><div>2 opt 0x08fc45f0</div><div>3 0xb77c4400 __kernel_sigreturn + 0</div><div>4 0xb77c4422 __kernel_vsyscall + 2</div><div>5 libc.so.6 0xb751f941 gsignal + 81</div><div>6 libc.so.6 0xb7522d72 abort + 386</div><div>7 libc.so.6 0xb7518b58 __assert_fail + 248</div><div>8 opt 0x08edfb85 llvm::Value::replaceAllUsesWith(llvm::Value*) + 187</div><div>9 CS6265Pass.so 0xb77bdee4</div><div>10 opt 0x08ec5317 llvm::FPPassManager::runOnFunction(llvm::Function&) + 301</div><div>11 opt 0x08ec54b8 llvm::FPPassManager::runOnModule(llvm::Module&) + 92</div><div>12 opt 0x08ec57bc llvm::MPPassManager::runOnModule(llvm::Module&) + 496</div><div>13 opt 0x08ec5d4d llvm::PassManagerImpl::run(llvm::Module&) + 229</div><div>14 opt 0x08ec5f41 llvm::PassManager::run(llvm::Module&) + 39</div><div>15 opt 0x0849c28b main + 5835</div><div>16 libc.so.6 0xb750be46 __libc_start_main + 230</div><div>17 opt 0x0848e4b1</div></div><div style="font-family: Calibri; font-size: 16px;"><br></div><div style="font-family: Calibri; font-size: 16px;">How can I fix it?</div><div style="font-family: Calibri; font-size: 16px;"><br></div><div style="font-family: Calibri; font-size: 16px;">Thanks,</div><div style="font-family: Calibri; font-size: 16px;">Shivam</div><div style="font-family: Calibri; font-size: 16px;"><br></div><div style="font-family: Calibri; font-size: 16px;"><br></div><div><div>On Dec 4, 2013, at 4:57 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Create a new alloca instruction, insert it into the IR right before (or after) the old one, RAUW the value, then delete the old instruction. You should be able to find a variety of examples of this sort of thing in most of the IR level optimization passes. I’d look at InstCombine in particular.</div><div><br></div><div>-Jim</div><div><br><div><div>On Dec 4, 2013, at 1:40 PM, Shivam Bhagi <<a href="mailto:shivam.bhagi@outlook.com">shivam.bhagi@outlook.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="font-family: Calibri; font-size: 16px;">Hi,</div><div style="font-family: Calibri; font-size: 16px;"><div><br></div><div>While looking over the IR generated by my source code, I came across the following:</div><div><br></div><div>%arr = alloca [30 x i8], align 1</div><div><br></div><div>In the source code this particular line of code is represented by:</div><div><br></div><div>int arr[30];</div><div><br></div><div>I was wondering how I could change the capacity of arr from 30 to any other integral value via a function-pass. I know that 'alloca' can be used for reserving space on stack; further, 'store' can be used for writing to memory. I was wondering how that would work for an array though?</div><div><br></div><div>Thanks,</div><div>Shivam</div></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></div></blockquote></div><br></body></html>