summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
index 1876dc3f712..f6bdbf5e9be 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -301,6 +301,26 @@ void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInstLowering.lower(MI, TmpInst);
EmitToStreamer(*OutStreamer, TmpInst);
+#ifdef EXPENSIVE_CHECKS
+ // Sanity-check getInstSizeInBytes on explicitly specified CPUs (it cannot
+ // work correctly for the generic CPU).
+ //
+ // The isPseudo check really shouldn't be here, but unfortunately there are
+ // some negative lit tests that depend on being able to continue through
+ // here even when pseudo instructions haven't been lowered.
+ if (!MI->isPseudo() && STI.isCPUStringValid(STI.getCPU())) {
+ SmallVector<MCFixup, 4> Fixups;
+ SmallVector<char, 16> CodeBytes;
+ raw_svector_ostream CodeStream(CodeBytes);
+
+ std::unique_ptr<MCCodeEmitter> InstEmitter(createSIMCCodeEmitter(
+ *STI.getInstrInfo(), *OutContext.getRegisterInfo(), OutContext));
+ InstEmitter->encodeInstruction(TmpInst, CodeStream, Fixups, STI);
+
+ assert(CodeBytes.size() == STI.getInstrInfo()->getInstSizeInBytes(*MI));
+ }
+#endif
+
if (STI.dumpCode()) {
// Disassemble instruction/operands to text.
DisasmLines.resize(DisasmLines.size() + 1);
OpenPOWER on IntegriCloud