0

尝试链接一些 IR 文件时,我遇到了llc的下一个错误:

LLVM ERROR: Cannot select: intrinsic %llvm.objc.clang.arc.use

我发现如果我O0在编译期间禁用了 clang 优化(),则不会弹出错误,但我不想这样做

我附上了如何重现它的示例,只是cd“问题”文件夹并运行“问题.sh”来重现错误。你必须有 Xcode(12.x 首选)你运行它

https://drive.google.com/file/d/1j0TvMZI2A7QxRbv_Q7aydtlNYaiTPYBm/view?usp=sharing

这就是 issue.sh 包含的内容,这是我实际实现的简化版本:

echo "clang..."

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c \
-target arm64-apple-ios12.0 \
-fobjc-arc -fmodules \
-S -Os -flto=thin \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk \
-fembed-bitcode \
-c ${PWD}/GTMSessionFetcher.m \
-o ${PWD}/GTMSessionFetcher.ll

echo "llc..."

${PWD}/llc \
GTMSessionFetcher.ll \
-stats -filetype=obj \
-code-model=small \
-enable-machine-outliner=never \
--mtriple=arm64-apple-ios12.0 \
-o ${PWD}/GTMSessionFetcher.o

正如我之前提到的,如果您更改-Osfor -O0,错误就会消失,但我确实需要尺寸优化。

我包含的 Objective-c 文件是来自 Google 库的 pod 的文件

https://github.com/google/gtm-session-fetcher

我发现了一个类似的问题,但它还没有任何答案 LLVM Error Cannot select intrinsic %llvm.coro.begin

4

1 回答 1

0

我以为是bug,没想到

正如 Akira 在LLVM 错误报告中指出的那样,我能够通过添加带有标志的中间优化器OPT步骤来修复它:-objc-arc-contract

clang
...

<path to your LLVM tools>/OPT \
<Your IR file> \
-objc-arc-contract \
-o <Output file>

llc
...
于 2021-03-25T23:09:59.470 回答