[llvm-dev] setDataLayout segfault
Mehdi Amini via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 14 10:05:37 PDT 2016
> On Sep 14, 2016, at 7:59 AM, Frank Winter via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> I get a segfault with this code when setting the data layout:
>
>
>
> int main(int argc, char** argv)
> {
> llvm::InitializeNativeTarget();
>
> llvm::LLVMContext TheContext;
> unique_ptr<Module> Mod(new Module("A",TheContext));
>
> llvm::EngineBuilder engineBuilder(std::move(Mod));
> std::string mcjit_error;
>
> engineBuilder.setMCPU(llvm::sys::getHostCPUName());
>
> engineBuilder.setEngineKind(llvm::EngineKind::JIT);
> engineBuilder.setOptLevel(llvm::CodeGenOpt::Aggressive);
> engineBuilder.setErrorStr(&mcjit_error);
>
> llvm::TargetOptions targetOptions;
> targetOptions.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> engineBuilder.setTargetOptions( targetOptions );
>
> TargetMachine *targetMachine = engineBuilder.selectTarget();
>
> assert(targetMachine && "failed to create target machine");
>
> std::cout << targetMachine->createDataLayout().getStringRepresentation() << "\n";
>
> Mod.get()->setDataLayout( targetMachine->createDataLayout().getStringRepresentation() ); // this segfaults
> Mod.get()->setDataLayout( targetMachine->createDataLayout() ); // as well as this
> }
>
>
> Backtrace:
>
>
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> e-m:e-i64:64-f80:128-n8:16:32:64-S128
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff5f65832 in llvm::SmallVectorTemplateCommon<unsigned char, void>::end (this=0x148) at /home/fwinter/svn/llvm-3.9/include/llvm/ADT/SmallVector.h:117
> 117 iterator end() { return (iterator)this->EndX; }
> (gdb) bt
> #0 0x00007ffff5f65832 in llvm::SmallVectorTemplateCommon<unsigned char, void>::end (this=0x148) at /home/fwinter/svn/llvm-3.9/include/llvm/ADT/SmallVector.h:117
> #1 llvm::SmallVectorImpl<unsigned char>::clear (this=0x148) at /home/fwinter/svn/llvm-3.9/include/llvm/ADT/SmallVector.h:345
> #2 0x00007ffff5fa13b5 in llvm::DataLayout::clear (this=0x138) at /home/fwinter/svn/llvm-3.9/lib/IR/DataLayout.cpp:545
> #3 0x00007ffff5f9f561 in llvm::DataLayout::reset (this=0x138, Desc=...) at /home/fwinter/svn/llvm-3.9/lib/IR/DataLayout.cpp:179
> #4 0x00007ffff60b25ca in llvm::Module::setDataLayout (this=0x0,
The Module is a null pointer here.
—
Mehdi
> #5 0x0000000000406c46 in main (argc=1, argv=0x7fffffffde68) at main.cc:95
>
>
> Any idea?
>
> Frank
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
More information about the llvm-dev
mailing list