【发布时间】:2016-09-26 11:11:05
【问题描述】:
从这个简单的 C 程序开始:
void nothing(void) {}
int main() {
int i;
for (i = 0; i < 10; ++i) {
nothing();
}
return 0;
}
我的通行证输出如下:
注意:IR 语句为绿色。
; Function Attrs: nounwind readnone ssp uwtable
define void @nothing() #0 {
entry:
ret void
}
; Function Attrs: nounwind readnone ssp uwtable
define i32 @main() #0 {
entry:
ret i32 0
}
问题:使用被认为是最高级别优化的O3,为什么nothing函数没有作为死代码被淘汰?
【问题讨论】:
-
nothing是从生成的.obj文件中导出的,因此无法消除。 -
@PetSerAl,对不起,我不明白,“从生成的 .obj 文件中导出”
标签: c clang llvm-clang llvm-ir llvm-codegen