LLVM 插桩 LLVM IR LandingPadInst Invoke 指令

刚刚遇到的报错如下:

The unwind destination does not have an exception handling instruction!
  %170 = invoke noundef ptr @_ZN6icu_668TimeZone14createTimeZoneERKNS_13UnicodeStringE(ptr noundef nonnull align 8 dereferenceable(64) %8)
          to label %171 unwind label %253, !dbg !2355
The unwind destination does not have an exception handling instruction!
  %181 = invoke noundef nonnull align 8 dereferenceable(72) ptr @_ZN6icu_668TimeZone10getUnknownEv()
          to label %182 unwind label %253, !dbg !2356
The unwind destination does not have an exception handling instruction!
  %195 = invoke noundef signext i8 %194(ptr noundef nonnull align 8 dereferenceable(72) %170, ptr noundef nonnull align 8 dereferenceable(72) %181)
          to label %196 unwind label %253, !dbg !2358
The unwind destination does not have an exception handling instruction!
  %217 = invoke i64 (ptr, i64, ptr, ...) @zend_spprintf(ptr noundef nonnull %7, i64 noundef 0, ptr noundef nonnull @.str.2, ptr noundef %4, ptr noundef %160)
          to label %218 unwind label %253, !dbg !2363
The unwind destination does not have an exception handling instruction!
  invoke void @intl_errors_set(ptr noundef %3, i32 noundef 1, ptr noundef %228, i32 noundef 1)
          to label %229 unwind label %253, !dbg !2366
The unwind destination does not have an exception handling instruction!
  invoke void @_efree(ptr noundef %239)
          to label %240 unwind label %253, !dbg !2367
LandingPadInst not the first non-PHI instruction in the block.
  %254 = landingpad { ptr, i32 }
          cleanup, !dbg !2370
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc-17 -filetype=obj ext/intl/common/common_date.o -o ext/intl/common/common_date.o
 #0 0x00007f8f72562ce6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccbce6)
 #1 0x00007f8f72560e80 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcc9e80)
 #2 0x00007f8f72563380 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xccc380)
 #3 0x00007f8f7186b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f8f712c600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f8f712a5859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f8f724c534c llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc2e34c)
 #7 0x00007f8f724c5176 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc2e176)
 #8 0x00007f8f725aa8de (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xd138de)
 #9 0x00007f8f752acc7e llvm::LLParser::validateEndOfModule(bool) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3a15c7e)
#10 0x00007f8f752abda9 llvm::LLParser::Run(bool, llvm::function_ref<std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (llvm::StringRef, llvm::StringRef)>) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3a14da9)
#11 0x00007f8f752ea25b (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3a5325b)
#12 0x00007f8f752ea3f9 llvm::parseAssembly(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*, llvm::function_ref<std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (llvm::StringRef, llvm::StringRef)>) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x3a533f9)
#13 0x00007f8f727694da llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::ParserCallbacks) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xed24da)
#14 0x00007f8f727698ac llvm::parseIRFile(llvm::StringRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::ParserCallbacks) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xed28ac)
#15 0x000055769b4b6e17 main (/usr/lib/llvm-17/bin/llc+0xfe17)
#16 0x00007f8f712a7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#17 0x000055769b4b32be _start (/usr/lib/llvm-17/bin/llc+0xc2be)
fish: “llc-17 -filetype=obj ext/intl/c…” terminated by signal SIGABRT (Abort)

根据 CHATGPT4

这个错误信息表明你的 LLVM IR(中间表示)代码中存在一些问题,主要与异常处理有关。
具体来说,这个错误提示是在使用 invoke 指令时出现的,该指令用于调用可能抛出异常的函数。
如果调用的函数抛出了异常,控制权会转移到 unwind label 指定的标签。
但是,你的代码中指定的 unwind 目的地(标签 %253)缺少必要的异常处理指令。

LandingPadInst not the first non-PHI instruction in the block 是另一个错误,
表明 landingpad 指令没有放在基本块的开始位置,或者没有紧跟在 PHI 指令之后。
landingpad 指令是用来处理异常的,它应该是基本块中第一个非 PHI 指令。

为了解决这些问题,你需要确保:

1.异常处理指令存在:检查 %253 标签所在的基本块是否包含了正确的异常处理指令,比如 landingpad 指令。
如果不存在,你需要添加适当的异常处理逻辑。

2.landingpad 指令位置正确:确保每个使用 invoke 指令的基本块的 unwind 目的地都有一个 landingpad 指令,
并且它是第一个非 PHI 指令(如果有 PHI 指令的话)。

3.你可以调整 LLVM IR 代码,确保每个可能抛出异常的 invoke 指令后都有正确配置的异常处理。
如果需要更具体的帮助来修改代码,你可以分享相关的基本块代码部分,我可以提供更具体的建议。

总结一下,就是说,如果有 LandingPadInst 指令,那么它必须是一个基本块的第一个非phi指令

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值