[llvm] r306793 - Revert "r306541 - Add zero-length check to memcpy/memset load store loop expansion"
Daniel Jasper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 23:37:34 PDT 2017
Author: djasper
Date: Thu Jun 29 23:37:33 2017
New Revision: 306793
URL: http://llvm.org/viewvc/llvm-project?rev=306793&view=rev
Log:
Revert "r306541 - Add zero-length check to memcpy/memset load store loop expansion"
Segfaults in non-optimized builds. I'll get a stack trace and a
reproducer to Teresa.
Modified:
llvm/trunk/lib/Transforms/Utils/LowerMemIntrinsics.cpp
llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll
Modified: llvm/trunk/lib/Transforms/Utils/LowerMemIntrinsics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerMemIntrinsics.cpp?rev=306793&r1=306792&r2=306793&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerMemIntrinsics.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerMemIntrinsics.cpp Thu Jun 29 23:37:33 2017
@@ -27,11 +27,8 @@ void llvm::createMemCpyLoop(Instruction
BasicBlock *LoopBB = BasicBlock::Create(F->getContext(), "loadstoreloop",
F, NewBB);
+ OrigBB->getTerminator()->setSuccessor(0, LoopBB);
IRBuilder<> Builder(OrigBB->getTerminator());
- Builder.CreateCondBr(
- Builder.CreateICmpEQ(ConstantInt::get(TypeOfCopyLen, 0), CopyLen), NewBB,
- LoopBB);
- OrigBB->getTerminator()->eraseFromParent();
// SrcAddr and DstAddr are expected to be pointer types,
// so no check is made here.
@@ -170,7 +167,6 @@ static void createMemMoveLoop(Instructio
static void createMemSetLoop(Instruction *InsertBefore,
Value *DstAddr, Value *CopyLen, Value *SetValue,
unsigned Align, bool IsVolatile) {
- Type *TypeOfCopyLen = CopyLen->getType();
BasicBlock *OrigBB = InsertBefore->getParent();
Function *F = OrigBB->getParent();
BasicBlock *NewBB =
@@ -178,11 +174,8 @@ static void createMemSetLoop(Instruction
BasicBlock *LoopBB
= BasicBlock::Create(F->getContext(), "loadstoreloop", F, NewBB);
+ OrigBB->getTerminator()->setSuccessor(0, LoopBB);
IRBuilder<> Builder(OrigBB->getTerminator());
- Builder.CreateCondBr(
- Builder.CreateICmpEQ(ConstantInt::get(TypeOfCopyLen, 0), CopyLen), NewBB,
- LoopBB);
- OrigBB->getTerminator()->eraseFromParent();
// Cast pointer to the type of value getting stored
unsigned dstAS = cast<PointerType>(DstAddr->getType())->getAddressSpace();
@@ -190,8 +183,8 @@ static void createMemSetLoop(Instruction
PointerType::get(SetValue->getType(), dstAS));
IRBuilder<> LoopBuilder(LoopBB);
- PHINode *LoopIndex = LoopBuilder.CreatePHI(TypeOfCopyLen, 0);
- LoopIndex->addIncoming(ConstantInt::get(TypeOfCopyLen, 0), OrigBB);
+ PHINode *LoopIndex = LoopBuilder.CreatePHI(CopyLen->getType(), 0);
+ LoopIndex->addIncoming(ConstantInt::get(CopyLen->getType(), 0), OrigBB);
LoopBuilder.CreateStore(
SetValue,
@@ -199,7 +192,7 @@ static void createMemSetLoop(Instruction
IsVolatile);
Value *NewIndex =
- LoopBuilder.CreateAdd(LoopIndex, ConstantInt::get(TypeOfCopyLen, 1));
+ LoopBuilder.CreateAdd(LoopIndex, ConstantInt::get(CopyLen->getType(), 1));
LoopIndex->addIncoming(NewIndex, LoopBB);
LoopBuilder.CreateCondBr(LoopBuilder.CreateICmpULT(NewIndex, CopyLen), LoopBB,
Modified: llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll?rev=306793&r1=306792&r2=306793&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll (original)
+++ llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll Thu Jun 29 23:37:33 2017
@@ -17,8 +17,6 @@ entry:
ret i8* %dst
; IR-LABEL: @memcpy_caller
-; IR: [[CMPREG:%[0-9]+]] = icmp eq i64 0, %n
-; IR: br i1 [[CMPREG]], label %split, label %loadstoreloop
; IR: loadstoreloop:
; IR: [[LOADPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %src, i64
; IR-NEXT: [[VAL:%[0-9]+]] = load i8, i8* [[LOADPTR]]
@@ -75,8 +73,6 @@ entry:
; IR-LABEL: @memset_caller
; IR: [[VAL:%[0-9]+]] = trunc i32 %c to i8
-; IR: [[CMPREG:%[0-9]+]] = icmp eq i64 0, %n
-; IR: br i1 [[CMPREG]], label %split, label %loadstoreloop
; IR: loadstoreloop:
; IR: [[STOREPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %dst, i64
; IR-NEXT: store i8 [[VAL]], i8* [[STOREPTR]]
More information about the llvm-commits
mailing list