<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<div class="moz-cite-prefix">On 05/22/2018 04:32 AM, Dávid Bolvanský
via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOrgDVOCB7_i70VEx3LmpqG5NsuVnG5835N-1fCxwiTEpUvEOw@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr">Hello,
<div><br>
</div>
<div>A new patch:</div>
<div><a href="https://reviews.llvm.org/D47159"
moz-do-not-send="true">https://reviews.llvm.org/D47159</a></div>
<div><br>
</div>
<div>proposes transformations like:</div>
printf("Hello, %s %d", "world", 123) - > printf("Hello world
123")<br>
</div>
</blockquote>
<br>
To clarify, the real question here comes up when you can only
substitute some of the arguments? If you can substitute all of the
arguments, then you can turn this into a call to puts.<br>
<br>
In any case , why do you want to do this? Also, doesn't the
formatting used by printf depend on the process's current locale?<br>
<br>
-Hal<br>
<br>
<blockquote type="cite"
cite="mid:CAOrgDVOCB7_i70VEx3LmpqG5NsuVnG5835N-1fCxwiTEpUvEOw@mail.gmail.com">
<div dir="ltr"><br>
As Eli noted:<br>
<br>
"I'm not sure we can rewrite calls to varargs functions safely
in general given the current state of the C ABI rules in LLVM.<br>
<br>
Sometimes clang does weird things to conform with the ABI rules,
because the LLVM type system isn't the same as the C system. For
most functions, it's pretty easy to tell it happened: if the IR
signature of the function doesn't match the expected signature,
something weird happened, so we can just bail out. But varargs
functions don't specify a complete signature, so we can't tell
if the clang ABI code was forced to do something weird, like
split an argument into multiple values, or insert a padding
value. For example, for the target mips64-unknown-linux-gnu, a
call like printf("asdf%Lf", 1.0L); gets lowered to the
following:<br>
<br>
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds
([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 undef, fp128
0xL00000000000000003FFF000000000000) #2"
<div><br>
</div>
<div><br>
</div>
<div>I would to hear more suggestions whether it is safe or not.
Seems like for mips Clang produces some weird IR, but e.g. x86
IR seems ok.</div>
<div><br>
</div>
<div>Any folks from Clang/LLVM to bring more information about
"varargs vs ABI vs LLVM vs Clang"? </div>
<div>And whether we can rewrite calls to varargs functions
safely under some conditions..</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>