我有以下LLVM IR方案:LLVM的-globalopt通不优化的全局变量
@test1 = global i32 3, align 4
@test2 = common global i32 0, align 4
; Function Attrs: nounwind uwtable
define i32 @main() #0 {
store i32 4, i32* @test2, align 4
%1 = load i32* @test1, align 4
ret i32 %1
}
当我使用选择(3.3版)与-globalopt
运行通过位码保持不变。不过,我预计@test1
被标记为constant和@test2
淘汰,因为该程序只存储到@test2
。
我是否必须在某些分析阶段之前运行opt,或者为什么该阶段未按预期执行?