[cfe-dev] va_arg instruction

Jia Chen jchen at cs.utexas.edu
Mon Jul 20 15:29:03 PDT 2015


Hi Reid,

Thanks for the reply!

So the basic solution you are proposing here is to cross-compile the 
codes to another fake target that doesn't do anything fancy for varargs, 
right? But if I change the target, will I be able to compile my programs 
using the native libc headers on my machine (they might get messed up by 
the #ifdefs)? I would imagine that I'll face all the nasty issues 
related to cross compilation, which doesn't seems to be simpler to 
tackle than the vararg problem.

On 07/20/2015 11:05 AM, Reid Kleckner wrote:
> Someone else (possibly from your research group!) wanted something 
> similar a long time ago. They wanted a way to ensure that structs were 
> always passed in memory using the 'byval' attribute, so that they 
> could more easily analyze the IR. The proposed solution was to add a 
> target triple and then compile targeting that. Unfortunately, they 
> didn't get any traction, so we never added that. That solution also 
> has the downside that you'll miss code under architecture specific 
> #ifdefs that you might want to analyze.
>
> Anyway, I can't actually find the relevant email anymore, but 
> searching "llvmdev defaultabiinfo" turns up a bunch of relevant hits 
> for you.
>
> On Sun, Jul 19, 2015 at 12:43 PM, Jia Chen <jchen at cs.utexas.edu 
> <mailto:jchen at cs.utexas.edu>> wrote:
>
>     Hi clang devs,
>
>     I've been writing static analysis on top of LLVM IR for quite some
>     time and I rely on clang to get me IRs from C source codes.
>     Functions with variadic arguments used to be something I tried to
>     avoid but as my work progressed, it seems that a lot of real-world
>     C codes use them so it's necessary to teach my analysis to
>     understand them.
>
>     If my understanding was correct, currently clang recognizes
>     variadic functions in C source code and directly emit IRs that
>     manipulate architecture-specific vararg structures, rather than
>     emitting a target-independent va_arg instruction. At least on my
>     x86_64 machine, this vararg structure consists of two offset
>     fields and two buffer pointers and is quite difficult to handle.
>     It would be nice if the front end could stop the vararg lowering
>     and just give me a simple va_arg instruction instead. Is there a
>     simple tweak I can do to have clang give me the va_arg instruction
>     I want? Or do I have to modify clang's source code to do that?
>
>     -- 
>     Best Regards,
>
>     --
>     Jia Chen
>     Department of Computer Science
>     University of Texas at Austin
>     jchen at cs.utexas.edu <mailto:jchen at cs.utexas.edu>
>     http://www.cs.utexas.edu/~jchen <http://www.cs.utexas.edu/%7Ejchen>
>
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>

-- 
Best Regards,

--
Jia Chen
Department of Computer Science
University of Texas at Austin
jchen at cs.utexas.edu
http://www.cs.utexas.edu/~jchen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150720/bb0cc997/attachment.html>


More information about the cfe-dev mailing list