Shawn Kim
2011-Sep-21 00:05 UTC
[LLVMdev] Segmentation fault while adding an addtional argument
Hi, all
I am trying to write a function pass to replace a old function to a new
function like:
int haha(int a) { } ==> int haha(int a, char *IO) { }
The below is a part of my code and generate segmentation fault. Can you help
me to fix it?
Thanks,
Shawn
// Since we have now created the new function, splice the body of the
old
// function right into the new function, leaving the old rotting hulk of
the
// function empty.
NF->getBasicBlockList().splice(NF->begin(), F.getBasicBlockList());
Value *Globals = NF->arg_end();
Globals->setName("globals");
=========================================================150
Globals->setName("globals");
(gdb)
Program received signal SIGSEGV, Segmentation fault.
0x08591311 in llvm::StringRef::operator[] (this=0xbfffeca0, Index=0)
at /home/skim/Etc/LLVM/llvm/include/llvm/ADT/StringRef.h:181
181 return Data[Index];
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20110920/7e035f28/attachment.html>
Eli Friedman
2011-Sep-21 00:21 UTC
[LLVMdev] Segmentation fault while adding an addtional argument
On Tue, Sep 20, 2011 at 5:05 PM, Shawn Kim <shawn.subscribe at gmail.com> wrote:> Hi, all > > I am trying to write a function pass to replace a old function to a new > function like: > int haha(int a) { } ==> int haha(int a, char *IO) { } > > The below is a part of my code and generate segmentation fault. Can you help > me to fix it? > Thanks, > Shawn > > // Since we have now created the new function, splice the body of the > old > // function right into the new function, leaving the old rotting hulk of > the > // function empty. > NF->getBasicBlockList().splice(NF->begin(), F.getBasicBlockList()); > > Value *Globals = NF->arg_end(); > Globals->setName("globals");You can't dereference arg_end... you might want to read up a bit on C++ iterators. -Eli