Clang for ARM Cortex A9

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang for ARM Cortex A9

Kiran V
Hi,
We are facing a strange problem with Clang compiler (latest version) for ARM Cortex A9.
 
When we compile our code using arm-linux-gcc compiler, it compiles perfectly and executes perfectly as well.
When we compile using clang compiler, it compiles but during execution we see certain floating point values overflow. The program still finishes execution but the final output is wrong.
 
However on x86, both Clang and gcc give no errors.
Since the code base is same we suspect that code generation by clang for ARM is not correct.
 
Has anyone else faced this problem? Please kindly suggest any solutions.
 
Thanks and regards,
Kiran.V
 
 

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

John McCall
<base href="x-msg://1263/">
On Jun 27, 2010, at 10:17 PM, Kiran V wrote:
We are facing a strange problem with Clang compiler (latest version) for ARM Cortex A9.
 
When we compile our code using arm-linux-gcc compiler, it compiles perfectly and executes perfectly as well.
When we compile using clang compiler, it compiles but during execution we see certain floating point values overflow. The program still finishes execution but the final output is wrong.
 
However on x86, both Clang and gcc give no errors.
Since the code base is same we suspect that code generation by clang for ARM is not correct.

It's certainly possible.  It's also possible that your code is doing something invalid and the LLVM optimizers are being more aggressive about exploiting it.  If you can provide a test case, we'll look at it.

John.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

Anton Korobeynikov
In reply to this post by Kiran V
Hello

> When we compile using clang compiler, it compiles but during execution we
> see certain floating point values overflow. The program still finishes
> execution but the final output is wrong.
What is the version of binutils you're using?

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

Kiran V
Hi,
Thanks for the reply.
The binutils version I am using is 2.19.1-0ubuntu3.
We managed to work around for this problem.
First we converted C code using clang to llvm byte code (-S -emit-llvm),
then we converted the llvm bytecode to C file using llc.
Then we used arm-linux-gcc to compile the resulted C file. This seems to
work and generated the correct output.

Any other solution is welcome.

regards,
Kiran.V

----- Original Message -----
From: "Anton Korobeynikov" <[hidden email]>
To: "Kiran V" <[hidden email]>
Cc: <[hidden email]>; "RAHUL SURESH" <[hidden email]>
Sent: Monday, June 28, 2010 1:10 PM
Subject: Re: [cfe-dev] Clang for ARM Cortex A9


> Hello
>
>> When we compile using clang compiler, it compiles but during execution we
>> see certain floating point values overflow. The program still finishes
>> execution but the final output is wrong.
> What is the version of binutils you're using?
>
> --
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State University

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

Anton Korobeynikov
Hello

> The binutils version I am using is 2.19.1-0ubuntu3.
This version is known buggy (it encodes "vcvt" instruction improperly,
thus you'll have wrong int <-> float conversion).
You need to use at least 2.20.1 (or anything else which is newer than
of Jan, 2010).

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

Kiran V
Hi,
Can I know why binutils is comming into picture. I will give the detailed
description of what we have done:

We downloaded the clang source code from
http://clang.llvm.org/get_started.html and build clang compiler.
With this clang compiler we try to build the source code using the commands

clang -march=armv7-a -mcpu=cortex-a9 -ccc-host-triple
arm-none-linux -ccc-gcc-name arm-none-linux-gnueabi-gcc  filename.c
(with relevant include and libraries).

To my knowledge binutils will be used  by gcc and not by clang.

regards,
Kiran.V


----- Original Message -----
From: "Anton Korobeynikov" <[hidden email]>
To: "Kiran V" <[hidden email]>
Cc: "John McCall" <[hidden email]>; <[hidden email]>; "RAHUL
SURESH" <[hidden email]>
Sent: Monday, June 28, 2010 3:36 PM
Subject: Re: [cfe-dev] Clang for ARM Cortex A9


> Hello
>
>> The binutils version I am using is 2.19.1-0ubuntu3.
> This version is known buggy (it encodes "vcvt" instruction improperly,
> thus you'll have wrong int <-> float conversion).
> You need to use at least 2.20.1 (or anything else which is newer than
> of Jan, 2010).
>
> --
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State University

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang for ARM Cortex A9

David Chisnall
On 29 Jun 2010, at 12:11, Kiran V wrote:

> Hi,
> Can I know why binutils is comming into picture. I will give the detailed
> description of what we have done:

When you compile with the clang driver, you have several components:

1) clang compiles [Objective-]C[++] code to LLVM IR
2) LLVM optimises this code and converts it to assembly (except on the platforms which have native code generation working)
3) as (from binutils) assembles the assembly into a .o file.
4) ld (from binutils) links these .o files into an executable or shared library.

In this specific case, as Anton said, LLVM is producing the vcvt (vector convert) instruction in the assembly and as is generating the wrong binary encoding of this instruction in the .o.

David
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev