Ollvm 适配 llvm10,平坦化功能不支持

ollvm 适配 llvm10 后,发现不支持平坦化功能,开启平坦化后,编译代码出现以下崩溃日志:

0  clang                    0x000000010d811683 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  clang                    0x000000010d81116e llvm::sys::CleanupOnSignal(unsigned long) + 185
2  clang                    0x000000010d7a07d5 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 97
3  clang                    0x000000010d7a0943 CrashRecoverySignalHandler(int) + 134
4  libsystem_platform.dylib 0x00007fff7165a5fd _sigtramp + 29
5  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338613676576
6  clang                    0x000000010e17decb (anonymous namespace)::Flattening::runOnFunction(llvm::Function&) + 195
7  clang                    0x000000010d3c0d8f llvm::FPPassManager::runOnFunction(llvm::Function&) + 481
8  clang                    0x000000010d3c0f98 llvm::FPPassManager::runOnModule(llvm::Module&) + 52
9  clang                    0x000000010d3c12fa llvm::legacy::PassManagerImpl::run(llvm::Module&) + 656
10 clang                    0x000000010d972654 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) + 11286
11 clang                    0x000000010db4be1c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1044
12 clang                    0x000000010e58cbf2 clang::ParseAST(clang::Sema&, bool, bool) + 549
13 clang                    0x000000010dd038fd clang::FrontendAction::Execute() + 75
14 clang                    0x000000010dccedba clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 958
15 clang                    0x000000010dd4c988 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1248
16 clang                    0x000000010c630f41 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1749
17 clang                    0x000000010c6301f2 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 300
18 clang                    0x000000010dc08ef1 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const::$_1>(long) + 23
19 clang                    0x000000010d7a0758 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 218
20 clang                    0x000000010dc08731 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const + 235
21 clang                    0x000000010dbecec6 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const + 536
22 clang                    0x000000010dbecfdb clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const + 95
23 clang                    0x000000010dbf9804 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) + 210
24 clang                    0x000000010c62fe2c main + 7358
25 libdyld.dylib            0x00007fff71461cc9 start + 1
clang-10: error: clang frontend command failed due to signal (use -v to see invocation)

调试 Flattening pass 源码发现会在 lower->runOnFunction(*f); 处崩溃。

bool Obfusca::flatten(Function *f) {
  ...
  // Lower switch
  FunctionPass *lower = createLowerSwitchPass();
  lower->runOnFunction(*f);
  ...

张总19年12月有发现这个问题 [llvm-dev] Calling LowerSwitchPass causing crash in llvm 9

请问大佬们是怎么解决这个问题的?

找到大佬适配的资料

PPT:上手 OLLVM : Porting to LLVM 10
视频: 20191123上海线下聚会HelloGCC&LLVM:AArch64编译优化、ollvm移植等

好像可以,我试试😂

Reschedule一下Pass Pipeline就好了,Issue里我有写英文的解决方案