This is the seg fault I am getting.<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/LLVMArrayBoundsCheck.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/LLVMArrayBoundsCheck.dylib</div>
<div>  Expected in: flat namespace</div><div><br></div><div>0  opt                        0x0045e01c llvm::SearchForAddressOfSpecialSymbol(char const*) + 284</div><div>1  opt                        0x0045e61e llvm::sys::RunInterruptHandlers() + 354</div>
<div>2  libSystem.B.dylib          0x93bcb2bb _sigtramp + 43</div><div>3  libSystem.B.dylib          0xffffffff _sigtramp + 1816350063</div><div>4  libSystem.B.dylib          0x8fe18c2f _sigtramp + 18446744073644857759</div>
<div>5  LLVMArrayBoundsCheck.dylib 0x0102c9df</div><div>6  LLVMArrayBoundsCheck.dylib 0x0102ca95</div><div>7  LLVMArrayBoundsCheck.dylib 0x0102ce2c</div><div>8  LLVMArrayBoundsCheck.dylib 0x0102ceec</div><div>9  opt                        0x003d265b llvm::FPPassManager::doInitialization(llvm::Module&) + 63</div>
<div>10 opt                        0x003d6062 llvm::FPPassManager::runOnModule(llvm::Module&) + 24</div><div>11 opt                        0x003d5b4d llvm::MPPassManager::runOnModule(llvm::Module&) + 375</div><div>
12 opt                        0x003d5d9c llvm::PassManagerImpl::run(llvm::Module&) + 112</div><div>13 opt                        0x003d5df5 llvm::PassManager::run(llvm::Module&) + 27</div><div>14 opt                        0x0000d68e main + 4026</div>
<div>15 opt                        0x00002146 start + 54</div><div>16 opt                        0x00000005 start + 18446744073709543157</div><div>Stack dump:</div><div>0.      Program arguments: opt -mem2reg -load ../llvm-2.8/Debug+Asserts/lib/LLVMArrayBoundsCheck.dylib -paa </div>
<div>1.      Running pass 'Function Pass Manager' on module '<stdin>'.</div><div>Segmentation fault</div><div><br></div><br><div class="gmail_quote">On Mon, Apr 4, 2011 at 11:33 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

  
    
  
  <div text="#000000" bgcolor="#ffffff"><div class="im">
    On 4/4/2011 6:26 PM, George Baah wrote:
    <blockquote type="cite"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">
        <div>
          <div>Hi Everyone,</div>
          <div>  I am trying to construct the print statement :
            printf("value:%d\n", value); </div>
          <div>This is my llvm code. It is seg faulting at
            builder.CreateGlobalStringPtr(str,"").</div>
        </div>
      </span></blockquote>
    <br></div>
    This might be easier to debug with a stack trace.  Use a debugger to
    see the call stack when the segfault occurs.  Also try to isolate
    which pointer value is bad.<br>
    <br>
    As a guess, did you give the builder object all the information it
    needs to insert IR (e.g., which LLVM Module * it is modifying, which
    BasicBlock or Instruction it is to use when inserting instructions,
    etc)?<br>
    <br>
    -- John T.<div class="im"><br>
    <br>
    <blockquote type="cite"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">
        <div>
          <div>Thanks.</div>
          <div><br>
          </div>
          <div>George</div>
          <div><br>
          </div>
          <div>vector<const Type *> params;</div>
          <div>params.push_back(Type::getInt8PtrTy(M.getContext()));</div>
          <div>FunctionType *fType =
            FunctionType::get(Type::getInt32Ty(M.getContext()), params,
            true);</div>
          <div>Constant *temp = M.getOrInsertFunction("printf",fType);</div>
          <div>if(!temp){</div>
          <div>  errs() << "printf function not in symbol
            table\n";</div>
          <div>  exit(1);</div>
          <div>}</div>
          <div>Function *f = cast<Function>(temp);</div>
          <div>f->setCallingConv(CallingConv::C);</div>
        </div>
        <div><br>
        </div>
        <div>const char *str = "value: %d\n";</div>
        <div>Value *intparam = ...</div>
        <div>
          <div>Value *strPtr = builder.CreateGlobalStringPtr(str,"");</div>
        </div>
        <div>
          <div>builder.CreateCall2(PrintF, strPtr, intparam,"tmp6");</div>
        </div>
      </span>
    </blockquote>
    <br>
  </div></div>

<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>
<br></blockquote></div><br></div>