This is the error:<div><br></div><div><div>0 opt 0x087e59ee</div><div>1 opt 0x087e5863</div><div>2 0x00a49400 __kernel_sigreturn + 0</div><div>3 opt 0x083bdd0b llvm::PATypeHolder::operator llvm::Type*() const + 29</div>
<div>4 opt 0x083bddb6 llvm::Value::getType() const + 32</div><div>5 opt 0x08725e33 llvm::CallInst::init(llvm::Value*, llvm::Value* const*, unsigned int) + 313</div><div>6 opt 0x083d7c4c void llvm::CallInst::init<__gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > > >(llvm::Value*, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, llvm::Twine const&, std::random_access_iterator_tag) + 92</div>
<div>7 opt 0x083d6c46 llvm::CallInst::CallInst<__gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > > >(llvm::Value*, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, llvm::Twine const&, llvm::Instruction*) + 266</div>
<div>8 opt 0x083d5ed3 llvm::CallInst* llvm::CallInst::Create<__gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > > >(llvm::Value*, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, __gnu_cxx::__normal_iterator<llvm::Value**, std::vector<llvm::Value*, std::allocator<llvm::Value*> > >, llvm::Twine const&, llvm::Instruction*) + 103</div>
<div>9 LLVMMpiAware.so 0x0011b842</div><div>10 LLVMMpiAware.so 0x0011b22e</div><div>11 opt 0x0875ad26 llvm::MPPassManager::runOnModule(llvm::Module&) + 388</div><div>12 opt 0x0875b212 llvm::PassManagerImpl::run(llvm::Module&) + 122</div>
<div>13 opt 0x0875b4f7 llvm::PassManager::run(llvm::Module&) + 39</div><div>14 opt 0x083b108b main + 3303</div><div>15 libc.so.6 0x005e0b56 __libc_start_main + 230</div><div>16 opt 0x083a2bd1</div>
<div>Stack dump:</div><div>0.<span class="Apple-tab-span" style="white-space:pre"> </span>Program arguments: opt -load ../../../Debug/lib/LLVMMpiAware.so -mpiaware </div><div>1.<span class="Apple-tab-span" style="white-space:pre"> </span>Running pass 'MPI Aware Pass' on module '<stdin>'.</div>
<div>Segmentation fault</div><div><br></div><br><div class="gmail_quote">On Sun, Apr 18, 2010 at 12:55 AM, Yuanfang Chen <span dir="ltr"><<a href="mailto:tabloid.adroit@gmail.com">tabloid.adroit@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>I need to generate variables like </div><div><br><div>status1, status2, status3, ......</div><div>request1, request2, request3, ......</div>
<div><br></div><div>this is my code, other unrelated detail are eliminated.</div>
<div><br></div><div>static int varNum;</div><div><div>static const char *getVarNum() {</div><div><span style="white-space:pre"> </span>++varNum;</div><div><span style="white-space:pre"> </span>std::stringstream ss;</div>
<div><span style="white-space:pre"> </span>ss << varNum;</div><div><span style="white-space:pre"> </span>std::string *varname = new std::string(ss.str());</div><div><span style="white-space:pre"> </span>return varname->c_str();</div>
<div>}</div></div><div><br></div><div>const char *VarNum = getVarNum();</div><div><div>Twine *x1 = new Twine(StringRef("status"), VarNum); // 1</div><div>Twine *x2 = new Twine(StringRef("request"), VarNum); // 2</div>
<div><br></div><div>Instruction *sstatusInst = new AllocaInst(StatusTy, *x1, entry_inst); // 3</div><div>Instruction *sreqInst = new AllocaInst(ReqTy, *x2, entry_inst); // 4</div></div><div><br></div></div>
<div>with only 1&3, my code works well, I can have status1, status2, status3, ......</div><div><br></div><div>with 1&2&3&4 exists at the same time, it compiles without problem, but</div><div>segmentation fault happens. </div>
<div><br></div><div>Instruction *sreqInst = new AllocaInst(ReqTy, "request", entry_inst); // 5</div><div>with 1&2&3&5, everything work, but that's not what I want. </div>
<div><br></div><div>I really can't figure out what is broken. I create everything new on the heap. </div><div>Each alloca inst with its own Twine object on the heap. Could anyone help me</div><div>out? Thanks a lot.</div>
<div><br></div><font color="#888888"><div>yuanfang</div>
</font></blockquote></div><br></div>