<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I am porting llvm-gcc frontend. We have ported GCC4.2 for our target. So I move *.h *.md and *.c to llvm-gcc. I do not implement any LLVM MACRO, and use default action of llvm-gcc. I get a new llvm-gcc for our target. But I get a bug. <br><br>/******************************/<br>//#include <stdio.h><br>union MYunion {<br> unsigned char uc ;<br> int ui;<br>} myunion;<br><br>void vfu1(union MYunion u) {<br> u.ui = 99;<br>}<br><br>void unions() {<br> myunion.ui = 0;<br> vfu1(myunion);<br> iequals(244, myunion.ui, 0);<br>}<br><br>int iequals( int line, int val1, int val2) {<br> printf("in iequals: line = %d, val1 = %d, val2 = %d\n", line, val1, val2);<br> if(val1 == val2) {<br> printf("val1 ==
val2\n");<br> } else {<br> printf("val1 != val2\n");<br> }<br> return 1;<br>}<br><br>int main() {<br> unions();<br> return 0;<br>}<br>/1. ****************I get IR from my llvm-gcc.*****************************/<br> %struct.MYunion = type { i32 }<br>@myunion = common global %struct.MYunion zeroinitializer ; <%struct.MYunion*> [#uses=2]<br>@.str = internal constant [45 x i8] c"in iequals: line = %d, val1 = %d, val2 = %d\0A\00" ; <[45 x i8]*> [#uses=1]<br>@.str1 = internal constant [13 x i8] c"val1 == val2\00" ; <[13 x i8]*>
[#uses=1]<br>@.str2 = internal constant [13 x i8] c"val1 != val2\00" ; <[13 x i8]*> [#uses=1]<br><br>define void @vfu1(%struct.MYunion* byval align 4 %u) nounwind {<br>entry:<br> %0 = getelementptr %struct.MYunion* %u, i32 0, i32 0 ; <i32*> [#uses=1]<br> store i32 99, i32* %0, align 4<br> br label %return<br><br>return: ; preds = %entry<br> ret void<br>}<br><br>define void @unions() nounwind {<br>entry:<br> store i32 0, i32* getelementptr (%struct.MYunion* @myunion, i32 0, i32 0), align 4<br> call void @vfu1(%struct.MYunion* byval
align 4 @myunion) nounwind<br> %0 = load i32* getelementptr (%struct.MYunion* @myunion, i32 0, i32 0), align 4 ; <i32> [#uses=1]<br> %1 = call i32 (...)* bitcast (i32 (i32, i32, i32)* @iequals to i32 (...)*)(i32 244, i32 %0, i32 0) nounwind ; <i32> [#uses=0]<br> br label %return<br><br>return: ; preds = %entry<br> ret void<br>}<br>/2. ***********After llvm optimize pass. I get *****************/<br>declare i32 @printf(i8*, ...) nounwind<br><br>declare i32 @puts(i8*)<br><br>define i32 @main() nounwind {<br>return:<br> %0 = call i32 (i8*, ...)* @printf(i8* getelementptr
([45 x i8]* @.str, i32 0, i32 0), i32 244, i32 99, i32 0) nounwind ; <i32> [#uses=0]<br> %1 = call i32 @puts(i8* getelementptr ([13 x i8]* @.str2, i32 0, i32 0)) nounwind ; <i32> [#uses=0]<br> ret i32 0<br>}<br>/3. ***********My question*********/<br>It means that function "void vfu1(union MYunion u)" modifies global varible myunion. But llvm-gcc of X86 will not do that. So my llvm-gcc has a bug.<br><br>1) Which function or Macro changes "vfu1" function's arguments type?<br>2) Which Macro of GCC or LLVM does I implement to control this arguments type convert?<br><br><br><br></td></tr></table><br>
<hr size=1><a href="http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/"> 好玩贺卡等你发,邮箱贺卡全新上线!</a>