[LLVMdev] Any suggestion for "Unknown instruction type encountered" error?
hacker cling
clinghacker at gmail.com
Fri Jul 5 17:23:40 PDT 2013
Hi Nick,
2013/7/6 Nick Lewycky <nicholas at mxc.ca>
> hacker cling wrote:
>
>> Hello all,
>> I was playing with LLVM pass. I changed the
>> lib/Transforms/Hello/Hello.cpp 's content to be my own pass. Then I make
>> install the pass and use an example test1.c to see whether it works or
>> not. When I run example using the following command:
>> clang -emit-llvm test1.c -c -o test1.bc
>> opt -load ../build_llvm/Debug+Asserts/**lib/LLVMHello.so -hello <
>> test1.bc
>> > /dev/null
>>
>> It shows the following error:
>>
>> Unknown instruction type encountered!
>> UNREACHABLE executed at include/llvm/InstVisitor.h:**120!
>>
>
> The error message here means that the type of instruction -- alloca, add,
> sub, load, store, etc. -- is one that did not exist in the compiler at the
> time that opt was built. This is a static list in the compiler, same as
> documented on llvm.org/docs/LangRef.html .
>
> My guess is that your .bc file is from a very different version of llvm
> than your 'opt' binary. Perhaps you're using a clang installed on the
> system and an opt your built yourself? We sometimes change the instruction
> numbering for the encoding in the .bc files. Does 'opt -verify < test1.bc'
> work?
>
>
I am sure that the version of llvm and opt are the same since I build them
at the same time.
opt -version
LLVM (http://llvm.org/):
LLVM version 3.3svn
DEBUG build with assertions.
Built Jun 12 2013 (19:47:01).
Default target: x86_64-unknown-linux-gnu
Host CPU: penryn
clang -v
clang version 3.3 (trunk 179269)
Target: x86_64-unknown-linux-gnu
Thread model: posix
They are both based on the trunk 179269. (Currently I am working on Cling(
http://root.cern.ch/drupal/content/cling), which is based on LLVM and clang
with the version 179269).
I use opt -verify < test1.bc -f
There is no error output.
I also use opt -verify -load ../build_llvm/Debug+Asserts/lib/LLVMHello.so
-hello < test1.bc -f
There is still no other error output except for the "Unknown instruction
type encountered!"
Another alternative is that you've managed to form invalid IR in some other
> way, or corrupted memory. Have you tried building 'opt' and LLVMHello.so
> with debug (so that llvm's assertions are enabled)? And what about running
> the 'opt' command under valgrind?
>
> I use valgrind to test it:
valgrind --tool=memcheck --leak-check=full opt -load
../build_llvm/Debug+Asserts/lib/LLVMHello.so -hello < test1.bc > /dev/null
==3609== Memcheck, a memory error detector
==3609== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==3609== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==3609== Command: opt -load ../build_llvm/Debug+Asserts/lib/LLVMHello.so
-hello
==3609==
define void @main() #0 {
entry:
%x = alloca i32, align 4
%0 = icmp eq i32* %x, null
br label %newBlock
newBlock: ; preds = %entry
store i32 5, i32* %x, align 4
ret void
}
Unknown instruction type encountered!
UNREACHABLE executed at /home/sploving/llvm/include/llvm/InstVisitor.h:120!
0 opt 0x00000000014190b6 llvm::sys::PrintStackTrace(_IO_FILE*)
+ 38
1 opt 0x0000000001419333
2 opt 0x0000000001418d8b
3 libpthread.so.0 0x0000003aa600f500
4 libc.so.6 0x0000003aa5c328a5 gsignal + 53
5 libc.so.6 0x0000003aa5c34085 abort + 373
6 opt 0x000000000140089b
7 LLVMHello.so 0x00000000050278b3
8 LLVMHello.so 0x000000000502783d
9 LLVMHello.so 0x00000000050277de
10 LLVMHello.so 0x0000000005027745
11 LLVMHello.so 0x0000000005027672
12 LLVMHello.so 0x000000000502746d
13 opt 0x00000000013a4e21
llvm::FPPassManager::runOnFunction(llvm::Function&) + 393
14 opt 0x00000000013a5021
llvm::FPPassManager::runOnModule(llvm::Module&) + 89
15 opt 0x00000000013a5399
llvm::MPPassManager::runOnModule(llvm::Module&) + 573
16 opt 0x00000000013a59a8
llvm::PassManagerImpl::run(llvm::Module&) + 254
17 opt 0x00000000013a5bbf llvm::PassManager::run(llvm::Module&)
+ 39
18 opt 0x000000000084b455 main + 5591
19 libc.so.6 0x0000003aa5c1ecdd __libc_start_main + 253
20 opt 0x000000000083d359
Stack dump:
0. Program arguments: opt -load
../build_llvm/Debug+Asserts/lib/LLVMHello.so -hello
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'Hello Pass' on function '@main'
==3609==
==3609== HEAP SUMMARY:
==3609== in use at exit: 200,735 bytes in 574 blocks
==3609== total heap usage: 2,340 allocs, 1,766 frees, 476,703 bytes
allocated
==3609==
==3609== 26 bytes in 1 blocks are possibly lost in loss record 106 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x85A69A: void llvm::cl::initializer<char
[2]>::apply<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string>
> >(llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >&)
const (CommandLine.h:290)
==3609== by 0x85912A: void
llvm::cl::applicator<llvm::cl::initializer<char [2]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [2]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0x856B05: void llvm::cl::apply<llvm::cl::initializer<char
[2]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [2]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0x8532FC: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<llvm::cl::FormattingFlags,
llvm::cl::desc, llvm::cl::initializer<char [2]>,
llvm::cl::value_desc>(llvm::cl::FormattingFlags const&, llvm::cl::desc
const&, llvm::cl::initializer<char [2]> const&, llvm::cl::value_desc
const&) (CommandLine.h:1195)
==3609== by 0x84C9CA: __static_initialization_and_destruction_0(int,
int) (opt.cpp:62)
==3609== by 0x84D5F6: global constructors keyed to opt.cpp (opt.cpp:831)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 26 bytes in 1 blocks are possibly lost in loss record 107 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9DDA9: std::string::_M_mutate(unsigned long, unsigned
long, unsigned long) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9DF6B: std::string::_M_replace_safe(unsigned long,
unsigned long, char const*, unsigned long) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x856E61: void llvm::cl::opt_storage<std::string, false,
true>::setValue<char [2]>(char const (&) [2], bool) (CommandLine.h:1070)
==3609== by 0x854129: std::string& llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::operator=<char [2]>(char const (&) [2])
(CommandLine.h:1166)
==3609== by 0x84A1AB: main (opt.cpp:613)
==3609==
==3609== 26 bytes in 1 blocks are possibly lost in loss record 108 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x143030A:
llvm::tool_output_file::CleanupInstaller::CleanupInstaller(char const*)
(ToolOutputFile.cpp:19)
==3609== by 0x14304A0: llvm::tool_output_file::tool_output_file(char
const*, std::string&, unsigned int) (ToolOutputFile.cpp:39)
==3609== by 0x84A1F0: main (opt.cpp:617)
==3609==
==3609== 29 bytes in 1 blocks are possibly lost in loss record 151 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0xC0722A: void llvm::cl::initializer<char
[5]>::apply<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string>
> >(llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >&)
const (CommandLine.h:290)
==3609== by 0xC071A3: void
llvm::cl::applicator<llvm::cl::initializer<char [5]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [5]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0xC06FB6: void llvm::cl::apply<llvm::cl::initializer<char
[5]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [5]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0xC06BEE: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [24], llvm::cl::desc,
llvm::cl::initializer<char [5]>, llvm::cl::OptionHidden>(char const (&)
[24], llvm::cl::desc const&, llvm::cl::initializer<char [5]> const&,
llvm::cl::OptionHidden const&) (CommandLine.h:1195)
==3609== by 0xC06492: __static_initialization_and_destruction_0(int,
int) (PostRASchedulerList.cpp:66)
==3609== by 0xC06624: global constructors keyed to
PostRASchedulerList.cpp (PostRASchedulerList.cpp:776)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 29 bytes in 1 blocks are possibly lost in loss record 152 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0xC0722A: void llvm::cl::initializer<char
[5]>::apply<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string>
> >(llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >&)
const (CommandLine.h:290)
==3609== by 0xC071A3: void
llvm::cl::applicator<llvm::cl::initializer<char [5]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [5]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0xC06FB6: void llvm::cl::apply<llvm::cl::initializer<char
[5]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [5]> const&, llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0xFBEDA9: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [21], llvm::cl::initializer<char
[5]>, llvm::cl::OptionHidden, llvm::cl::ValueExpected>(char const (&) [21],
llvm::cl::initializer<char [5]> const&, llvm::cl::OptionHidden const&,
llvm::cl::ValueExpected const&) (CommandLine.h:1195)
==3609== by 0xFBEB5D: __static_initialization_and_destruction_0(int,
int) (GCOVProfiling.cpp:46)
==3609== by 0xFBEBF4: global constructors keyed to GCOVProfiling.cpp
(GCOVProfiling.cpp:855)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 32 bytes in 1 blocks are possibly lost in loss record 199 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x139B32C: llvm::Module::Module(llvm::StringRef,
llvm::LLVMContext&) (Module.cpp:46)
==3609== by 0x12926C1: llvm::getLazyBitcodeModule(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3038)
==3609== by 0x12928B5: llvm::ParseBitcodeFile(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3078)
==3609== by 0x123674D: llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&) (IRReader.cpp:67)
==3609== by 0x1236A0F: llvm::ParseIRFile(std::string const&,
llvm::SMDiagnostic&, llvm::LLVMContext&) (IRReader.cpp:88)
==3609== by 0x84A036: main (opt.cpp:593)
==3609==
==3609== 37 bytes in 1 blocks are possibly lost in loss record 219 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x1132DB0: void llvm::cl::initializer<char
[13]>::apply<llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> > >(llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) const (CommandLine.h:290)
==3609== by 0x11317C9: void
llvm::cl::applicator<llvm::cl::initializer<char [13]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0x1130EB8: void llvm::cl::apply<llvm::cl::initializer<char
[13]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0x11307F9: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [25], llvm::cl::initializer<char
[13]>, llvm::cl::value_desc, llvm::cl::desc, llvm::cl::OptionHidden>(char
const (&) [25], llvm::cl::initializer<char [13]> const&,
llvm::cl::value_desc const&, llvm::cl::desc const&, llvm::cl::OptionHidden
const&) (CommandLine.h:1202)
==3609== by 0x1130663: __static_initialization_and_destruction_0(int,
int) (PathProfileInfo.cpp:32)
==3609== by 0x113070E: global constructors keyed to PathProfileInfo.cpp
(PathProfileInfo.cpp:433)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 37 bytes in 1 blocks are possibly lost in loss record 220 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x1132DB0: void llvm::cl::initializer<char
[13]>::apply<llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> > >(llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) const (CommandLine.h:290)
==3609== by 0x11317C9: void
llvm::cl::applicator<llvm::cl::initializer<char [13]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0x1130EB8: void llvm::cl::apply<llvm::cl::initializer<char
[13]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0x115B6F9: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [18], llvm::cl::initializer<char
[13]>, llvm::cl::value_desc, llvm::cl::desc>(char const (&) [18],
llvm::cl::initializer<char [13]> const&, llvm::cl::value_desc const&,
llvm::cl::desc const&) (CommandLine.h:1195)
==3609== by 0x115B4D9: __static_initialization_and_destruction_0(int,
int) (ProfileInfoLoaderPass.cpp:37)
==3609== by 0x115B5B6: global constructors keyed to
ProfileInfoLoaderPass.cpp (ProfileInfoLoaderPass.cpp:267)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 37 bytes in 1 blocks are possibly lost in loss record 221 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x1132DB0: void llvm::cl::initializer<char
[13]>::apply<llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> > >(llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) const (CommandLine.h:290)
==3609== by 0x11317C9: void
llvm::cl::applicator<llvm::cl::initializer<char [13]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0x1130EB8: void llvm::cl::apply<llvm::cl::initializer<char
[13]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [13]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0x113C091: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [13], llvm::cl::initializer<char
[13]>, llvm::cl::value_desc, llvm::cl::desc>(char const (&) [13],
llvm::cl::initializer<char [13]> const&, llvm::cl::value_desc const&,
llvm::cl::desc const&) (CommandLine.h:1195)
==3609== by 0x113BE9D: __static_initialization_and_destruction_0(int,
int) (ProfileDataLoaderPass.cpp:42)
==3609== by 0x113BF44: global constructors keyed to
ProfileDataLoaderPass.cpp (ProfileDataLoaderPass.cpp:188)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 43 bytes in 1 blocks are possibly lost in loss record 240 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0xBFEB42: void llvm::cl::initializer<char
[19]>::apply<llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> > >(llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) const (CommandLine.h:290)
==3609== by 0xBFE447: void
llvm::cl::applicator<llvm::cl::initializer<char [19]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [19]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0xBFDDBD: void llvm::cl::apply<llvm::cl::initializer<char
[19]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [19]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0xBFD782: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [20], llvm::cl::ValueExpected,
llvm::cl::desc, llvm::cl::value_desc, llvm::cl::initializer<char [19]>
>(char const (&) [20], llvm::cl::ValueExpected const&, llvm::cl::desc
const&, llvm::cl::value_desc const&, llvm::cl::initializer<char [19]>
const&) (CommandLine.h:1203)
==3609== by 0xBFCC53: __static_initialization_and_destruction_0(int,
int) (Passes.cpp:86)
==3609== by 0xBFCD8F: global constructors keyed to Passes.cpp
(Passes.cpp:760)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 49 bytes in 1 blocks are possibly lost in loss record 249 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x84F356: llvm::Module::setTargetTriple(llvm::StringRef)
(Module.h:265)
==3609== by 0x128AD61: llvm::BitcodeReader::ParseModule(bool)
(BitcodeReader.cpp:1613)
==3609== by 0x128C026:
llvm::BitcodeReader::ParseBitcodeInto(llvm::Module*)
(BitcodeReader.cpp:1826)
==3609== by 0x1292712: llvm::getLazyBitcodeModule(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3041)
==3609== by 0x12928B5: llvm::ParseBitcodeFile(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3078)
==3609== by 0x123674D: llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&) (IRReader.cpp:67)
==3609==
==3609== 49 bytes in 1 blocks are possibly lost in loss record 250 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x11CB6F6: llvm::TargetMachine::TargetMachine(llvm::Target
const&, llvm::StringRef, llvm::StringRef, llvm::StringRef,
llvm::TargetOptions const&) (TargetMachine.cpp:58)
==3609== by 0xB960AF:
llvm::LLVMTargetMachine::LLVMTargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions,
llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level)
(LLVMTargetMachine.cpp:70)
==3609== by 0x861341:
llvm::X86TargetMachine::X86TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level, bool) (X86TargetMachine.cpp:85)
==3609== by 0x86119B:
llvm::X86_64TargetMachine::X86_64TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (X86TargetMachine.cpp:71)
==3609== by 0x863564:
llvm::RegisterTargetMachine<llvm::X86_64TargetMachine>::Allocator(llvm::Target
const&, llvm::StringRef, llvm::StringRef, llvm::StringRef,
llvm::TargetOptions const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (TargetRegistry.h:1015)
==3609== by 0x84FA5E: llvm::Target::createTargetMachine(llvm::StringRef,
llvm::StringRef, llvm::StringRef, llvm::TargetOptions const&,
llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level) const
(TargetRegistry.h:340)
==3609==
==3609== 49 bytes in 1 blocks are possibly lost in loss record 251 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x8613AE:
llvm::X86TargetMachine::X86TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level, bool) (X86TargetMachine.cpp:85)
==3609== by 0x86119B:
llvm::X86_64TargetMachine::X86_64TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (X86TargetMachine.cpp:71)
==3609== by 0x863564:
llvm::RegisterTargetMachine<llvm::X86_64TargetMachine>::Allocator(llvm::Target
const&, llvm::StringRef, llvm::StringRef, llvm::StringRef,
llvm::TargetOptions const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (TargetRegistry.h:1015)
==3609== by 0x84FA5E: llvm::Target::createTargetMachine(llvm::StringRef,
llvm::StringRef, llvm::StringRef, llvm::TargetOptions const&,
llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level) const
(TargetRegistry.h:340)
==3609== by 0x849E3C: GetTargetMachine(llvm::Triple) (opt.cpp:548)
==3609== by 0x84A553: main (opt.cpp:658)
==3609==
==3609== 49 bytes in 1 blocks are possibly lost in loss record 252 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x1220A16:
llvm::MCSubtargetInfo::InitMCSubtargetInfo(llvm::StringRef,
llvm::StringRef, llvm::StringRef, llvm::SubtargetFeatureKV const*,
llvm::SubtargetFeatureKV const*, llvm::SubtargetInfoKV const*,
llvm::MCWriteProcResEntry const*, llvm::MCWriteLatencyEntry const*,
llvm::MCReadAdvanceEntry const*, llvm::InstrStage const*, unsigned int
const*, unsigned int const*, unsigned int, unsigned int)
(MCSubtargetInfo.cpp:48)
==3609== by 0x956879:
llvm::X86GenSubtargetInfo::X86GenSubtargetInfo(llvm::StringRef,
llvm::StringRef, llvm::StringRef) (X86GenSubtargetInfo.inc:2102)
==3609== by 0x957FBD: llvm::X86Subtarget::X86Subtarget(std::string
const&, std::string const&, std::string const&, unsigned int, bool)
(X86Subtarget.cpp:483)
==3609== by 0x8613D6:
llvm::X86TargetMachine::X86TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level, bool) (X86TargetMachine.cpp:85)
==3609== by 0x86119B:
llvm::X86_64TargetMachine::X86_64TargetMachine(llvm::Target const&,
llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::TargetOptions
const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (X86TargetMachine.cpp:71)
==3609== by 0x863564:
llvm::RegisterTargetMachine<llvm::X86_64TargetMachine>::Allocator(llvm::Target
const&, llvm::StringRef, llvm::StringRef, llvm::StringRef,
llvm::TargetOptions const&, llvm::Reloc::Model, llvm::CodeModel::Model,
llvm::CodeGenOpt::Level) (TargetRegistry.h:1015)
==3609==
==3609== 50 bytes in 1 blocks are possibly lost in loss record 253 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF32: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x1138894: void llvm::cl::initializer<char
[26]>::apply<llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> > >(llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >&) const (CommandLine.h:290)
==3609== by 0x1137382: void
llvm::cl::applicator<llvm::cl::initializer<char [26]>
>::opt<llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [26]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >&) (CommandLine.h:974)
==3609== by 0x1136AF0: void llvm::cl::apply<llvm::cl::initializer<char
[26]>, llvm::cl::opt<std::string, false, llvm::cl::parser<std::string> >
>(llvm::cl::initializer<char [26]> const&, llvm::cl::opt<std::string,
false, llvm::cl::parser<std::string> >*) (CommandLine.h:1012)
==3609== by 0x1136347: llvm::cl::opt<std::string, false,
llvm::cl::parser<std::string> >::opt<char [27], llvm::cl::initializer<char
[26]>, llvm::cl::value_desc, llvm::cl::desc, llvm::cl::OptionHidden>(char
const (&) [27], llvm::cl::initializer<char [26]> const&,
llvm::cl::value_desc const&, llvm::cl::desc const&, llvm::cl::OptionHidden
const&) (CommandLine.h:1202)
==3609== by 0x1136183: __static_initialization_and_destruction_0(int,
int) (PathProfileVerifier.cpp:54)
==3609== by 0x113621E: global constructors keyed to
PathProfileVerifier.cpp (PathProfileVerifier.cpp:206)
==3609== by 0x1443675: ??? (in /usr/local/bin/opt)
==3609== by 0x83C282: ??? (in /usr/local/bin/opt)
==3609==
==3609== 69 bytes in 1 blocks are possibly lost in loss record 435 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84EC42:
llvm::cl::parser<std::string>::parse(llvm::cl::Option&, llvm::StringRef,
llvm::StringRef, std::string&) (CommandLine.h:878)
==3609== by 0x85D961: llvm::cl::opt<llvm::PluginLoader, false,
llvm::cl::parser<std::string> >::handleOccurrence(unsigned int,
llvm::StringRef, llvm::StringRef) (CommandLine.h:1127)
==3609== by 0x13EFAE6: llvm::cl::Option::addOccurrence(unsigned int,
llvm::StringRef, llvm::StringRef, bool) (CommandLine.cpp:883)
==3609== by 0x13ED212: CommaSeparateAndAddOccurence(llvm::cl::Option*,
unsigned int, llvm::StringRef, llvm::StringRef, bool) (CommandLine.cpp:259)
==3609== by 0x13ED4EC: ProvideOption(llvm::cl::Option*, llvm::StringRef,
llvm::StringRef, int, char const* const*, int&) (CommandLine.cpp:299)
==3609== by 0x13EEFCA: llvm::cl::ParseCommandLineOptions(int, char
const* const*, char const*) (CommandLine.cpp:724)
==3609== by 0x849F96: main (opt.cpp:582)
==3609==
==3609== 170 bytes in 1 blocks are possibly lost in loss record 461 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x125522A: llvm::Module::setDataLayout(llvm::StringRef)
(Module.h:262)
==3609== by 0x128AE35: llvm::BitcodeReader::ParseModule(bool)
(BitcodeReader.cpp:1620)
==3609== by 0x128C026:
llvm::BitcodeReader::ParseBitcodeInto(llvm::Module*)
(BitcodeReader.cpp:1826)
==3609== by 0x1292712: llvm::getLazyBitcodeModule(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3041)
==3609== by 0x12928B5: llvm::ParseBitcodeFile(llvm::MemoryBuffer*,
llvm::LLVMContext&, std::string*) (BitcodeReader.cpp:3078)
==3609== by 0x123674D: llvm::ParseIR(llvm::MemoryBuffer*,
llvm::SMDiagnostic&, llvm::LLVMContext&) (IRReader.cpp:67)
==3609==
==3609== 208 bytes in 7 blocks are possibly lost in loss record 467 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x12B9552:
llvm::StringAttributeEntry::StringAttributeEntry(llvm::StringRef,
llvm::StringRef) (AttributeImpl.h:87)
==3609== by 0x12B56C0:
llvm::AttributeImpl::AttributeImpl(llvm::LLVMContext&, llvm::StringRef,
llvm::StringRef) (Attributes.cpp:288)
==3609== by 0x12B4048: llvm::Attribute::get(llvm::LLVMContext&,
llvm::StringRef, llvm::StringRef) (Attributes.cpp:68)
==3609== by 0x12B6BA4: llvm::AttributeSet::get(llvm::LLVMContext&,
unsigned int, llvm::AttrBuilder&) (Attributes.cpp:619)
==3609== by 0x12856AC: llvm::BitcodeReader::ParseAttributeGroupBlock()
(BitcodeReader.cpp:577)
==3609== by 0x128A9D0: llvm::BitcodeReader::ParseModule(bool)
(BitcodeReader.cpp:1534)
==3609==
==3609== 302 bytes in 7 blocks are possibly lost in loss record 471 of 535
==3609== at 0x4A075BC: operator new(unsigned long)
(vg_replace_malloc.c:298)
==3609== by 0x33B2A9C3C8: std::string::_Rep::_S_create(unsigned long,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CDE4: ??? (in /usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x33B2A9CF6A: std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
unsigned long, std::allocator<char> const&) (in
/usr/lib64/libstdc++.so.6.0.13)
==3609== by 0x84D7CF: llvm::StringRef::str() const (StringRef.h:183)
==3609== by 0x84D80D: llvm::StringRef::operator std::string() const
(StringRef.h:200)
==3609== by 0x12B953B:
llvm::StringAttributeEntry::StringAttributeEntry(llvm::StringRef,
llvm::StringRef) (AttributeImpl.h:87)
==3609== by 0x12B56C0:
llvm::AttributeImpl::AttributeImpl(llvm::LLVMContext&, llvm::StringRef,
llvm::StringRef) (Attributes.cpp:288)
==3609== by 0x12B4048: llvm::Attribute::get(llvm::LLVMContext&,
llvm::StringRef, llvm::StringRef) (Attributes.cpp:68)
==3609== by 0x12B6BA4: llvm::AttributeSet::get(llvm::LLVMContext&,
unsigned int, llvm::AttrBuilder&) (Attributes.cpp:619)
==3609== by 0x12856AC: llvm::BitcodeReader::ParseAttributeGroupBlock()
(BitcodeReader.cpp:577)
==3609== by 0x128A9D0: llvm::BitcodeReader::ParseModule(bool)
(BitcodeReader.cpp:1534)
==3609==
==3609== LEAK SUMMARY:
==3609== definitely lost: 0 bytes in 0 blocks
==3609== indirectly lost: 0 bytes in 0 blocks
==3609== possibly lost: 1,317 bytes in 31 blocks
==3609== still reachable: 199,418 bytes in 543 blocks
==3609== suppressed: 0 bytes in 0 blocks
==3609== Reachable blocks (those to which a pointer was found) are not
shown.
==3609== To see them, rerun with: --leak-check=full --show-reachable=yes
==3609==
==3609== For counts of detected and suppressed errors, rerun with: -v
==3609== ERROR SUMMARY: 19 errors from 19 contexts (suppressed: 6 from 6)
There seems no invalid memory access.
Do you think that maybe the error is based on not the latest llvm version?
or is it a llvm bug? thanks.
> Nick
>
>
> 0 opt 0x00000000014190b6
>> llvm::sys::PrintStackTrace(_**IO_FILE*) + 38
>> 1 opt 0x0000000001419333
>> 2 opt 0x0000000001418d8b
>> 3 libpthread.so.0 0x0000003aa600f500
>> 4 libc.so.6 0x0000003aa5c328a5 gsignal + 53
>> 5 libc.so.6 0x0000003aa5c34085 abort + 373
>> 6 opt 0x000000000140089b
>> 7 LLVMHello.so 0x00007f889beb5833
>> 8 LLVMHello.so 0x00007f889beb57bd
>> 9 LLVMHello.so 0x00007f889beb575e
>> 10 LLVMHello.so 0x00007f889beb56c5
>> 11 LLVMHello.so 0x00007f889beb55f2
>> 12 LLVMHello.so 0x00007f889beb5401
>> 13 opt 0x00000000013a4e21
>> llvm::FPPassManager::**runOnFunction(llvm::Function&) + 393
>> 14 opt 0x00000000013a5021
>> llvm::FPPassManager::**runOnModule(llvm::Module&) + 89
>> 15 opt 0x00000000013a5399
>> llvm::MPPassManager::**runOnModule(llvm::Module&) + 573
>> 16 opt 0x00000000013a59a8
>> llvm::PassManagerImpl::run(**llvm::Module&) + 254
>> 17 opt 0x00000000013a5bbf
>> llvm::PassManager::run(llvm::**Module&) + 39
>> 18 opt 0x000000000084b455 main + 5591
>> 19 libc.so.6 0x0000003aa5c1ecdd __libc_start_main + 253
>> 20 opt 0x000000000083d359
>> Stack dump:
>> 0. Program arguments: opt -load
>> ../build_llvm/Debug+Asserts/**lib/LLVMHello.so -hello
>> 1. Running pass 'Function Pass Manager' on module '<stdin>'.
>> 2. Running pass 'Hello Pass' on function '@main'
>>
>> I will illustrate the pass code, the test1 example, and the IR generated
>> below, so that anyone could help me or give me some suggestion. Thanks.
>>
>> The Hello.cpp pass is as the following:
>>
>> #define DEBUG_TYPE"hello"
>> #include"llvm/Pass.h"
>> #include"llvm/IR/Module.h"
>> #include"llvm/InstVisitor.h"
>> #include"llvm/IR/Constants.h"
>> #include"llvm/IR/IRBuilder.h"
>> #include"llvm/Support/raw_**ostream.h"
>> namespace {
>>
>> struct Hello : public llvm::FunctionPass, llvm::InstVisitor<Hello> {
>> private:
>> llvm::BasicBlock *FailBB;
>> public:
>> static char ID;
>> Hello() : llvm::FunctionPass(ID) {FailBB = 0;}
>>
>>
>> virtual bool runOnFunction(llvm::Function&**F) {
>>
>> visit(F);
>> return false;
>> }
>>
>> llvm::BasicBlock *getTrapBB(llvm::Instruction&**Inst) {
>>
>> if (FailBB) return FailBB;
>> llvm::Function *Fn = Inst.getParent()->getParent();
>>
>> llvm::LLVMContext& ctx = Fn->getContext();
>> llvm::IRBuilder<> builder(ctx);
>>
>
> You don't seem to ever use this builder?
>
>
>> FailBB = llvm::BasicBlock::Create(ctx,"**FailBlock", Fn);
>> llvm::ReturnInst::Create(Fn->**getContext(), FailBB);
>> return FailBB;
>>
>> }
>> void visitLoadInst(llvm::LoadInst& LI) {
>> }
>>
>> void visitStoreInst(llvm::**StoreInst& SI) {
>>
>> llvm::Value * Addr = SI.getOperand(1);
>> llvm::PointerType* PTy = llvm::cast<llvm::PointerType>(**
>> Addr->getType());
>> llvm::Type * ElTy = PTy -> getElementType();
>> if (!ElTy->isPointerTy()) {
>> llvm::BasicBlock *OldBB = SI.getParent();
>> llvm::errs()<< "yes, got it \n";
>> llvm::ICmpInst *Cmp = new llvm::ICmpInst(&SI,
>> llvm::CmpInst::ICMP_EQ, Addr, llvm::Constant::getNullValue(**
>> Addr->getType()),"");
>>
>> llvm::Instruction *Iter =&SI;
>> OldBB->getParent()->dump();
>> llvm::BasicBlock *NewBB = OldBB->splitBasicBlock(Iter,"**
>> newBlock");
>> OldBB->getParent()->dump();
>>
>> }
>>
>> }
>> };
>>
>> char Hello::ID = 0;
>> static llvm::RegisterPass<Hello> X("hello","Hello Pass", false,
>> false);
>> }
>>
>> The test1.c example is as the following:
>>
>> #include<stdio.h>
>> void main() {
>> int x;
>> x = 5;
>> }
>>
>> The IR for the example after adding the pass is as the following:
>> define void @main() #0 {
>> entry:
>> %x = alloca i32, align 4
>> %0 = icmp eq i32* %x, null
>> br label %newBlock
>>
>> newBlock: ; preds = %entry
>> store i32 5, i32* %x, align 4
>> ret void
>> }
>>
>>
>> any suggestion?
>>
>>
>> ______________________________**_________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130706/83067b99/attachment.html>
More information about the llvm-dev
mailing list