Hi All, 
<div><br></div><div>The following crashes in CreateGlobalStringPtr: </div><div><div>#include "llvm/Support/DataTypes.h"</div><div>#include "llvm/LLVMContext.h"</div><div>#include "llvm/Module.h"</div>

<div>#include "llvm/Constants.h"</div><div>#include "llvm/Function.h"</div><div>#include "llvm/BasicBlock.h"</div><div>#include "llvm/ExecutionEngine/ExecutionEngine.h"</div><div>#include "llvm/ExecutionEngine/GenericValue.h"</div>

<div>#include "llvm/Support/IRBuilder.h"</div><div><br></div><div>#include <vector></div><div>#include <cstdio></div><div>#include <string></div><div><br></div><div>int main()</div><div>{</div>

<div>  llvm::LLVMContext & context = llvm::getGlobalContext();</div><div>  llvm::Module *module = new llvm::Module("asdf", context);</div><div>  llvm::IRBuilder<> builder(context);</div><div> <font color="#ff0000"> llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n"); // crash here</font></div>

<div>}</div></div><div><br></div><div>And this one doesn't, any idea what's happening here: </div><div><div>#include "llvm/Support/DataTypes.h"</div><div>#include "llvm/LLVMContext.h"</div><div>

#include "llvm/Module.h"</div><div>#include "llvm/Constants.h"</div><div>#include "llvm/Function.h"</div><div>#include "llvm/BasicBlock.h"</div><div>#include "llvm/ExecutionEngine/ExecutionEngine.h"</div>

<div>#include "llvm/ExecutionEngine/GenericValue.h"</div><div>#include "llvm/Support/IRBuilder.h"</div><div><br></div><div>#include <vector></div><div>#include <cstdio></div><div>#include <string></div>

<div><br></div><div>int main()</div><div>{</div><div>  llvm::LLVMContext & context = llvm::getGlobalContext();</div><div>  llvm::Module *module = new llvm::Module("asdf", context);</div><div>  llvm::IRBuilder<> builder(context);</div>

<div><br></div><div>  <font color="#3366ff">// Added extra</font></div><div><font color="#6633ff">  </font><font color="#3366ff">llvm::FunctionType *funcType = llvm::FunctionType::get(builder.getVoidTy(), false);</font></div>

<div><font color="#3366ff">  llvm::Function *mainFunc = llvm::Function::Create(funcType, llvm::Function::ExternalLinkage, "main", module);</font></div><div><font color="#3366ff">  llvm::BasicBlock *entry = llvm::BasicBlock::Create(context, "entry", mainFunc);</font></div>

<div><font color="#3366ff">  builder.SetInsertPoint(entry);</font></div><div><br></div><div>  llvm::Value *helloWorld = builder.CreateGlobalStringPtr("hello world!\n");</div></div><div>}</div><div><br></div><div>

Not sure how creating a main routine and an entry point can remove the crash. Thought they were unrelated. Here are my options to g++ for compiling: </div><div><div>llvm-config --cxxflags --ldflags --libs</div><div>-I/usr/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3  -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual</div>

<div>-L/usr/lib  -lpthread -lm </div><div>-lLLVMXCoreCodeGen -lLLVMTableGen -lLLVMSystemZCodeGen -lLLVMSparcCodeGen -lLLVMPTXCodeGen -lLLVMPowerPCCodeGen -lLLVMMSP430CodeGen -lLLVMMipsCodeGen -lLLVMMCJIT -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCDisassembler -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMPTXDesc -lLLVMPTXInfo -lLLVMPTXAsmPrinter -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMMBlazeDisassembler -lLLVMMBlazeAsmParser -lLLVMMBlazeCodeGen -lLLVMMBlazeDesc -lLLVMMBlazeAsmPrinter -lLLVMMBlazeInfo -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMDebugInfo -lLLVMCppBackend -lLLVMCppBackendInfo -lLLVMCellSPUCodeGen -lLLVMCellSPUDesc -lLLVMCellSPUInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBlackfinCodeGen -lLLVMBlackfinDesc -lLLVMBlackfinInfo -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMX86Info -lLLVMAsmParser -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDesc -lLLVMARMAsmPrinter -lLLVMARMInfo -lLLVMArchive -lLLVMBitReader -lLLVMAlphaCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAlphaDesc -lLLVMAlphaInfo -lLLVMMC -lLLVMSupport</div>

</div><div><br></div><div>Thanks,</div><div>  Arpan</div>