]> granicus.if.org Git - llvm/commitdiff
Add placeholder for more extensive verification of psuedo ops
authorPhilip Reames <listmail@philipreames.com>
Fri, 2 Jun 2017 16:36:37 +0000 (16:36 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 2 Jun 2017 16:36:37 +0000 (16:36 +0000)
This initial patch doesn't actually do much useful. It's just to show where the new code goes. Once this is in, I'll extend the verification logic to check more useful properties.

For those curious, the more complicated version of this patch already found one very suspicious thing.

Differential Revision: https://reviews.llvm.org/D33819

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

14 files changed:
include/llvm/CodeGen/StackMaps.h
lib/CodeGen/MachineVerifier.cpp
test/CodeGen/X86/statepoint-allocas.ll
test/CodeGen/X86/statepoint-call-lowering.ll
test/CodeGen/X86/statepoint-far-call.ll
test/CodeGen/X86/statepoint-forward.ll
test/CodeGen/X86/statepoint-gctransition-call-lowering.ll
test/CodeGen/X86/statepoint-invoke.ll
test/CodeGen/X86/statepoint-live-in.ll
test/CodeGen/X86/statepoint-stack-usage.ll
test/CodeGen/X86/statepoint-stackmap-format.ll
test/CodeGen/X86/statepoint-uniqueing.ll
test/CodeGen/X86/statepoint-vector-bad-spill.ll
test/CodeGen/X86/statepoint-vector.ll

index a18936feea7b0c56ac7ac1a8c808520dfee815bc..f6aa98563e0a431e05cc538248cc42faf0b904c7 100644 (file)
@@ -150,7 +150,7 @@ public:
 ///   <StackMaps::ConstantOp>, <num other args>, [other args],
 ///   [gc values]
 class StatepointOpers {
-private:
+public:
   // These values are aboolute offsets into the operands of the statepoint
   // instruction.
   enum { IDPos, NBytesPos, NCallArgsPos, CallTargetPos, MetaEnd };
@@ -159,7 +159,6 @@ private:
   // arguments (i.e. the end of the call arguments).
   enum { CCOffset = 1, FlagsOffset = 3, NumVMSArgsOffset = 5 };
 
-public:
   explicit StatepointOpers(const MachineInstr *MI) : MI(MI) {}
 
   /// Get starting index of non call related arguments
index 265f93c363ca1f073659e67e06e5ea04b0b5443b..d40694ce91e308888b20c760844f2e7397906beb 100644 (file)
@@ -36,6 +36,7 @@
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineMemOperand.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/StackMaps.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Instructions.h"
@@ -909,17 +910,29 @@ 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);
+
+  // Verify properties of various specific instruction types
+  switch(MI->getOpcode()) {
+  default:
+    break;
+  case TargetOpcode::G_LOAD:
+  case TargetOpcode::G_STORE:
+    // Generic loads and stores must have a single MachineMemOperand
+    // describing that access.
+    if (!MI->hasOneMemOperand())
+      report("Generic instruction accessing memory must have one mem operand",
+             MI);
+    break;
+  case TargetOpcode::STATEPOINT:
+    if (!MI->getOperand(StatepointOpers::IDPos).isImm() ||
+        !MI->getOperand(StatepointOpers::NBytesPos).isImm() ||
+        !MI->getOperand(StatepointOpers::NCallArgsPos).isImm())
+      report("meta operands to STATEPOINT not constant!", MI);
+    break;
+  };
 }
 
 void
index 9f5418432abc3fdbfde12a19448a7024335deb98..b8e5c82913a51bc9a506dbce0f2df54862be6c31 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 ; Check that we can lower a use of an alloca both as a deopt value (where the
 ; exact meaning is up to the consumer of the stackmap) and as an explicit spill
 ; slot used for GC.  
index 6e5cdd605122934fbddc6805639dd64cd186e943..bd2dd53b654a83eb3dc79b899881a6f0866cdc64 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 ; This file contains a collection of basic tests to ensure we didn't
 ; screw up normal call lowering when there are no deopt or gc arguments.
 
index dc49061f64612e73f04b215a4446a402305b28eb..9f9b684efae838e9dab1deff00a8ef2dd61b0ed4 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 ; Test to check that Statepoints with X64 far-immediate targets
 ; are lowered correctly to an indirect call via a scratch register.
 
index d97bc0c75602931fc91e33b72a5cc3faee6a309e..bee4b5ac884e981220646e4c4bc54ba53c9e3b6c 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: opt -O3 -S < %s | FileCheck --check-prefix=CHECK-OPT %s
-; RUN: llc < %s | FileCheck --check-prefix=CHECK-LLC %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-LLC %s
 ; These tests are targetted at making sure we don't retain information
 ; about memory which contains potential gc references across a statepoint.
 ; They're carefully written to only outlaw forwarding of references. 
index 11dbe9e2e6c1c148d55dee1d1f14c292bc088bb8..b88ca03805f2a3022e2e308615aa90ad2b745363 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 ; This file contains a collection of basic tests to ensure we didn't
 ; screw up normal call lowering when a statepoint is a GC transition.
 
index 3e8b8ca49f1df7a95926d7e18b72b063176dca5d..29f8e3ed4f789293301ac04f43851f2a7723c788 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s 2>&1 | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s 2>&1 | FileCheck %s
 
 target triple = "x86_64-pc-linux-gnu"
 
index abe2b0a7acc87081e5c7498924dce5b0e4547b93..038ecec5a218d58086c3155476e15b78593b36fe 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -O3 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -O3 < %s | FileCheck %s
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.11.0"
 
index 5c27898f284aa2fb6ae2487351fa22dc891c2b09..b16426eae3d5c5325853541bf38ac04795ffa044 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -stack-symbol-ordering=0 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -stack-symbol-ordering=0 < %s | FileCheck %s
 
 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-linux-gnu"
index 0506381b9ec2c6b464d0f2dd0e24e22f27891ca5..966f66815f92ea9aa74e630358b32c5c6f6db543 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc < %s -stack-symbol-ordering=0 -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
-; RUN: llc < %s -stack-symbol-ordering=0 -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
+; RUN: llc < %s -verify-machineinstrs -stack-symbol-ordering=0 -mtriple="x86_64-pc-linux-gnu" | FileCheck %s
+; RUN: llc < %s -verify-machineinstrs -stack-symbol-ordering=0 -mtriple="x86_64-pc-unknown-elf" | FileCheck %s
 
 ; This test is a sanity check to ensure statepoints are generating StackMap
 ; sections correctly.  This is not intended to be a rigorous test of the 
index e791bc6b233390dbf923a84d7a6b6cd74d87dda4..a5fa1f2d99c9a3034079376c7e5587cc91f45294 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 
 ; Checks for a crash we had when two gc.relocate calls would
 ; relocating identical values
index 848988589cb0eeefb45cb227832830706c57fd16..7c55491bb1bea97cf01dfe6a842de43d807964ed 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -O3 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -O3 < %s | FileCheck %s
 
 ; This is checking for a crash.
 
index 000e88742880f2fb6f5594cd272b27df81a26d91..5bc8f983ff06b0310e1551c434557dabcf1e05c4 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc -stack-symbol-ordering=0 -mcpu=nehalem -debug-only=stackmaps < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -stack-symbol-ordering=0 -mcpu=nehalem -debug-only=stackmaps < %s | FileCheck %s
 ; REQUIRES: asserts
 
 target triple = "x86_64-pc-linux-gnu"