Index: llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp +++ llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp @@ -38,7 +38,7 @@ for (auto Ty : {p0, s1, s8, s16, s32, s64}) setAction({G_IMPLICIT_DEF, Ty}, Legal); - for (auto Ty : {s16, s32, s64}) + for (auto Ty : {s16, s32, s64, p0}) setAction({G_PHI, Ty}, Legal); for (auto Ty : {s1, s8}) Index: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir =================================================================== --- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir +++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir @@ -10,6 +10,11 @@ ret i32 0 } + define i64* @legalize_phi_ptr(i64* %a, i64* %b, i1 %cond) { + entry: + ret i64* null + } + define i32 @legalize_phi_empty(i32 %argc) { entry: ret i32 0 @@ -104,6 +109,52 @@ ... --- +name: legalize_phi_ptr +alignment: 2 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +tracksRegLiveness: true +registers: + - { id: 0, class: _, preferred-register: '' } + - { id: 1, class: _, preferred-register: '' } + - { id: 2, class: _, preferred-register: '' } + - { id: 3, class: _, preferred-register: '' } + - { id: 4, class: _, preferred-register: '' } + - { id: 5, class: _, preferred-register: '' } +liveins: +body: | + bb.1: + ; CHECK-LABEL: name: legalize_phi_ptr + ; CHECK-LABEL: bb.0: + ; CHECK: %0(p0) = COPY %x0 + ; CHECK: %1(p0) = COPY %x1 + ; CHECK: %2(s1) = COPY %w2 + + ; CHECK-LABEL: bb.1: + ; CHECK-LABEL: bb.2: + ; CHECK: %3(p0) = G_PHI %0(p0), %bb.0, %1(p0), %bb.1 + ; CHECK: %x0 = COPY %3(p0) + successors: %bb.2, %bb.3 + liveins: %w2, %x0, %x1 + + %0(p0) = COPY %x0 + %1(p0) = COPY %x1 + %2(s1) = COPY %w2 + G_BRCOND %2(s1), %bb.2 + G_BR %bb.3 + + bb.2: + successors: %bb.3 + + bb.3: + %3(p0) = G_PHI %0(p0), %bb.1, %1(p0), %bb.2 + %x0 = COPY %3(p0) + RET_ReallyLR implicit %x0 + +... +--- name: legalize_phi_empty alignment: 2 exposesReturnsTwice: false