[LLVMdev] Which pass converts call printf to puts?
Christoph Erhardt
christoph at sicherha.de
Mon Jun 18 06:12:33 PDT 2012
Hi Thomson,
> This makes sense now. So if the instruction doesn't make any assignment,
> it would be unnecessary to replace any operand reference and the same
> instruction(CI) would be returned from the inner function to avoid this
> replacement, is this right?
yep, looks like it. To use the correct terminology, though, I would
rather call it "the result of the instruction is unused" instead of "the
instruction doesn't make any assignment".
By the way, I'm a bit confused myself about the following line
(SimplifyLibCalls.cpp:1195) - maybe someone can comment on it:
return CI->use_empty() ? (Value*)CI :
ConstantInt::get(CI->getType(), FormatStr.size()+1);
So does LLVM assume that puts() is always successful and will never
return EOF? I'm not really sure that's a safe assumption. For instance,
stdout might have been closed or redirected to a file on a disk with
exceeded quota, and the write operation could fail as a consequence.
Best regards,
Christoph
More information about the llvm-dev
mailing list