@@ -2617,7 +2617,7 @@ void OpenMPIRBuilder::emitReductionListCopy(
2617
2617
Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction (
2618
2618
const LocationDescription &Loc, ArrayRef<ReductionInfo> ReductionInfos,
2619
2619
AttributeList FuncAttrs) {
2620
- InsertPointTy SavedIP = Builder. saveIP ( );
2620
+ IRBuilder<>::InsertPointGuard IPG (Builder );
2621
2621
LLVMContext &Ctx = M.getContext ();
2622
2622
FunctionType *FuncTy = FunctionType::get (
2623
2623
Builder.getVoidTy (), {Builder.getPtrTy (), Builder.getInt32Ty ()},
@@ -2630,6 +2630,7 @@ Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction(
2630
2630
WcFunc->addParamAttr (1 , Attribute::NoUndef);
2631
2631
BasicBlock *EntryBB = BasicBlock::Create (M.getContext (), " entry" , WcFunc);
2632
2632
Builder.SetInsertPoint (EntryBB);
2633
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
2633
2634
2634
2635
// ReduceList: thread local Reduce list.
2635
2636
// At the stage of the computation when this function is called, partially
@@ -2844,7 +2845,6 @@ Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction(
2844
2845
}
2845
2846
2846
2847
Builder.CreateRetVoid ();
2847
- Builder.restoreIP (SavedIP);
2848
2848
2849
2849
return WcFunc;
2850
2850
}
@@ -2853,6 +2853,7 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
2853
2853
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
2854
2854
AttributeList FuncAttrs) {
2855
2855
LLVMContext &Ctx = M.getContext ();
2856
+ IRBuilder<>::InsertPointGuard IPG (Builder);
2856
2857
FunctionType *FuncTy =
2857
2858
FunctionType::get (Builder.getVoidTy (),
2858
2859
{Builder.getPtrTy (), Builder.getInt16Ty (),
@@ -2871,6 +2872,7 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
2871
2872
SarFunc->addParamAttr (3 , Attribute::SExt);
2872
2873
BasicBlock *EntryBB = BasicBlock::Create (M.getContext (), " entry" , SarFunc);
2873
2874
Builder.SetInsertPoint (EntryBB);
2875
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
2874
2876
2875
2877
// Thread local Reduce list used to host the values of data to be reduced.
2876
2878
Argument *ReduceListArg = SarFunc->getArg (0 );
@@ -3017,7 +3019,7 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
3017
3019
Function *OpenMPIRBuilder::emitListToGlobalCopyFunction (
3018
3020
ArrayRef<ReductionInfo> ReductionInfos, Type *ReductionsBufferTy,
3019
3021
AttributeList FuncAttrs) {
3020
- OpenMPIRBuilder::InsertPointTy OldIP = Builder. saveIP ( );
3022
+ IRBuilder<>::InsertPointGuard IPG (Builder );
3021
3023
LLVMContext &Ctx = M.getContext ();
3022
3024
FunctionType *FuncTy = FunctionType::get (
3023
3025
Builder.getVoidTy (),
@@ -3033,6 +3035,7 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
3033
3035
3034
3036
BasicBlock *EntryBlock = BasicBlock::Create (Ctx, " entry" , LtGCFunc);
3035
3037
Builder.SetInsertPoint (EntryBlock);
3038
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3036
3039
3037
3040
// Buffer: global reduction buffer.
3038
3041
Argument *BufferArg = LtGCFunc->getArg (0 );
@@ -3120,14 +3123,13 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
3120
3123
}
3121
3124
3122
3125
Builder.CreateRetVoid ();
3123
- Builder.restoreIP (OldIP);
3124
3126
return LtGCFunc;
3125
3127
}
3126
3128
3127
3129
Function *OpenMPIRBuilder::emitListToGlobalReduceFunction (
3128
3130
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
3129
3131
Type *ReductionsBufferTy, AttributeList FuncAttrs) {
3130
- OpenMPIRBuilder::InsertPointTy OldIP = Builder. saveIP ( );
3132
+ IRBuilder<>::InsertPointGuard IPG (Builder );
3131
3133
LLVMContext &Ctx = M.getContext ();
3132
3134
FunctionType *FuncTy = FunctionType::get (
3133
3135
Builder.getVoidTy (),
@@ -3143,6 +3145,7 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
3143
3145
3144
3146
BasicBlock *EntryBlock = BasicBlock::Create (Ctx, " entry" , LtGRFunc);
3145
3147
Builder.SetInsertPoint (EntryBlock);
3148
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3146
3149
3147
3150
// Buffer: global reduction buffer.
3148
3151
Argument *BufferArg = LtGRFunc->getArg (0 );
@@ -3203,14 +3206,13 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
3203
3206
Builder.CreateCall (ReduceFn, {LocalReduceListAddrCast, ReduceList})
3204
3207
->addFnAttr (Attribute::NoUnwind);
3205
3208
Builder.CreateRetVoid ();
3206
- Builder.restoreIP (OldIP);
3207
3209
return LtGRFunc;
3208
3210
}
3209
3211
3210
3212
Function *OpenMPIRBuilder::emitGlobalToListCopyFunction (
3211
3213
ArrayRef<ReductionInfo> ReductionInfos, Type *ReductionsBufferTy,
3212
3214
AttributeList FuncAttrs) {
3213
- OpenMPIRBuilder::InsertPointTy OldIP = Builder. saveIP ( );
3215
+ IRBuilder<>::InsertPointGuard IPG (Builder );
3214
3216
LLVMContext &Ctx = M.getContext ();
3215
3217
FunctionType *FuncTy = FunctionType::get (
3216
3218
Builder.getVoidTy (),
@@ -3226,6 +3228,7 @@ Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
3226
3228
3227
3229
BasicBlock *EntryBlock = BasicBlock::Create (Ctx, " entry" , LtGCFunc);
3228
3230
Builder.SetInsertPoint (EntryBlock);
3231
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3229
3232
3230
3233
// Buffer: global reduction buffer.
3231
3234
Argument *BufferArg = LtGCFunc->getArg (0 );
@@ -3311,14 +3314,13 @@ Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
3311
3314
}
3312
3315
3313
3316
Builder.CreateRetVoid ();
3314
- Builder.restoreIP (OldIP);
3315
3317
return LtGCFunc;
3316
3318
}
3317
3319
3318
3320
Function *OpenMPIRBuilder::emitGlobalToListReduceFunction (
3319
3321
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
3320
3322
Type *ReductionsBufferTy, AttributeList FuncAttrs) {
3321
- OpenMPIRBuilder::InsertPointTy OldIP = Builder. saveIP ( );
3323
+ IRBuilder<>::InsertPointGuard IPG (Builder );
3322
3324
LLVMContext &Ctx = M.getContext ();
3323
3325
auto *FuncTy = FunctionType::get (
3324
3326
Builder.getVoidTy (),
@@ -3334,6 +3336,7 @@ Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
3334
3336
3335
3337
BasicBlock *EntryBlock = BasicBlock::Create (Ctx, " entry" , LtGRFunc);
3336
3338
Builder.SetInsertPoint (EntryBlock);
3339
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3337
3340
3338
3341
// Buffer: global reduction buffer.
3339
3342
Argument *BufferArg = LtGRFunc->getArg (0 );
@@ -3394,7 +3397,6 @@ Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
3394
3397
Builder.CreateCall (ReduceFn, {ReduceList, ReductionList})
3395
3398
->addFnAttr (Attribute::NoUnwind);
3396
3399
Builder.CreateRetVoid ();
3397
- Builder.restoreIP (OldIP);
3398
3400
return LtGRFunc;
3399
3401
}
3400
3402
@@ -3407,6 +3409,7 @@ std::string OpenMPIRBuilder::getReductionFuncName(StringRef Name) const {
3407
3409
Expected<Function *> OpenMPIRBuilder::createReductionFunction (
3408
3410
StringRef ReducerName, ArrayRef<ReductionInfo> ReductionInfos,
3409
3411
ReductionGenCBKind ReductionGenCBKind, AttributeList FuncAttrs) {
3412
+ IRBuilder<>::InsertPointGuard IPG (Builder);
3410
3413
auto *FuncTy = FunctionType::get (Builder.getVoidTy (),
3411
3414
{Builder.getPtrTy (), Builder.getPtrTy ()},
3412
3415
/* IsVarArg */ false );
@@ -3419,6 +3422,7 @@ Expected<Function *> OpenMPIRBuilder::createReductionFunction(
3419
3422
BasicBlock *EntryBB =
3420
3423
BasicBlock::Create (M.getContext (), " entry" , ReductionFunc);
3421
3424
Builder.SetInsertPoint (EntryBB);
3425
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3422
3426
3423
3427
// Need to alloca memory here and deal with the pointers before getting
3424
3428
// LHS/RHS pointers out
@@ -3746,10 +3750,12 @@ static Error populateReductionFunction(
3746
3750
Function *ReductionFunc,
3747
3751
ArrayRef<OpenMPIRBuilder::ReductionInfo> ReductionInfos,
3748
3752
IRBuilder<> &Builder, ArrayRef<bool > IsByRef, bool IsGPU) {
3753
+ IRBuilder<>::InsertPointGuard IPG (Builder);
3749
3754
Module *Module = ReductionFunc->getParent ();
3750
3755
BasicBlock *ReductionFuncBlock =
3751
3756
BasicBlock::Create (Module->getContext (), " " , ReductionFunc);
3752
3757
Builder.SetInsertPoint (ReductionFuncBlock);
3758
+ Builder.SetCurrentDebugLocation (llvm::DebugLoc ());
3753
3759
Value *LHSArrayPtr = nullptr ;
3754
3760
Value *RHSArrayPtr = nullptr ;
3755
3761
if (IsGPU) {
0 commit comments