diff --git a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp index f19b932f3c731..8103bfe5f4f12 100644 --- a/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp +++ b/llvm/lib/Target/SystemZ/SystemZLongBranch.cpp @@ -218,6 +218,7 @@ static unsigned getInstSizeInBytes(const MachineInstr &MI, // These do not have a size: MI.isDebugOrPseudoInstr() || MI.isPosition() || MI.isKill() || MI.isImplicitDef() || MI.getOpcode() == TargetOpcode::MEMBARRIER || + MI.getOpcode() == TargetOpcode::INIT_UNDEF || // These have a size that may be zero: MI.isInlineAsm() || MI.getOpcode() == SystemZ::STACKMAP || MI.getOpcode() == SystemZ::PATCHPOINT || diff --git a/llvm/test/CodeGen/SystemZ/init-undef.mir b/llvm/test/CodeGen/SystemZ/init-undef.mir new file mode 100644 index 0000000000000..101dc6ebf8fd5 --- /dev/null +++ b/llvm/test/CodeGen/SystemZ/init-undef.mir @@ -0,0 +1,17 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 +# REQUIRES: asserts +# RUN: llc -run-pass systemz-long-branch -mtriple=s390x-ibm-zos -o - %s | FileCheck %s + +# Makes sure INIT_UNDEF does not crash the compiler in systemz-long-branch +--- +name: func0 +body: | + bb.0.entry: + ; CHECK-LABEL: name: func0 + ; CHECK: renamable $r0l = INIT_UNDEF + ; CHECK-NEXT: renamable $r3d = LGFR killed renamable $r0l + ; CHECK-NEXT: frame-destroy Return_XPLINK implicit $r3d + renamable $r0l = INIT_UNDEF + renamable $r3d = LGFR killed renamable $r0l + frame-destroy Return_XPLINK implicit $r3d +...