@@ -433,7 +433,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
433
433
434
434
// / addOptimizedRegAlloc - Add passes related to register allocation.
435
435
// / LLVMTargetMachine provides standard regalloc passes for most targets.
436
- void addOptimizedRegAlloc (AddMachinePass &) const ;
436
+ Error addOptimizedRegAlloc (AddMachinePass &) const ;
437
437
438
438
// / Add passes that optimize machine instructions after register allocation.
439
439
void addMachineLateOptimization (AddMachinePass &) const ;
@@ -896,7 +896,8 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addMachinePasses(
896
896
// Run register allocation and passes that are tightly coupled with it,
897
897
// including phi elimination and scheduling.
898
898
if (*Opt.OptimizeRegAlloc ) {
899
- derived ().addOptimizedRegAlloc (addPass);
899
+ if (auto Err = derived ().addOptimizedRegAlloc (addPass))
900
+ return Err;
900
901
} else {
901
902
if (auto Err = derived ().addFastRegAlloc (addPass))
902
903
return Err;
@@ -1089,7 +1090,7 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addFastRegAlloc(
1089
1090
// / optimized register allocation, including coalescing, machine instruction
1090
1091
// / scheduling, and register allocation itself.
1091
1092
template <typename Derived, typename TargetMachineT>
1092
- void CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
1093
+ Error CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
1093
1094
AddMachinePass &addPass) const {
1094
1095
addPass (DetectDeadLanesPass ());
1095
1096
@@ -1115,20 +1116,23 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
1115
1116
// PreRA instruction scheduling.
1116
1117
addPass (MachineSchedulerPass ());
1117
1118
1118
- if (derived ().addRegAssignmentOptimized (addPass)) {
1119
- // Allow targets to expand pseudo instructions depending on the choice of
1120
- // registers before MachineCopyPropagation.
1121
- derived ().addPostRewrite (addPass);
1119
+ if (auto Err = derived ().addRegAssignmentOptimized (addPass))
1120
+ return Err;
1122
1121
1123
- // Copy propagate to forward register uses and try to eliminate COPYs that
1124
- // were not coalesced .
1125
- addPass ( MachineCopyPropagationPass () );
1122
+ // Allow targets to expand pseudo instructions depending on the choice of
1123
+ // registers before MachineCopyPropagation .
1124
+ derived (). addPostRewrite (addPass );
1126
1125
1127
- // Run post-ra machine LICM to hoist reloads / remats.
1128
- //
1129
- // FIXME: can this move into MachineLateOptimization?
1130
- addPass (MachineLICMPass ());
1131
- }
1126
+ // Copy propagate to forward register uses and try to eliminate COPYs that
1127
+ // were not coalesced.
1128
+ addPass (MachineCopyPropagationPass ());
1129
+
1130
+ // Run post-ra machine LICM to hoist reloads / remats.
1131
+ //
1132
+ // FIXME: can this move into MachineLateOptimization?
1133
+ addPass (MachineLICMPass ());
1134
+
1135
+ return Error::success ();
1132
1136
}
1133
1137
1134
1138
// ===---------------------------------------------------------------------===//
0 commit comments