Need Some Help!

I have a "first version" of Stacker up and running. Structurally its a
lot like llvm-as. When I run it, I get:

Leaked objects found: after running pass 'Function Pass Manager'
  LLVM Value subclasses leaked:

Note that the supposed list of "LLVM Value subclasses leaked" is empty.
Its followed up by a SIGSEGV at AsmWriter.cpp:754 presumably because I
have a BasicBlock object not assigned to a Function.

Is the message above attempting to tell me this?

What I can't figure out is where the message comes from and why.

Reid.

I have a "first version" of Stacker up and running. Structurally its a
lot like llvm-as. When I run it, I get:
Leaked objects found: after running pass 'Function Pass Manager'
  LLVM Value subclasses leaked:

This is coming from the LLVM "LeakDetector" stuff. The idea is that you
are not supposed to create random instructions or basic blocks, then leave
them hanging around: you should put them into a module somewhere. :slight_smile:

Note that the supposed list of "LLVM Value subclasses leaked" is empty.
Its followed up by a SIGSEGV at AsmWriter.cpp:754 presumably because I
have a BasicBlock object not assigned to a Function.
Is the message above attempting to tell me this?

Yeah well, it's trying but failing. It's attempting to print out the
thing that has been leaked, but the asmwriter isn't handling the "broken"
LLVM IR very well. :frowning:

What I can't figure out is where the message comes from and why.

Basically it's because a BasicBlock has not be inserted into a function.
If you want to FORCE this to be acceptable, use the
LeakDetector::removeGarbageObject method in Support/LeakDetector.h

This is yet another "helpful" LLVM debugging tool, pointing out a silly
bug. :slight_smile:

-Chris

> I have a "first version" of Stacker up and running. Structurally its a
> lot like llvm-as. When I run it, I get:
> Leaked objects found: after running pass 'Function Pass Manager'
> LLVM Value subclasses leaked:

This is coming from the LLVM "LeakDetector" stuff. The idea is that you
are not supposed to create random instructions or basic blocks, then leave
them hanging around: you should put them into a module somewhere. :slight_smile:

Right. Haven't written that part yet :slight_smile:

> Note that the supposed list of "LLVM Value subclasses leaked" is empty.
> Its followed up by a SIGSEGV at AsmWriter.cpp:754 presumably because I
> have a BasicBlock object not assigned to a Function.
> Is the message above attempting to tell me this?

Yeah well, it's trying but failing. It's attempting to print out the
thing that has been leaked, but the asmwriter isn't handling the "broken"
LLVM IR very well. :frowning:

I actually have a patch for this. AsmWriter is calling
BB->getParent()->xyz without checking that the call to getParent()
doesn't return null. I just put in the check and made it print out
something when it finds that case. The patch is attached.

> What I can't figure out is where the message comes from and why.

Basically it's because a BasicBlock has not be inserted into a function.
If you want to FORCE this to be acceptable, use the
LeakDetector::removeGarbageObject method in Support/LeakDetector.h

This is yet another "helpful" LLVM debugging tool, pointing out a silly
bug. :slight_smile:

Cool! It surprised me, but I like this.

Reid.

patch.txt (1.55 KB)