[PATCH] D137031: [InstCombine] Avoid deleting volatile memcpys.
Patrick Walton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 30 02:40:51 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb2cb2d20181: [InstCombine] Avoid deleting volatile memcpys. (authored by pcwalton).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137031/new/
https://reviews.llvm.org/D137031
Files:
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/memcpy-from-global.ll
Index: llvm/test/Transforms/InstCombine/memcpy-from-global.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memcpy-from-global.ll
+++ llvm/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -366,10 +366,12 @@
ret void
}
-; FIXME: Test that we incorrectly elide a volatile memcpy.
+; Test that we don't elide a volatile memcpy.
define void @volatile_memcpy() {
; CHECK-LABEL: @volatile_memcpy(
-; CHECK-NEXT: call void @bar(ptr nonnull @H) #[[ATTR3]]
+; CHECK-NEXT: [[A:%.*]] = alloca [[U:%.*]], align 16
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A]], ptr align 4 @H, i64 20, i1 true)
+; CHECK-NEXT: call void @bar(ptr nonnull [[A]]) #[[ATTR3]]
; CHECK-NEXT: ret void
;
%A = alloca %U, align 16
Index: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -111,12 +111,14 @@
if (!MI)
return false;
+ // If the transfer is volatile, reject it.
+ if (MI->isVolatile())
+ return false;
+
// If the transfer is using the alloca as a source of the transfer, then
// ignore it since it is a load (unless the transfer is volatile).
- if (U.getOperandNo() == 1) {
- if (MI->isVolatile()) return false;
+ if (U.getOperandNo() == 1)
continue;
- }
// If we already have seen a copy, reject the second one.
if (TheCopy) return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137031.471824.patch
Type: text/x-patch
Size: 1640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221030/43a4bcf3/attachment.bin>
More information about the llvm-commits
mailing list