diff options
author | Jessica Paquette <jpaquette@apple.com> | 2019-06-10 21:53:56 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2019-06-10 21:53:56 +0000 |
commit | b22954384e34eebb761db342dbad0b08dfb57856 (patch) | |
tree | 18c3fd4611aae4293cc2a50dd3cc9231984f824d /llvm/lib/CodeGen | |
parent | 23ee97be05f4e75fd40696ee3f2fd5c11b1a46f2 (diff) | |
download | bcm5719-llvm-b22954384e34eebb761db342dbad0b08dfb57856.tar.gz bcm5719-llvm-b22954384e34eebb761db342dbad0b08dfb57856.zip |
[GlobalISel] Translate memset/memmove/memcpy from undef ptrs into nops
If the source is undef, then just don't do anything.
This matches SelectionDAG's behaviour in SelectionDAG.cpp.
Also add a test showing that we do the right thing here.
(irtranslator-memfunc-undef.ll)
Differential Revision: https://reviews.llvm.org/D63095
llvm-svn: 362989
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index bde5ccc4f66..78b452899ef 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -728,6 +728,19 @@ bool IRTranslator::translateGetElementPtr(const User &U, bool IRTranslator::translateMemfunc(const CallInst &CI, MachineIRBuilder &MIRBuilder, unsigned ID) { + + // If the source is undef, then just emit a nop. + if (isa<UndefValue>(CI.getArgOperand(1))) { + switch (ID) { + case Intrinsic::memmove: + case Intrinsic::memcpy: + case Intrinsic::memset: + return true; + default: + break; + } + } + LLT SizeTy = getLLTForType(*CI.getArgOperand(2)->getType(), *DL); Type *DstTy = CI.getArgOperand(0)->getType(); if (cast<PointerType>(DstTy)->getAddressSpace() != 0 || |