Skip to content

Commit 7d7f381

Browse files
authored
Revert "[OMPIRBuilder] Don't use invalid debug loc in reduction functions." (#150832)
Reverts #147950 I noticed some fails in the reduction tests with clang after this change. I need to understand the failures better. Reverting this for now.
1 parent f3c750f commit 7d7f381

File tree

2 files changed

+10
-137
lines changed

2 files changed

+10
-137
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ void OpenMPIRBuilder::emitReductionListCopy(
26172617
Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction(
26182618
const LocationDescription &Loc, ArrayRef<ReductionInfo> ReductionInfos,
26192619
AttributeList FuncAttrs) {
2620-
IRBuilder<>::InsertPointGuard IPG(Builder);
2620+
InsertPointTy SavedIP = Builder.saveIP();
26212621
LLVMContext &Ctx = M.getContext();
26222622
FunctionType *FuncTy = FunctionType::get(
26232623
Builder.getVoidTy(), {Builder.getPtrTy(), Builder.getInt32Ty()},
@@ -2630,7 +2630,6 @@ Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction(
26302630
WcFunc->addParamAttr(1, Attribute::NoUndef);
26312631
BasicBlock *EntryBB = BasicBlock::Create(M.getContext(), "entry", WcFunc);
26322632
Builder.SetInsertPoint(EntryBB);
2633-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
26342633

26352634
// ReduceList: thread local Reduce list.
26362635
// At the stage of the computation when this function is called, partially
@@ -2845,6 +2844,7 @@ Expected<Function *> OpenMPIRBuilder::emitInterWarpCopyFunction(
28452844
}
28462845

28472846
Builder.CreateRetVoid();
2847+
Builder.restoreIP(SavedIP);
28482848

28492849
return WcFunc;
28502850
}
@@ -2853,7 +2853,6 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
28532853
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
28542854
AttributeList FuncAttrs) {
28552855
LLVMContext &Ctx = M.getContext();
2856-
IRBuilder<>::InsertPointGuard IPG(Builder);
28572856
FunctionType *FuncTy =
28582857
FunctionType::get(Builder.getVoidTy(),
28592858
{Builder.getPtrTy(), Builder.getInt16Ty(),
@@ -2872,7 +2871,6 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
28722871
SarFunc->addParamAttr(3, Attribute::SExt);
28732872
BasicBlock *EntryBB = BasicBlock::Create(M.getContext(), "entry", SarFunc);
28742873
Builder.SetInsertPoint(EntryBB);
2875-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
28762874

28772875
// Thread local Reduce list used to host the values of data to be reduced.
28782876
Argument *ReduceListArg = SarFunc->getArg(0);
@@ -3019,7 +3017,7 @@ Function *OpenMPIRBuilder::emitShuffleAndReduceFunction(
30193017
Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
30203018
ArrayRef<ReductionInfo> ReductionInfos, Type *ReductionsBufferTy,
30213019
AttributeList FuncAttrs) {
3022-
IRBuilder<>::InsertPointGuard IPG(Builder);
3020+
OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
30233021
LLVMContext &Ctx = M.getContext();
30243022
FunctionType *FuncTy = FunctionType::get(
30253023
Builder.getVoidTy(),
@@ -3035,7 +3033,6 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
30353033

30363034
BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGCFunc);
30373035
Builder.SetInsertPoint(EntryBlock);
3038-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
30393036

30403037
// Buffer: global reduction buffer.
30413038
Argument *BufferArg = LtGCFunc->getArg(0);
@@ -3123,13 +3120,14 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
31233120
}
31243121

31253122
Builder.CreateRetVoid();
3123+
Builder.restoreIP(OldIP);
31263124
return LtGCFunc;
31273125
}
31283126

31293127
Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
31303128
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
31313129
Type *ReductionsBufferTy, AttributeList FuncAttrs) {
3132-
IRBuilder<>::InsertPointGuard IPG(Builder);
3130+
OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
31333131
LLVMContext &Ctx = M.getContext();
31343132
FunctionType *FuncTy = FunctionType::get(
31353133
Builder.getVoidTy(),
@@ -3145,7 +3143,6 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
31453143

31463144
BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGRFunc);
31473145
Builder.SetInsertPoint(EntryBlock);
3148-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
31493146

31503147
// Buffer: global reduction buffer.
31513148
Argument *BufferArg = LtGRFunc->getArg(0);
@@ -3206,13 +3203,14 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
32063203
Builder.CreateCall(ReduceFn, {LocalReduceListAddrCast, ReduceList})
32073204
->addFnAttr(Attribute::NoUnwind);
32083205
Builder.CreateRetVoid();
3206+
Builder.restoreIP(OldIP);
32093207
return LtGRFunc;
32103208
}
32113209

32123210
Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
32133211
ArrayRef<ReductionInfo> ReductionInfos, Type *ReductionsBufferTy,
32143212
AttributeList FuncAttrs) {
3215-
IRBuilder<>::InsertPointGuard IPG(Builder);
3213+
OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
32163214
LLVMContext &Ctx = M.getContext();
32173215
FunctionType *FuncTy = FunctionType::get(
32183216
Builder.getVoidTy(),
@@ -3228,7 +3226,6 @@ Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
32283226

32293227
BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGCFunc);
32303228
Builder.SetInsertPoint(EntryBlock);
3231-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
32323229

32333230
// Buffer: global reduction buffer.
32343231
Argument *BufferArg = LtGCFunc->getArg(0);
@@ -3314,13 +3311,14 @@ Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
33143311
}
33153312

33163313
Builder.CreateRetVoid();
3314+
Builder.restoreIP(OldIP);
33173315
return LtGCFunc;
33183316
}
33193317

33203318
Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
33213319
ArrayRef<ReductionInfo> ReductionInfos, Function *ReduceFn,
33223320
Type *ReductionsBufferTy, AttributeList FuncAttrs) {
3323-
IRBuilder<>::InsertPointGuard IPG(Builder);
3321+
OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP();
33243322
LLVMContext &Ctx = M.getContext();
33253323
auto *FuncTy = FunctionType::get(
33263324
Builder.getVoidTy(),
@@ -3336,7 +3334,6 @@ Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
33363334

33373335
BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGRFunc);
33383336
Builder.SetInsertPoint(EntryBlock);
3339-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
33403337

33413338
// Buffer: global reduction buffer.
33423339
Argument *BufferArg = LtGRFunc->getArg(0);
@@ -3397,6 +3394,7 @@ Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
33973394
Builder.CreateCall(ReduceFn, {ReduceList, ReductionList})
33983395
->addFnAttr(Attribute::NoUnwind);
33993396
Builder.CreateRetVoid();
3397+
Builder.restoreIP(OldIP);
34003398
return LtGRFunc;
34013399
}
34023400

@@ -3409,7 +3407,6 @@ std::string OpenMPIRBuilder::getReductionFuncName(StringRef Name) const {
34093407
Expected<Function *> OpenMPIRBuilder::createReductionFunction(
34103408
StringRef ReducerName, ArrayRef<ReductionInfo> ReductionInfos,
34113409
ReductionGenCBKind ReductionGenCBKind, AttributeList FuncAttrs) {
3412-
IRBuilder<>::InsertPointGuard IPG(Builder);
34133410
auto *FuncTy = FunctionType::get(Builder.getVoidTy(),
34143411
{Builder.getPtrTy(), Builder.getPtrTy()},
34153412
/* IsVarArg */ false);
@@ -3422,7 +3419,6 @@ Expected<Function *> OpenMPIRBuilder::createReductionFunction(
34223419
BasicBlock *EntryBB =
34233420
BasicBlock::Create(M.getContext(), "entry", ReductionFunc);
34243421
Builder.SetInsertPoint(EntryBB);
3425-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
34263422

34273423
// Need to alloca memory here and deal with the pointers before getting
34283424
// LHS/RHS pointers out
@@ -3750,12 +3746,10 @@ static Error populateReductionFunction(
37503746
Function *ReductionFunc,
37513747
ArrayRef<OpenMPIRBuilder::ReductionInfo> ReductionInfos,
37523748
IRBuilder<> &Builder, ArrayRef<bool> IsByRef, bool IsGPU) {
3753-
IRBuilder<>::InsertPointGuard IPG(Builder);
37543749
Module *Module = ReductionFunc->getParent();
37553750
BasicBlock *ReductionFuncBlock =
37563751
BasicBlock::Create(Module->getContext(), "", ReductionFunc);
37573752
Builder.SetInsertPoint(ReductionFuncBlock);
3758-
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
37593753
Value *LHSArrayPtr = nullptr;
37603754
Value *RHSArrayPtr = nullptr;
37613755
if (IsGPU) {

mlir/test/Target/LLVMIR/omptarget-debug-reduc-fn-loc.mlir

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)