@@ -433,7 +433,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
433433
434434 // / addOptimizedRegAlloc - Add passes related to register allocation.
435435 // / LLVMTargetMachine provides standard regalloc passes for most targets.
436- void addOptimizedRegAlloc (AddMachinePass &) const ;
436+ Error addOptimizedRegAlloc (AddMachinePass &) const ;
437437
438438 // / Add passes that optimize machine instructions after register allocation.
439439 void addMachineLateOptimization (AddMachinePass &) const ;
@@ -896,7 +896,8 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addMachinePasses(
896896 // Run register allocation and passes that are tightly coupled with it,
897897 // including phi elimination and scheduling.
898898 if (*Opt.OptimizeRegAlloc ) {
899- derived ().addOptimizedRegAlloc (addPass);
899+ if (auto Err = derived ().addOptimizedRegAlloc (addPass))
900+ return Err;
900901 } else {
901902 if (auto Err = derived ().addFastRegAlloc (addPass))
902903 return Err;
@@ -1089,7 +1090,7 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addFastRegAlloc(
10891090// / optimized register allocation, including coalescing, machine instruction
10901091// / scheduling, and register allocation itself.
10911092template <typename Derived, typename TargetMachineT>
1092- void CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
1093+ Error CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
10931094 AddMachinePass &addPass) const {
10941095 addPass (DetectDeadLanesPass ());
10951096
@@ -1115,20 +1116,23 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addOptimizedRegAlloc(
11151116 // PreRA instruction scheduling.
11161117 addPass (MachineSchedulerPass ());
11171118
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;
11221121
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 );
11261125
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 ();
11321136}
11331137
11341138// ===---------------------------------------------------------------------===//
0 commit comments