diff options
author | Yuanfang Chen <yuanfang.chen@sony.com> | 2021-04-12 14:16:25 -0700 |
---|---|---|
committer | Yuanfang Chen <yuanfang.chen@sony.com> | 2021-04-12 14:50:54 -0700 |
commit | c5fda0e6629fb4674b9e2e80cfd360c2758bd136 (patch) | |
tree | 813188d0dfffc0f41fe773665ce8cf9104f49324 /llvm/lib/Analysis/TargetLibraryInfo.cpp | |
parent | c2ad7c23707cece995ee9070283a72c4afc8c0fe (diff) | |
download | llvm-c5fda0e6629fb4674b9e2e80cfd360c2758bd136.zip llvm-c5fda0e6629fb4674b9e2e80cfd360c2758bd136.tar.gz llvm-c5fda0e6629fb4674b9e2e80cfd360c2758bd136.tar.bz2 |
Reland "Revert "[InstCombine] when calling conventions are compatible, don't convert the call to undef idiom""
This reverts commit a3fabc79ae9d7dd76545b2abc2a3bfb66c6d3175 (relands
f4d682d6ce6c5b3a41a0acf297507c82f5c21eef with fix for the compile-time
regression issue).
Diffstat (limited to 'llvm/lib/Analysis/TargetLibraryInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/TargetLibraryInfo.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 31cea8f..9ea84f1 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -65,6 +65,49 @@ static bool hasBcmp(const Triple &TT) { return TT.isOSFreeBSD() || TT.isOSSolaris(); } +static bool isCallingConvCCompatible(CallingConv::ID CC, StringRef TT, + FunctionType *FuncTy) { + switch (CC) { + default: + return false; + case llvm::CallingConv::C: + return true; + case llvm::CallingConv::ARM_APCS: + case llvm::CallingConv::ARM_AAPCS: + case llvm::CallingConv::ARM_AAPCS_VFP: { + + // The iOS ABI diverges from the standard in some cases, so for now don't + // try to simplify those calls. + if (Triple(TT).isiOS()) + return false; + + if (!FuncTy->getReturnType()->isPointerTy() && + !FuncTy->getReturnType()->isIntegerTy() && + !FuncTy->getReturnType()->isVoidTy()) + return false; + + for (auto *Param : FuncTy->params()) { + if (!Param->isPointerTy() && !Param->isIntegerTy()) + return false; + } + return true; + } + } + return false; +} + +bool TargetLibraryInfoImpl::isCallingConvCCompatible(CallBase *CI) { + return ::isCallingConvCCompatible(CI->getCallingConv(), + CI->getModule()->getTargetTriple(), + CI->getFunctionType()); +} + +bool TargetLibraryInfoImpl::isCallingConvCCompatible(Function *F) { + return ::isCallingConvCCompatible(F->getCallingConv(), + F->getParent()->getTargetTriple(), + F->getFunctionType()); +} + /// Initialize the set of available library functions based on the specified /// target triple. This should be carefully written so that a missing target /// triple gets a sane set of defaults. |