2
我有一個LLVM IR代碼,看起來像這樣。這個LLVM IR代碼有什麼問題
%8 = load i64* @tid, align 8
%arrayidx1 = getelementptr inbounds [16 x i32]* @h,
i32 0, i64 %8 ;<-- %8 works fine here
..............
%OldFuncCounter7 = load i64* getelementptr inbounds ([16 x i64]*
@EdgeProfCounters, i64 0, i64 %8) ;<-- error here, %8 not allowed
..............
在arrayidx1分配行了,一切都很好,但對於OldFuncCounter7中,LLVM編譯器說「無效的使用功能,本地名」抱怨。這是由於我正在使用%8。如果我用常量替換它,它工作正常。所以我的問題是爲什麼%8可以正常工作arrayidx1,但不能用OldFuncCounter7。這裏發生了什麼?
其中發生該錯誤的整個基本塊下面示出
%8 = load i64* @tid, align 8
%arrayidx1 = getelementptr inbounds [16 x i32]* @h, i32 0, i64 %8
store volatile i32 3, i32* %arrayidx1, align 4
%9 = load volatile i32* getelementptr inbounds ([16 x i32]* @h, i32 0, i64 0), align 4
%call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str, i32 0, i32 0), i32 %9)
%10 = load i64* @tid, align 8
store volatile i64 %10, i64* %clock, align 8
%call3 = call i32 @getpid() nounwind
%call4 = call i64 @pthread_self() nounwind readnone
%11 = load volatile i64* %clock, align 8
%call5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([21 x i8]* @.str1, i32 0, i32 0), i32 %call3, i64 %call4, i64 %11)
store i64 0, i64* %oi, align 8
; Error here due to %8
%OldFuncCounter7 = load i64* getelementptr inbounds ([16 x i64]* @EdgeProfCounters, i64 0, i64 %8)
;
%NewFuncCounter8 = add i64 %OldFuncCounter7, 13
store volatile i64 %NewFuncCounter8, i64* getelementptr inbounds ([16 x i64]* @EdgeProfCounters, i64 0, i64 0)
br label %for.cond6
可以粘貼產生這個問題最小但完整的模塊? – 2012-02-23 13:08:36
Eli,現在我已經添加了整個基本塊。 – pythonic 2012-02-23 13:11:03