[PATCH] D31094: [BuildLibCalls] emitPutChar should infer its function attributes

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 12:22:20 PDT 2017


craig.topper created this revision.
Herald added a subscriber: wdng.

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.


https://reviews.llvm.org/D31094

Files:
  lib/Transforms/Utils/BuildLibCalls.cpp


Index: lib/Transforms/Utils/BuildLibCalls.cpp
===================================================================
--- lib/Transforms/Utils/BuildLibCalls.cpp
+++ lib/Transforms/Utils/BuildLibCalls.cpp
@@ -920,6 +920,7 @@
   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(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31094.92179.patch
Type: text/x-patch
Size: 608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170317/92520612/attachment.bin>


More information about the llvm-commits mailing list