<div dir="ltr">This code:<div><br></div><div><div><font face="courier new, monospace">declare i32 @printf(i8* nocapture readonly, ...) nounwind</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">define i32 @bar(i8* %c, i32 %i) #0 {</font></div>
<div><font face="courier new, monospace">entry:</font></div><div><font face="courier new, monospace"> %call = tail call i32 (i8*, ...)* @printf(i8* %c, i8* %c)</font></div><div><font face="courier new, monospace"> ret i32 %call</font></div>
<div><font face="courier new, monospace">}</font></div></div><div><br></div><div>Is accepted without complaints by close-to-trunk llc on my Ubuntu machine.</div><div><br></div><div>Eli</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Dec 3, 2013 at 2:58 PM, Mikael Lyngvig <span dir="ltr"><<a href="mailto:mikael@lyngvig.org" target="_blank">mikael@lyngvig.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I just tried adding the cast but it didn't help. I have the feeling that I am overlooking something very obvious, but I can't seem to figure out what it is. Thanks for your suggestion, though.<span class="HOEnZb"><font color="#888888"><div>
<br></div><div><br></div><div>-- Mikael</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/3 Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@google.com" target="_blank">eliben@google.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 3, 2013 at 2:29 PM, Mikael Lyngvig <span dir="ltr"><<a href="mailto:mikael@lyngvig.org" target="_blank">mikael@lyngvig.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am trying to print two strings using printf. I have tried various things, but keep getting this error:</div>
<div><br></div><div> llc: printf.ll:4:11: error: '@printf' defined with type 'i32 (i8*, ...)*'<br>
</div><div> %1 = call i32 @printf(i8* null, i8*, i8* null)<br></div><div><br></div><div>The code is:</div><div><div style="font-size:14pt;font-family:Consolas">
<pre> declare i32 @printf(i8* nocapture readonly, ...) nounwind
define i32 @main() nounwind {
%1 = call i32 @printf(i8* null, i8* null)
ret i32 0
}
</pre></div></div><div>I am aware that the call will core dump, but I am initially only trying to figure out why LLC won't accept the call itself. I started out trying with real values and then reduced it to the above to see if I could make it work. Comparing with the output of Clang didn't help; it does the same - passes in two i8* pointers and declares @printf in the same way (and LLC accepts the Clang output as valid input). The Clang code goes as follows (edited snippet):</div>
<div><br></div><div><div>@.str = private unnamed_addr constant [11 x i8] c"Error: %s\0A\00", align 1</div><div>@.str1 = private unnamed_addr constant [5 x i8] c"Test\00", align 1</div><div><br></div><div>
define i32 @main() nounwind {<br></div><div> %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8]* @.str1, i32 0, i32 0)) nounwind</div>
<div> ret i32 0</div><div>}</div><div><br></div><div>declare i32 @printf(i8* nocapture readonly, ...) nounwind<br></div></div><div><br></div><div>A good thing about this question is that the answer will find its way into the Mapping Highlevel doc, which is why I am asking it in the first place.</div>
<div><br></div><div>This is on Windows using a 32-bit version of LLVM llc v3.4 (built about a week ago).<br></div><div><br></div><div>I searched the LR, the FAQ, and Google but found nothing of relevance.</div><span><font color="#888888"><div>
<br></div></font></span></div></blockquote><div><br></div><div>You're missing the cast, IMHO. The cast appeases the LLVM type checker w.r.t. mismatching function type</div><span><font color="#888888"><div>
<br></div><div>Eli</div><div> </div></font></span></div>
</div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>