Converting a clang -cc1 invocation into an llc invocation

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

Converting a clang -cc1 invocation into an llc invocation

Edmund Grimley Evans
I've been compiling programs by invoking clang -cc1 like this:

clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c -S

I encounter an interesting problem that I want to investigate by looking
at the SelectionDAGs. However, clang -cc1 doesn't accept the
-view-legalize-dags option that llc accepts. What should I do?

I notice that (strings `which clang` | grep view-legalize-dags), so is
there a way of giving that argument to clang -cc1?

Alternatively, is there a way of converting the clang -cc1 invocation
into an llc invocation that will give exactly the same behaviour so that
I can do the following?

clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c
-emit-llvm-bc
llc t.bc ... -view-legalize-dags






--
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Converting a clang -cc1 invocation into an llc invocation

Charles Davis-3
On 3/12/10 9:50 AM, Edmund Grimley Evans wrote:
> clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c
> -emit-llvm-bc
> llc t.bc ... -view-legalize-dags
You just answered your own question :). That will work quite nicely
actually.

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

Re: Converting a clang -cc1 invocation into an llc invocation

Charles Davis-3
You forgot to reply to the list. Also CC'ing LLVMdev.

On 3/12/10 1:41 PM, Edmund Grimley-Evans wrote:
>>> clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c
>>> -emit-llvm-bc
>>> llc t.bc ... -view-legalize-dags
>> You just answered your own question :). That will work quite nicely
>> actually.
>
> Maybe it would if I knew exactly what to put instead of "...". I can't use the same options as with clang -cc1 as they are not recognised. If I put nothing I won't even be targeting the same architecture.
Oh sorry, I didn't notice that '...'. (Silly me...)

You can use -mtriple to specify the target triple to llc, and -mcpu to
specify the CPU type:
llc t.bc -mtriple=thumbv7-eabi -mcpu=cortex-a8 -view-legalize-dags

Of course, specifying the triple shouldn't be necessary, since Clang
encodes that information into the BC file. If you disassembled the BC
file into human-readable IR, you'd see something like this at the top:

target triple thumbv7-eabi

so you should only have to specify the CPU type with -mcpu.

Hope that helps.

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

Re: Converting a clang -cc1 invocation into an llc invocation

Daniel Dunbar
In reply to this post by Edmund Grimley Evans
Hi Edmund,

Chip answered this, mostly, but there are some subtle details in how
llc is invoked that aren't always obvious. For example, depending on
the exact arguments to Clang you may need to pass -O0 to llc, or
-mcpu, or target attrs, or the relocation model, or -disable-fp-elim,
etc. Unfortunately there is currently no easy way to get the exact
invocation.

My plan is to eventually extend the Clang driver to support this
directly to solve this problem.

 - Daniel

On Fri, Mar 12, 2010 at 8:50 AM, Edmund Grimley Evans
<[hidden email]> wrote:

> I've been compiling programs by invoking clang -cc1 like this:
>
> clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c -S
>
> I encounter an interesting problem that I want to investigate by looking
> at the SelectionDAGs. However, clang -cc1 doesn't accept the
> -view-legalize-dags option that llc accepts. What should I do?
>
> I notice that (strings `which clang` | grep view-legalize-dags), so is
> there a way of giving that argument to clang -cc1?
>
> Alternatively, is there a way of converting the clang -cc1 invocation
> into an llc invocation that will give exactly the same behaviour so that
> I can do the following?
>
> clang -cc1 -triple thumbv7-eabi -O3 -target-cpu cortex-a8 t.c
> -emit-llvm-bc
> llc t.bc ... -view-legalize-dags
>
>
>
>
>
>
> --
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

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