[llvm] r293851 - NVPTX: Fix not preserving volatile when expanding memset
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 17:20:36 PST 2017
Author: arsenm
Date: Wed Feb 1 19:20:34 2017
New Revision: 293851
URL: http://llvm.org/viewvc/llvm-project?rev=293851&view=rev
Log:
NVPTX: Fix not preserving volatile when expanding memset
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp?rev=293851&r1=293850&r2=293851&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp Wed Feb 1 19:20:34 2017
@@ -204,8 +204,8 @@ void convertMemMoveToLoop(Instruction *C
// Lower memset to loop.
void convertMemSetToLoop(Instruction *ConvertedInst, Value *DstAddr,
- Value *CopyLen, Value *SetValue, LLVMContext &Context,
- Function &F) {
+ Value *CopyLen, Value *SetValue,
+ bool IsVolatile, LLVMContext &Context, Function &F) {
BasicBlock *OrigBB = ConvertedInst->getParent();
BasicBlock *NewBB =
ConvertedInst->getParent()->splitBasicBlock(ConvertedInst, "split");
@@ -226,7 +226,7 @@ void convertMemSetToLoop(Instruction *Co
LoopBuilder.CreateStore(
SetValue,
LoopBuilder.CreateInBoundsGEP(SetValue->getType(), DstAddr, LoopIndex),
- false);
+ IsVolatile);
Value *NewIndex =
LoopBuilder.CreateAdd(LoopIndex, ConstantInt::get(CopyLen->getType(), 1));
@@ -325,6 +325,7 @@ bool NVPTXLowerAggrCopies::runOnFunction
/* DstAddr */ Memset->getRawDest(),
/* CopyLen */ Memset->getLength(),
/* SetValue */ Memset->getValue(),
+ /* IsVolatile */ Memset->isVolatile(),
/* Context */ Context,
/* Function F */ F);
}
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=293851&r1=293850&r2=293851&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll (original)
+++ llvm/trunk/test/CodeGen/NVPTX/lower-aggr-copies.ll Wed Feb 1 19:20:34 2017
@@ -86,6 +86,19 @@ entry:
; PTX-NEXT: @%p[[PRED]] bra LBB[[LABEL]]
}
+define i8* @volatile_memset_caller(i8* %dst, i32 %c, i64 %n) #0 {
+entry:
+ %0 = trunc i32 %c to i8
+ tail call void @llvm.memset.p0i8.i64(i8* %dst, i8 %0, i64 %n, i32 1, i1 true)
+ ret i8* %dst
+
+; IR-LABEL: @volatile_memset_caller
+; IR: [[VAL:%[0-9]+]] = trunc i32 %c to i8
+; IR: loadstoreloop:
+; IR: [[STOREPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %dst, i64
+; IR-NEXT: store volatile i8 [[VAL]], i8* [[STOREPTR]]
+}
+
define i8* @memmove_caller(i8* %dst, i8* %src, i64 %n) #0 {
entry:
tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %n, i32 1, i1 false)
More information about the llvm-commits
mailing list