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

Trevor Harmon trevor.w.harmon at nasa.gov
Fri Jul 16 15:20:57 PDT 2010


Hi,

I'm trying to use CallGraphSCCPass, but I keep getting a bus error. I  
can reproduce the problem quite easily using the lib/Transforms/Hello  
example. I simply mix in these changes:

#include "llvm/CallGraphSCCPass.h"
...
   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();
         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




More information about the llvm-dev mailing list