[llvm] r298171 - [BuildLibCalls] emitPutChar should infer function attributes for putchar

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 16:48:02 PDT 2017


Author: ctopper
Date: Fri Mar 17 18:48:02 2017
New Revision: 298171

URL: http://llvm.org/viewvc/llvm-project?rev=298171&view=rev
Log:
[BuildLibCalls] emitPutChar should infer function attributes for putchar

When InstCombine calls into SimplifyLibCalls and it createa putChar calls, we don't infer the attributes. And since SimplifyLibCalls doesn't use InstCombine's IRBuilder the calls doesn't end up in the worklist on this iteration of InstCombine. So it gets picked up on the next iteration where it causes an IR change. This of course causes InstCombine to run another iteration.

So this patch just gets the attributes right the first time. We already did this for puts and some other libcalls.

Differential Revision: https://reviews.llvm.org/D31094



Modified:
    llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp

Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=298171&r1=298170&r2=298171&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Fri Mar 17 18:48:02 2017
@@ -920,6 +920,7 @@ Value *llvm::emitPutChar(Value *Char, IR
   Module *M = B.GetInsertBlock()->getModule();
   Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(),
                                           B.getInt32Ty(), nullptr);
+  inferLibFuncAttributes(*M->getFunction("putchar"), *TLI);
   CallInst *CI = B.CreateCall(PutChar,
                               B.CreateIntCast(Char,
                               B.getInt32Ty(),




More information about the llvm-commits mailing list