<div>Hi Duncan,</div><div>I replaced cast<Function> with dyn_cast<Function> and f is not null.</div><div><br></div>The problem happens to be coming from the CreateGlobalStringPtr.<div>I am getting this error, </div>
<div><br></div><div><div>dyld: lazy symbol binding failed: Symbol not found: __ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE</div><div>  Referenced from: /Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMMyTest.dylib</div>
<div>  Expected in: flat namespace</div><div><br></div><div>dyld: Symbol not found: __ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE</div><div>  Referenced from: /Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMMyTest.dylib</div>
<div>  Expected in: flat namespace</div><div><br></div>Thanks.</div><div><br></div><div>George </div><div><br><div class="gmail_quote">On Fri, Apr 1, 2011 at 2:44 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi George,<br>
<div class="im"><br>
>    I am trying to insert printf ("%d", v), where v is an integer param, into the IR.<br>
> I am doing something wrong because I keep getting segfaults.<br>
<br>
</div>if you are doing development with LLVM then you should build LLVM with<br>
assertions enabled.  That way you get understandable failures rather<br>
than obscure segmentation faults.<br>
<div class="im"><br>
> Function *f = cast<Function>(temp);<br>
<br>
</div>If printf was already present in the module but with a different type then<br>
temp will be a bitcast of the existing declaration (the bitcast changing<br>
the type), and this will fail.<br>
<br>
Ciao, Duncan.<br>
_______________________________________________<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" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>