2012-02-23 2 views
2

J'ai un code IR LLVM qui ressemble à ceci.Quel est le problème avec ce code IR LLVM

%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 
    .............. 

Dans la ligne où arrayidx1 est attribué, tout va bien, mais pour OldFuncCounter7, le compilateur LLVM se plaint en disant « utilisation invalide du nom de la fonction locale ». C'est dû au% 8 que j'utilise. Si je le remplace par une constante, ça fonctionne bien. Donc ma question est pourquoi est ce% 8 fonctionne bien avec arrayidx1, mais pas avec OldFuncCounter7. Qu'est-ce qui se passe ici?

Le bloc de base tout où cette erreur se produit est indiquée ci-dessous

%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 
+1

peut vous coller un module minimal mais complet qui produit ce problème? –

+0

Eli, maintenant j'ai ajouté tout le bloc de base. – pythonic

Répondre

3

Vous utilisez %8 à partir d'un constant expression, mais ce n'est pas une constante. Vous devez corriger votre code pour effectuer l'instruction getelementptr en dehors d'une expression constante:

%temp = getelementptr inbounds [16 x i64]* @EdgeProfCounters, i64 0, i64 %8 
%OldFuncCounter7 = load i64* %temp