[llvm] r353209 - GlobalISel: Verify G_GEP
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 5 12:04:12 PST 2019
Author: arsenm
Date: Tue Feb 5 12:04:12 2019
New Revision: 353209
URL: http://llvm.org/viewvc/llvm-project?rev=353209&view=rev
Log:
GlobalISel: Verify G_GEP
Added:
llvm/trunk/test/Verifier/test_g_gep.mir
Modified:
llvm/trunk/lib/CodeGen/MachineVerifier.cpp
Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=353209&r1=353208&r2=353209&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Tue Feb 5 12:04:12 2019
@@ -1100,6 +1100,22 @@ void MachineVerifier::verifyPreISelGener
break;
}
+ case TargetOpcode::G_GEP: {
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ LLT PtrTy = MRI->getType(MI->getOperand(1).getReg());
+ LLT OffsetTy = MRI->getType(MI->getOperand(2).getReg());
+ if (!DstTy.isValid() || !PtrTy.isValid() || !OffsetTy.isValid())
+ break;
+
+ if (!PtrTy.getScalarType().isPointer())
+ report("gep first operand must be a pointer", MI);
+
+ if (OffsetTy.getScalarType().isPointer())
+ report("gep offset operand must not be a pointer", MI);
+
+ // TODO: Is the offset allowed to be a scalar with a vector?
+ break;
+ }
case TargetOpcode::G_SEXT:
case TargetOpcode::G_ZEXT:
case TargetOpcode::G_ANYEXT:
Added: llvm/trunk/test/Verifier/test_g_gep.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/test_g_gep.mir?rev=353209&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/test_g_gep.mir (added)
+++ llvm/trunk/test/Verifier/test_g_gep.mir Tue Feb 5 12:04:12 2019
@@ -0,0 +1,32 @@
+#RUN: not llc -o - -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
+# REQUIRES: global-isel, aarch64-registered-target
+
+---
+name: test_gep
+legalized: true
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+liveins:
+body: |
+ bb.0:
+
+ %0:_(p0) = G_IMPLICIT_DEF
+ %1:_(s64) = G_IMPLICIT_DEF
+
+ ; CHECK: Bad machine code: Type mismatch in generic instruction
+ %2:_(s64) = G_GEP %0, %1
+
+ ; CHECK: Bad machine code: Type mismatch in generic instruction
+ %3:_(p0) = G_GEP %1, %1
+
+ ; CHECK: Bad machine code: gep offset operand must not be a pointer
+ %4:_(p0) = G_GEP %0, %0
+
+ ; CHECK: Bad machine code: Type mismatch in generic instruction
+ %5:_(p1) = G_GEP %0, %1
+
+ ; CHECK: Bad machine code: gep first operand must be a pointer
+ %6:_(s64) = G_GEP %1, %1
+
+...
More information about the llvm-commits
mailing list