[llvm] ad643d5 - [Verifier] Remove invalid verifier check

Serguei Katkov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 15 22:16:33 PDT 2020


Author: Serguei Katkov
Date: 2020-03-16T12:00:08+07:00
New Revision: ad643d5e93c368a4fde616d03955c9f7f3eb6768

URL: https://github.com/llvm/llvm-project/commit/ad643d5e93c368a4fde616d03955c9f7f3eb6768
DIFF: https://github.com/llvm/llvm-project/commit/ad643d5e93c368a4fde616d03955c9f7f3eb6768.diff

LOG: [Verifier] Remove invalid verifier check

According to LangRef for unordered atomic memory transfer intrinsics
"The first three arguments are the same as they are in the @llvm.memcpy intrinsic, with the added constraint that
 len is required to be a positive integer multiple of the element_size. If len is not a positive integer multiple
 of element_size, then the behaviour of the intrinsic is undefined."

So the len is not multiple of element size is just an undefined behavior and verifier should not complain about that
as undefined behavior is allowed in LLVM IR.

This change removes the verifier check for this condition

Reviewers: reames
Reviewed By: reames
Subscribers: dantrushin, hiraditya, jfb, llvm-commits
Differential Revision: https://reviews.llvm.org/D76116

Added: 
    

Modified: 
    llvm/lib/IR/Verifier.cpp
    llvm/test/Verifier/element-wise-atomic-memory-intrinsics.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 1053304995c9..37dc3a8fbd9b 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4412,15 +4412,6 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
            "must be a power of 2",
            Call);
 
-    if (auto *LengthCI = dyn_cast<ConstantInt>(AMI->getLength())) {
-      uint64_t Length = LengthCI->getZExtValue();
-      uint64_t ElementSize = AMI->getElementSizeInBytes();
-      Assert((Length % ElementSize) == 0,
-             "constant length must be a multiple of the element size in the "
-             "element-wise atomic memory intrinsic",
-             Call);
-    }
-
     auto IsValidAlignment = [&](uint64_t Alignment) {
       return isPowerOf2_64(Alignment) && ElementSizeVal.ule(Alignment);
     };

diff  --git a/llvm/test/Verifier/element-wise-atomic-memory-intrinsics.ll b/llvm/test/Verifier/element-wise-atomic-memory-intrinsics.ll
index f22f8eecbcc0..3912cef37fd4 100644
--- a/llvm/test/Verifier/element-wise-atomic-memory-intrinsics.ll
+++ b/llvm/test/Verifier/element-wise-atomic-memory-intrinsics.ll
@@ -9,7 +9,6 @@ define void @test_memcpy(i8* %P, i8* %Q, i32 %A, i32 %E) {
   ; CHECK: element size of the element-wise atomic memory intrinsic must be a power of 2
   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1, i32 3)
 
-  ; CHECK: constant length must be a multiple of the element size in the element-wise atomic memory intrinsic
   call void @llvm.memcpy.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 7, i32 4)
 
   ; CHECK: incorrect alignment of the destination argument
@@ -36,7 +35,6 @@ define void @test_memmove(i8* %P, i8* %Q, i32 %A, i32 %E) {
   ; CHECK: element size of the element-wise atomic memory intrinsic must be a power of 2
   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 1, i32 3)
 
-  ; CHECK: constant length must be a multiple of the element size in the element-wise atomic memory intrinsic
   call void @llvm.memmove.element.unordered.atomic.p0i8.p0i8.i32(i8* align 4 %P, i8* align 4 %Q, i32 7, i32 4)
 
   ; CHECK: incorrect alignment of the destination argument
@@ -63,7 +61,6 @@ define void @test_memset(i8* %P, i8 %V, i32 %A, i32 %E) {
   ; CHECK: element size of the element-wise atomic memory intrinsic must be a power of 2
   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 4 %P, i8 %V, i32 1, i32 3)
 
-  ; CHECK: constant length must be a multiple of the element size in the element-wise atomic memory intrinsic
   call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 4 %P, i8 %V, i32 7, i32 4)
 
   ; CHECK: incorrect alignment of the destination argument


        


More information about the llvm-commits mailing list