For some reason the exception selector register must be a pointer (that's
assumed by SDag); on the other hand, it gets moved into an IR-level type which
might be entirely different (i32 on AArch64). IRTranslator needs to be aware of
this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293546
91177308-0d34-0410-b5e6-
96231b3b80d8
if (unsigned Reg = TLI.getExceptionSelectorRegister(PersonalityFn)) {
MBB.addLiveIn(Reg);
+
+ // N.b. the exception selector register always has pointer type and may not
+ // match the actual IR-level type in the landingpad so an extra cast is
+ // needed.
+ unsigned PtrVReg = MRI->createGenericVirtualRegister(Tys[0]);
+ MIRBuilder.buildCopy(PtrVReg, Reg);
+
unsigned VReg = MRI->createGenericVirtualRegister(Tys[1]);
- MIRBuilder.buildCopy(VReg, Reg);
+ MIRBuilder.buildInstr(TargetOpcode::G_PTRTOINT)
+ .addDef(VReg)
+ .addUse(PtrVReg);
Regs.push_back(VReg);
Offsets.push_back(Tys[0].getSizeInBits());
}
; CHECK: [[BAD]] (landing-pad):
; CHECK: EH_LABEL
; CHECK: [[PTR:%[0-9]+]](p0) = COPY %x0
-; CHECK: [[SEL:%[0-9]+]](s32) = COPY %x1
+; CHECK: [[SEL_PTR:%[0-9]+]](p0) = COPY %x1
+; CHECK: [[SEL:%[0-9]+]](s32) = G_PTRTOINT [[SEL_PTR]]
; CHECK: [[PTR_SEL:%[0-9]+]](s128) = G_SEQUENCE [[PTR]](p0), 0, [[SEL]](s32), 64
; CHECK: [[PTR_RET:%[0-9]+]](s64), [[SEL_RET:%[0-9]+]](s32) = G_EXTRACT [[PTR_SEL]](s128), 0, 64
; CHECK: %x0 = COPY [[PTR_RET]]
; CHECK: [[LP]] (landing-pad):
; CHECK: EH_LABEL
; CHECK: [[PTR:%[0-9]+]](p0) = COPY %x0
-; CHECK: [[SEL:%[0-9]+]](s32) = COPY %x1
+; CHECK: [[SEL_PTR:%[0-9]+]](p0) = COPY %x1
+; CHECK: [[SEL:%[0-9]+]](s32) = G_PTRTOINT [[SEL_PTR]]
; CHECK-NOT: G_SEQUENCE
; CHECK-NOT: G_EXTRACT
; CHECK: G_STORE [[PTR]](p0), {{%[0-9]+}}(p0)