[LLVMdev] It is possible to somehow turn off coercion of struct parameters into ints?

Zvonimir Rakamaric zvonimir at cs.utah.edu
Fri May 16 15:00:04 PDT 2014


Thanks for your help Reid.

After poking around a little (a lot actually) I figured out that
selecting DefaultTargetCodeGenInfo would work for us. And that could
be accomplished by selecting UnknownArch as the target architecture.

Now, I figured our a one line hack that accomplishes that in clang.
What I could not figure out was how to set UnknownArch from the
command line using --target or something like that.

Invoking clang like this:
clang --target=x86_64-unknown-linux-gnu simple.c
is fine.

But for this:
clang --target=unknown-unknown-linux-gnu simple.c

I get an error:
error: unknown target triple 'unknown-unknown-linux-gnu', please use
-triple or -arch

It would really be awesome if UnknownArch could somehow be selected
from the command line. Is that possible? Am I missing something?

Thanks!
-- Zvonimir


--
http://zvonimir.info
http://soarlab.org/


On Fri, May 16, 2014 at 11:22 AM, Reid Kleckner <rnk at google.com> wrote:
> There isn't a flag to do this, but depending on what you need, you can hack
> clang to get it.
>
> Someone else wanted Clang to pass structs directly as LLVM aggregates, but
> that would definitely be an ABI break:
> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036615.html
>
> This might be a reasonable lowering, if it works for you:
>
> struct A { int a; int b; };
> void foo(A x) { }
>
> %struct.A = type { i32, i32 }
> define void @foo(%struct.A* byval %x) {
>   ret void
> }
>
> Something like this would be easy to implement and might even be ABI
> compatible with the integral coercion lowering, but I make no guarantees.
> You'd change TargetInfo.cpp to return ABIArgInfo::getIndirect(0,
> /*ByVal=*/true) for every record that is currently expanded or passed
> directly.
>
>
> On Fri, May 16, 2014 at 8:55 AM, Zvonimir Rakamaric <zvonimir at cs.utah.edu>
> wrote:
>>
>> In particular, I would for example like to prevent that two fields of
>> type i32 are packed into an i64 parameter. And so on...
>>
>> Thanks!
>> -- Zvonimir
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>



More information about the llvm-dev mailing list