[LLVMdev] Function::getName in CallGraphSCCPass causes bus error

Duncan Sands baldrick at free.fr
Mon Jul 19 04:55:16 PDT 2010


Hi Trevor,

>     struct Hello : public CallGraphSCCPass {
>       static char ID; // Pass identification, replacement for typeid
>       Hello() : CallGraphSCCPass(&ID) {}
>       virtual bool runOnSCC(std::vector<CallGraphNode *>  &SCC) {
>           CallGraphNode *node = SCC.front();
>           Function *function = node->getFunction();
>           StringRef str = function->getName();

maybe function is NULL?  This is the case for the "external node".

Ciao,

Duncan.

>           return false;
>       }
>     };
>
> And when I run the pass with opt, I get:
>
> 0  libLLVM-2.7.dylib 0xe0b33d28
> llvm::sys::RWMutexImpl::writer_release() + 424
> 1  libLLVM-2.7.dylib 0xe0b34607
> llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) +
> 1143
> 2  libSystem.B.dylib 0x002632bb _sigtramp + 43
> 3  libSystem.B.dylib 0xffffffff _sigtramp + 18446744073707048303
> 4  LLVMHello.dylib   0x0002eba8 (anonymous
> namespace)::Hello::runOnSCC(std::vector<llvm::CallGraphNode*,
> std::allocator<llvm::CallGraphNode*>  >&) + 24
> 5  libLLVM-2.7.dylib 0xe0cbff44 (anonymous
> namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*,
> std::vector<llvm::CallGraphNode*, std::allocator<llvm::CallGraphNode*>
>   >&, llvm::CallGraph&, bool&) + 340
> 6  libLLVM-2.7.dylib 0xe0cc07b2 (anonymous
> namespace)::CGPassManager::runOnModule(llvm::Module&) + 770
> 7  libLLVM-2.7.dylib 0xe055597d
> llvm::MPPassManager::runOnModule(llvm::Module&) + 477
> 8  libLLVM-2.7.dylib 0xe0555b54
> llvm::PassManagerImpl::run(llvm::Module&) + 148
> 9  libLLVM-2.7.dylib 0xe0555bfb llvm::PassManager::run(llvm::Module&)
> + 27
> 10 opt               0x0000dbbe main + 3566
> 11 opt               0x000022d6 start + 54
> Stack dump:
> 0.	Program arguments: ../../../Release/bin/opt -load ../../../Release/
> lib/LLVMHello.dylib -hello
> 1.	Running pass 'CallGraph Pass Manager' on module '<stdin>'.
> Bus error
>
> Removing the function->getName() statement causes the error to go away.
>
> This is with the stock LLVM 2.7 release on Mac OS X 10.5.8.
>
> Am I doing something wrong, or is this a bug in LLVM? Thanks,
>
> Trevor
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list