[LLVMdev] inserting a print statement into IR

Jake jake.cobb at gmail.com
Thu Apr 7 10:13:45 PDT 2011


I have this same issue using the 2.8 release in Linux.  The function
CreateGlobalString is declared on line 150 of llvm/Support/IRBuilder.h in
the IRBuilderBase class but without implementation:

  Value *CreateGlobalString(const char *Str = "", const Twine &Name = "");

CreateGlobalStringPtr is implemented in terms of CreateGlobalString starting
on line 818 of llvm/Support/IRBuilder.h in the IRBuilder class::

  /// CreateGlobalStringPtr - Same as CreateGlobalString, but return a
  /// with "i8*" type instead of a pointer to array of i8.
  Value *CreateGlobalStringPtr(const char *Str = "", const Twine &Name = "")
    Value *gv = CreateGlobalString(Str, Name);
    Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
    Value *Args[] = { zero, zero };
    return CreateInBoundsGEP(gv, Args, Args+2, Name);

The implementation of CreateGlobalString starts on line 25 of
lib/VMCore/IRBuilder.cpp.  That file implements just one other function,
getCurrentFunctionReturnType.  Attempting to call
getCurrentFunctionReturnType has the same issue, it compiles but fails with
opt due to the symbol being undefined.

However, there are stock transforms that successfully call these functions,
for example lib/Transforms/InstCombine.  InstCombine is being built as a
static library (using BUILD_ARCHIVE), whereas our transform is a loadable
module.  Does that offer any clue as to the problem?  Perhaps we need to
specify something for LIBS or USEDLIBS in our Makefile?



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

> Hi George,
> > This is the seg fault I am getting.
> >
> > dyld: lazy symbol binding failed: Symbol not found:
> > __ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
> >    Referenced from:
> >
> /Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMArrayBoundsCheck.dylib
> >    Expected in: flat namespace
> >
> > dyld: Symbol not found:
> __ZN4llvm13IRBuilderBase18CreateGlobalStringEPKcRKNS_5TwineE
> >    Referenced from:
> >
> /Users/georgebaah/llvm_dir/llvm-2.8/Debug+Asserts/lib/LLVMArrayBoundsCheck.dylib
> >    Expected in: flat namespace
> this is quite a different kind failure to what I was imagining when you
> mentioned getting a segfault!  Indeed calling a function will clearly fail
> if that function doesn't exist.  I suggest you work out where in LLVM these
> symbols are defined (or determine that they are not defined anywhere) and
> then try to work out why your library wasn't linked with them.  Probably
> you forgot to link with the right LLVM library.
> 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/20110407/597dd0d4/attachment.html>

More information about the llvm-dev mailing list