]> granicus.if.org Git - llvm/commitdiff
GlobalISel: verify that generic loads & stores have a mem operand.
authorTim Northover <tnorthover@apple.com>
Fri, 17 Feb 2017 18:50:15 +0000 (18:50 +0000)
committerTim Northover <tnorthover@apple.com>
Fri, 17 Feb 2017 18:50:15 +0000 (18:50 +0000)
The mem operand is used by GlobalISel to convey atomic constraints so dropping
it is invalid.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295476 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineVerifier.cpp
test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir
test/CodeGen/ARM/GlobalISel/arm-instruction-select.mir
test/CodeGen/ARM/GlobalISel/arm-legalizer.mir
test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir

index 74709dc088827ee2468b5f7fefdf5a9a15e46247..15694cb481f6858b7da148a6fe2a2a6c8bc27ccb 100644 (file)
@@ -908,6 +908,14 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
     }
   }
 
+  // Generic loads and stores must have a single MachineMemOperand
+  // describing that access.
+  if ((MI->getOpcode() == TargetOpcode::G_LOAD ||
+       MI->getOpcode() == TargetOpcode::G_STORE) &&
+      !MI->hasOneMemOperand())
+    report("Generic instruction accessing memory must have one mem operand",
+           MI);
+
   StringRef ErrorInfo;
   if (!TII->verifyInstruction(*MI, ErrorInfo))
     report(ErrorInfo.data(), MI);
index 12162eb54a839c92c10bd8e19d28e03cbb5f358f..14ee40c941bf08c5953870fce4881ed8c4d9cb63 100644 (file)
@@ -622,7 +622,7 @@ body: |
     ; CHECK:      %0(p0) = COPY %x0
     ; CHECK:      %1(s32) = G_LOAD %0
     %0(p0) = COPY %x0
-    %1(s32) = G_LOAD %0
+    %1(s32) = G_LOAD %0 :: (load 4)
 ...
 
 ---
@@ -643,7 +643,7 @@ body: |
     ; CHECK:      G_STORE %1(s32), %0(p0)
     %0(p0) = COPY %x0
     %1(s32) = COPY %w1
-    G_STORE %1, %0
+    G_STORE %1, %0 :: (store 4)
 ...
 
 ---
index 77dcccde3f612ea8267ce03c421c543db057be77..25c5efd6a61462a2ae6c59769febdfc60f063f67 100644 (file)
@@ -320,13 +320,13 @@ body:             |
     %0(p0) = G_FRAME_INDEX %fixed-stack.2
     ; CHECK: [[FI32VREG:%[0-9]+]] = ADDri %fixed-stack.[[FI32]], 0, 14, _, _
 
-    %1(s32) = G_LOAD %0(p0)
+    %1(s32) = G_LOAD %0(p0) :: (load 4)
     ; CHECK: {{%[0-9]+}} = LDRi12 [[FI32VREG]], 0, 14, _
 
     %2(p0) = G_FRAME_INDEX %fixed-stack.0
     ; CHECK: [[FI1VREG:%[0-9]+]] = ADDri %fixed-stack.[[FI1]], 0, 14, _, _
 
-    %3(s1) = G_LOAD %2(p0)
+    %3(s1) = G_LOAD %2(p0) :: (load 1)
     ; CHECK: {{%[0-9]+}} = LDRBi12 [[FI1VREG]], 0, 14, _
 
     BX_RET 14, _
@@ -350,7 +350,7 @@ body:             |
 
     %0(p0) = COPY %r0
 
-    %1(s32) = G_LOAD %0(p0)
+    %1(s32) = G_LOAD %0(p0) :: (load 4)
     ; CHECK: %[[V]] = VLDRS %[[P]], 0, 14, _
 
     %s0 = COPY %1
@@ -377,7 +377,7 @@ body:             |
 
     %0(p0) = COPY %r0
 
-    %1(s64) = G_LOAD %0(p0)
+    %1(s64) = G_LOAD %0(p0) :: (load 8)
     ; CHECK: %[[V]] = VLDRD %[[P]], 0, 14, _
 
     %d0 = COPY %1
index 8ed4870ba89f892682c293099b5fbbe7d9579e8b..4943a7305fb572d6e2fb0b58f827e77e22c9a2bd 100644 (file)
@@ -157,9 +157,9 @@ body:             |
 
     ; This is legal, so we should find it unchanged in the output
     ; CHECK: [[FIVREG:%[0-9]+]](p0) = G_FRAME_INDEX %fixed-stack.[[FRAME_INDEX]]
-    ; CHECK: {{%[0-9]+}}(s32) = G_LOAD [[FIVREG]](p0)
+    ; CHECK: {{%[0-9]+}}(s32) = G_LOAD [[FIVREG]](p0) :: (load 4)
     %0(p0) = G_FRAME_INDEX %fixed-stack.2
-    %1(s32) = G_LOAD %0(p0)
+    %1(s32) = G_LOAD %0(p0) :: (load 4)
     BX_RET 14, _
 ...
 ---
@@ -190,12 +190,12 @@ body:             |
     ; CHECK-DAG: {{%[0-9]+}}(s1) = G_LOAD %0
     ; CHECK-DAG: {{%[0-9]+}}(p0) = G_LOAD %0
     %0(p0) = COPY %r0
-    %1(s32) = G_LOAD %0(p0)
-    %2(s16) = G_LOAD %0(p0)
-    %3(s8)  = G_LOAD %0(p0)
-    %4(s1)  = G_LOAD %0(p0)
-    %5(p0)  = G_LOAD %0(p0)
-    %6(s64) = G_LOAD %0(p0)
+    %1(s32) = G_LOAD %0(p0) :: (load 4)
+    %2(s16) = G_LOAD %0(p0) :: (load 2)
+    %3(s8)  = G_LOAD %0(p0) :: (load 1)
+    %4(s1)  = G_LOAD %0(p0) :: (load 1)
+    %5(p0)  = G_LOAD %0(p0) :: (load 4)
+    %6(s64) = G_LOAD %0(p0) :: (load 8)
     BX_RET 14, _
 ...
 ---
index 4ed778a5939cb6d6a2870f89f473422f3386da66..e54ca39b3aee495fd197c96723a2dd8c677b466d 100644 (file)
@@ -145,12 +145,12 @@ body:             |
   bb.0:
     liveins: %r0
     %0(p0) = COPY %r0
-    %6(s64) = G_LOAD %0
-    %1(s32) = G_LOAD %0
-    %2(s16) = G_LOAD %0
-    %3(s8)  = G_LOAD %0
-    %4(s1)  = G_LOAD %0
-    %5(p0)  = G_LOAD %0
+    %6(s64) = G_LOAD %0 :: (load 8)
+    %1(s32) = G_LOAD %0 :: (load 4)
+    %2(s16) = G_LOAD %0 :: (load 2)
+    %3(s8)  = G_LOAD %0 :: (load 1)
+    %4(s1)  = G_LOAD %0 :: (load 1)
+    %5(p0)  = G_LOAD %0 :: (load 8)
     BX_RET 14, _, implicit %r0
 
 ...