[LLVMdev] insert printf into IR

George Baah georgebaah at gmail.com
Mon Apr 4 13:48:46 PDT 2011


Hi Duncan,
I replaced cast<Function> with dyn_cast<Function> and f is not null.

The problem happens to be coming from the CreateGlobalStringPtr.
I am getting this error,

dyld: lazy symbol binding failed: Symbol not found:
__ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
  Referenced from:
/Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMMyTest.dylib
  Expected in: flat namespace

dyld: Symbol not found:
__ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
  Referenced from:
/Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMMyTest.dylib
  Expected in: flat namespace

Thanks.

George

On Fri, Apr 1, 2011 at 2:44 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi George,
>
> >    I am trying to insert printf ("%d", v), where v is an integer param,
> into the IR.
> > I am doing something wrong because I keep getting segfaults.
>
> if you are doing development with LLVM then you should build LLVM with
> assertions enabled.  That way you get understandable failures rather
> than obscure segmentation faults.
>
> > Function *f = cast<Function>(temp);
>
> If printf was already present in the module but with a different type then
> temp will be a bitcast of the existing declaration (the bitcast changing
> the type), and this will fail.
>
> Ciao, Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110404/1952dc73/attachment.html>


More information about the llvm-dev mailing list