aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2022-08-15 10:06:12 -0600
committerMartin Sebor <msebor@redhat.com>2022-08-16 15:35:08 -0600
commite858f5120da77f46a6676c6fd63ccbbb83b23d2d (patch)
tree587f9b29e3d076cff306fc9db207617e801051d5 /llvm/lib/Transforms/Utils/BuildLibCalls.cpp
parent1fe72001e8d69cae1975a360fee055c2fd3730f4 (diff)
downloadllvm-e858f5120da77f46a6676c6fd63ccbbb83b23d2d.zip
llvm-e858f5120da77f46a6676c6fd63ccbbb83b23d2d.tar.gz
llvm-e858f5120da77f46a6676c6fd63ccbbb83b23d2d.tar.bz2
[InstCombine] Remove assumptions about int having 32 bits
Reviewed By: bjope Differential Revision: https://reviews.llvm.org/D131731
Diffstat (limited to 'llvm/lib/Transforms/Utils/BuildLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BuildLibCalls.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index 048f132..b15e14b 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -1756,22 +1756,19 @@ Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2,
return emitBinaryFloatFnCallHelper(Op1, Op2, TheLibFunc, Name, B, Attrs, TLI);
}
+// Emit a call to putchar(int) with Char as the argument. Char must have
+// the same precision as int, which need not be 32 bits.
Value *llvm::emitPutChar(Value *Char, IRBuilderBase &B,
const TargetLibraryInfo *TLI) {
Module *M = B.GetInsertBlock()->getModule();
if (!isLibFuncEmittable(M, TLI, LibFunc_putchar))
return nullptr;
+ Type *Ty = Char->getType();
StringRef PutCharName = TLI->getName(LibFunc_putchar);
- FunctionCallee PutChar = getOrInsertLibFunc(M, *TLI, LibFunc_putchar,
- B.getInt32Ty(), B.getInt32Ty());
+ FunctionCallee PutChar = getOrInsertLibFunc(M, *TLI, LibFunc_putchar, Ty, Ty);
inferNonMandatoryLibFuncAttrs(M, PutCharName, *TLI);
- CallInst *CI = B.CreateCall(PutChar,
- B.CreateIntCast(Char,
- B.getInt32Ty(),
- /*isSigned*/true,
- "chari"),
- PutCharName);
+ CallInst *CI = B.CreateCall(PutChar, Char, PutCharName);
if (const Function *F =
dyn_cast<Function>(PutChar.getCallee()->stripPointerCasts()))