gpt4 book ai didi

segmentation-fault - getAnalysis() 上的 LLVM 传递段错误

转载 作者:行者123 更新时间:2023-12-04 12:41:52 27 4
gpt4 key购买 nike

我正在尝试为我需要支配树的 LLVM 3.2 优化器构建一个 channel 。这应该很容易通过请求 DominatorTree 来实现。来自 PassManager 的分析结果,但即使是这个简单的例子也会崩溃。

我究竟做错了什么?

namespace {
struct Mypass : public FunctionPass {
static char ID;

Mypass() : FunctionPass(ID) { }

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<DominatorTree>();
}

virtual bool runOnFunction(Function &F) {
DominatorTree& DT = getAnalysis<DominatorTree>(F);
return false;
}
};
}

char Mypass::ID = 0;
static RegisterPass<Mypass> X("mypass", "My test analysis", true, true);

当用
opt --load mypass.so -mypass --debug-pass=Structure test.bc
它立即与
Pass Arguments:  -targetlibinfo -datalayout -domtree -mypass -preverify -domtree -verify
Target Library Information
Data Layout
ModulePass Manager
FunctionPass Manager
Dominator Tree Construction
My test analysis
Preliminary module verification
Dominator Tree Construction
Module Verifier
0 libLLVM-3.2.so.1 0x00007f2d8172a1df
1 libLLVM-3.2.so.1 0x00007f2d8172a649
2 libpthread.so.0 0x00007f2d80842bd0
3 mypass.so 0x00007f2d7f63deb9 llvm::DominatorTree& llvm::Pass::getAnalysisID<llvm::DominatorTree>(void const*, llvm::Function&) + 217
4 mypass.so 0x00007f2d7f63ddce llvm::DominatorTree& llvm::Pass::getAnalysis<llvm::DominatorTree>(llvm::Function&) + 94
5 mypass.so 0x00007f2d7f63dc38
6 libLLVM-3.2.so.1 0x00007f2d811e0e3f llvm::FPPassManager::runOnFunction(llvm::Function&) + 575
7 libLLVM-3.2.so.1 0x00007f2d811e0e83 llvm::FPPassManager::runOnModule(llvm::Module&) + 51
8 libLLVM-3.2.so.1 0x00007f2d811e0ba4 llvm::MPPassManager::runOnModule(llvm::Module&) + 484
9 libLLVM-3.2.so.1 0x00007f2d811e44bb llvm::PassManagerImpl::run(llvm::Module&) + 107
10 opt 0x000000000040d606 main + 4230
11 libc.so.6 0x00007f2d80189ea5 __libc_start_main + 245
12 opt 0x000000000040db41
Stack dump:
0. Program arguments: opt --load mypass.so -mypass --debug-pass=Structure
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'My test analysis' on function '@const_expr'
Segmentation fault (core dumped)

最佳答案

更改 DominatorTree& DT = getAnalysis<DominatorTree>(F);DominatorTree& DT = getAnalysis<DominatorTree>();似乎工作。

关于segmentation-fault - getAnalysis<DominatorTree>() 上的 LLVM 传递段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14799127/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com