summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
authorAmara Emerson <aemerson@apple.com>2019-01-27 11:34:41 +0000
committerAmara Emerson <aemerson@apple.com>2019-01-27 11:34:41 +0000
commit711bbdc8942df7b81d82a9517e9dc67068eaa642 (patch)
tree8e7cad3cb039341fbd72bb2c25d1fb32fef2ad98 /llvm/lib/CodeGen/MachineVerifier.cpp
parentbf43004ff1b9e2270b074117e53bfb11937c7bf4 (diff)
downloadbcm5719-llvm-711bbdc8942df7b81d82a9517e9dc67068eaa642.tar.gz
bcm5719-llvm-711bbdc8942df7b81d82a9517e9dc67068eaa642.zip
Re-apply "r351584: "GlobalISel: Verify g_zextload and g_sextload""
I reverted it originally due to a bot failing. The underlying bug has been fixed as of r352311. llvm-svn: 352312
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index ad7825ba3eb..879a3d33469 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1002,11 +1002,24 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
}
case TargetOpcode::G_LOAD:
case TargetOpcode::G_STORE:
+ case TargetOpcode::G_ZEXTLOAD:
+ case TargetOpcode::G_SEXTLOAD:
// Generic loads and stores must have a single MachineMemOperand
// describing that access.
- if (!MI->hasOneMemOperand())
+ if (!MI->hasOneMemOperand()) {
report("Generic instruction accessing memory must have one mem operand",
MI);
+ } else {
+ if (MI->getOpcode() == TargetOpcode::G_ZEXTLOAD ||
+ MI->getOpcode() == TargetOpcode::G_SEXTLOAD) {
+ const MachineMemOperand &MMO = **MI->memoperands_begin();
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ if (MMO.getSize() * 8 >= DstTy.getSizeInBits()) {
+ report("Generic extload must have a narrower memory type", MI);
+ }
+ }
+ }
+
break;
case TargetOpcode::G_PHI: {
LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
OpenPOWER on IntegriCloud