<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br>
<div style="font-family: Calibri; font-size: 16px;">Hi,</div><div style="font-family: Calibri; font-size: 16px;"><br><div>In my IR code, I have the following:</div><div><br></div><div>%arr = alloca [30 x i8], align 1</div><div>%arraydecay = getelementptr inbounds [16 x i8]* %arr, i32 0, i32 0</div><div>%arraydecay1 = getelementptr inbounds [16 x i8]* %arr, i32 0, i32 0</div><div><br></div><div>I'm trying to change the capacity of <b>arr</b> via a function pass. I've written the following code in my function pass:</div><div><br></div><div>ArrayType* b = ArrayType::get(IntegerType::get(getGlobalContext(), 8), 10);</div><div>AllocaInst* pa = new AllocaInst(b, "arr");</div><div>//I is an instruction pointer currently pointing to %arr = alloca [30 x i8], align 1</div><div>I->replaceAllUsesWith(pa); </div><div>I->eraseFromParent();</div><div>I->getParent()->getInstList().insert(*I, pa);</div><div><br></div><div><div>When I run the pass, I run into the following error:</div><div><br></div><div>Stack dump:</div><div><br></div><div>Return code not zero; aborting</div><div>void llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `New->getType() == getType() && "replaceAllUses of value with new value of different type!"' failed.</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><br></div><div>How can I fix it?</div><div><br></div><div>Thanks,</div><div>Shivam</div></div></body></html>