Skip to content

Commit c4ee7d9

Browse files
committed
Use InsertPointGuard instead of manual save/restore.
It has the extra benefit of saving/restoring the debug location which otherwise could be lost.
1 parent 315a7fc commit c4ee7d9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6585,6 +6585,8 @@ static Function *createOutlinedFunction(
65856585
ParameterTypes.push_back(Arg->getType());
65866586
}
65876587

6588+
// Save insert point.
6589+
IRBuilder<>::InsertPointGuard IPG(Builder);
65886590
auto BB = Builder.GetInsertBlock();
65896591
auto M = BB->getModule();
65906592
auto FuncType = FunctionType::get(Builder.getVoidTy(), ParameterTypes,
@@ -6621,9 +6623,6 @@ static Function *createOutlinedFunction(
66216623
}
66226624
}
66236625

6624-
// Save insert point.
6625-
auto OldInsertPoint = Builder.saveIP();
6626-
66276626
// Generate the region into the function.
66286627
BasicBlock *EntryBB = BasicBlock::Create(Builder.getContext(), "entry", Func);
66296628
Builder.SetInsertPoint(EntryBB);
@@ -6729,9 +6728,6 @@ static Function *createOutlinedFunction(
67296728
for (auto Deferred : DeferredReplacement)
67306729
ReplaceValue(std::get<0>(Deferred), std::get<1>(Deferred), Func);
67316730

6732-
// Restore insert point.
6733-
Builder.restoreIP(OldInsertPoint);
6734-
67356731
return Func;
67366732
}
67376733

0 commit comments

Comments
 (0)