[LLVMdev] hello world error
Ankit Sethia
asethia at eecs.umich.edu
Wed Jun 29 13:25:39 PDT 2011
Hi,
Can people suggest how this is solved for other ISAs? This happens only for
Alpha and not for x86-64. The register 16 does not have any uses within that
function, but is used inside puts. So Machine DCE thinks it is dead code.
On Wed, Jun 29, 2011 at 4:20 PM, Ankit Sethia <asethia at eecs.umich.edu>wrote:
> Hi,
>
> I found that machine dead code elimination, does not respect the calling
> convention of alpha and eliminates r16, which was set correctly during code
> generation. I verified it with -print-after-all.
> Does anybody have a patch for this?
>
> On Wed, Jun 29, 2011 at 11:12 AM, Ankit Sethia <asethia at eecs.umich.edu>wrote:
>
>> Hi All,
>>
>> I am using llvm-2.9 to cross compile to alpha. I know that alpha is in
>> experimental stage, but i can not get even the "Hello World" program to run
>> on it.
>>
>> Here is what happens, the bitcode file for the hello world program is as
>> follow:
>>
>> ; ModuleID = 'hello.bc'
>> target datalayout =
>> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
>> target triple = "x86_64-unknown-linux-gnu"
>>
>> @.str = private constant [12 x i8] c"Hello World\00", align 1
>>
>> define i32 @main() nounwind {
>> entry:
>> %retval = alloca i32
>> %0 = alloca i32
>> %"alloca point" = bitcast i32 0 to i32
>> *%1 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64
>> 0, i64 0)) nounwind*
>> store i32 0, i32* %0, align 4
>> %2 = load i32* %0, align 4
>> store i32 %2, i32* %retval, align 4
>> br label %return
>>
>> return: ; preds = %entry
>> %retval1 = load i32* %retval
>> ret i32 %retval1
>> }
>>
>> declare i32 @puts(i8*)
>>
>> The .str is present in the argument to the puts function in %1 is present
>> in the bitcode.
>> But when i use llc to change the bitcode to alpha assembly, i get the
>> following:
>>
>>
>> ldah $29,0($27) !gpdisp!1
>> lda $29,0($29) !gpdisp!1
>> $main..ng:
>> lda $30,-32($30)
>> stq $9,24($30)
>> stq $11,16($30)
>> bis $26,$26,$9
>> * ldq $27,puts($29) * !literal
>> lda $11,8($30)
>> jsr $26,($27),0
>>
>>
>> The puts call is there, but register 16 which i believe is supposed to
>> have the arguments to a function call is not set.
>> If i manually add the line to the assembly,
>>
>> lda $16, $.str($29)
>>
>> where $.str is defined in the assembly to be the appropriate string, it
>> works fine, and i get the hello world output.
>> It seems that for some reason llc is not setting the argument of the
>> function call.
>>
>> Are there any tests for alpha assembly that presently work with function
>> call? I would like to confirm that something with alpha is working.
>>
>>
>>
>>
>> --
>> Ankit
>>
>
>
>
> --
> Ankit
>
--
Ankit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110629/1630c635/attachment.html>
More information about the llvm-dev
mailing list