MIB.addMBB(BBToMBB[PI->getIncomingBlock(i)]);
}
}
-
- PendingPHIs.clear();
}
bool IRTranslator::translate(const Instruction &Inst) {
}
void IRTranslator::finalizeFunction() {
- finishPendingPhis();
-
// Release the memory used by the different maps we
// needed during the translation.
+ PendingPHIs.clear();
ValToVReg.clear();
FrameIndices.clear();
Constants.clear();
if (!TPC->isGlobalISelAbortEnabled()) {
MIRBuilder.getMF().getProperties().set(
MachineFunctionProperties::Property::FailedISel);
+ finalizeFunction();
return false;
}
report_fatal_error("Unable to lower arguments");
MIRBuilder.setMBB(MBB);
for (const Instruction &Inst: BB) {
- bool Succeeded = translate(Inst);
+ Succeeded &= translate(Inst);
if (!Succeeded) {
if (TPC->isGlobalISelAbortEnabled())
reportTranslationError(Inst, "unable to translate instruction");
}
}
- finalizeFunction();
+ if (Succeeded) {
+ finishPendingPhis();
+
+ // Now that the MachineFrameInfo has been configured, no further changes to
+ // the reserved registers are possible.
+ MRI->freezeReservedRegs(MF);
+ }
- // Now that the MachineFrameInfo has been configured, no further changes to
- // the reserved registers are possible.
- MRI->freezeReservedRegs(MF);
+ finalizeFunction();
return false;
}
; FALLBACK-WITH-REPORT-OUT: fmov d0, #1.0
define [1 x double] @constant() {
ret [1 x double] [double 1.0]
+}
+
+ ; The key problem here is that we may fail to create an MBB referenced by a
+ ; PHI. If so, we cannot complete the G_PHI and mustn't try or bad things
+ ; happen.
+; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for pending_phis
+define i32 @pending_phis(i1 %tst, i32 %val, i32* %addr) {
+ br i1 %tst, label %true, label %false
+
+end:
+ %res = phi i32 [%val, %true], [42, %false]
+ ret i32 %res
+
+true:
+ store atomic i32 42, i32* %addr seq_cst, align 4
+ br label %end
+
+false:
+ br label %end
+
}