-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[OMPIRBuilder] Add support for explicit deallocation points #154752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/skatrak/flang-generic-06-openmp-opt
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1886,20 +1886,21 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) { | |
const CapturedStmt *CS = S.getCapturedStmt(OMPD_parallel); | ||
const Stmt *ParallelRegionBodyStmt = CS->getCapturedStmt(); | ||
|
||
auto BodyGenCB = [&, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [&, this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPOutlinedRegionBody( | ||
*this, ParallelRegionBodyStmt, AllocaIP, CodeGenIP, "parallel"); | ||
*this, ParallelRegionBodyStmt, AllocIP, CodeGenIP, "parallel"); | ||
return llvm::Error::success(); | ||
}; | ||
|
||
CGCapturedStmtInfo CGSI(*CS, CR_OpenMP); | ||
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI); | ||
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP( | ||
AllocaInsertPt->getParent(), AllocaInsertPt->getIterator()); | ||
llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail( | ||
OMPBuilder.createParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB, | ||
IfCond, NumThreads, ProcBind, S.hasCancel())); | ||
llvm::OpenMPIRBuilder::InsertPointTy AfterIP = | ||
cantFail(OMPBuilder.createParallel( | ||
Builder, AllocaIP, /*DeallocIPs=*/{}, BodyGenCB, PrivCB, FiniCB, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will happen with Clang if deallocation is needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, the only code path that uses the If at some point explicit allocations were introduced for the host at the |
||
IfCond, NumThreads, ProcBind, S.hasCancel())); | ||
Builder.restoreIP(AfterIP); | ||
return; | ||
} | ||
|
@@ -4427,21 +4428,23 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) { | |
llvm::SmallVector<BodyGenCallbackTy, 4> SectionCBVector; | ||
if (CS) { | ||
for (const Stmt *SubStmt : CS->children()) { | ||
auto SectionCB = [this, SubStmt](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, SubStmt, AllocaIP, CodeGenIP, "section"); | ||
auto SectionCB = [this, SubStmt](InsertPointTy AllocIP, | ||
InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody(*this, SubStmt, AllocIP, | ||
CodeGenIP, "section"); | ||
return llvm::Error::success(); | ||
}; | ||
SectionCBVector.push_back(SectionCB); | ||
} | ||
} else { | ||
auto SectionCB = [this, CapturedStmt](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, CapturedStmt, AllocaIP, CodeGenIP, "section"); | ||
return llvm::Error::success(); | ||
}; | ||
auto SectionCB = | ||
[this, CapturedStmt](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, CapturedStmt, AllocIP, CodeGenIP, "section"); | ||
return llvm::Error::success(); | ||
}; | ||
SectionCBVector.push_back(SectionCB); | ||
} | ||
|
||
|
@@ -4495,10 +4498,11 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &S) { | |
return llvm::Error::success(); | ||
}; | ||
|
||
auto BodyGenCB = [SectionRegionBodyStmt, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [SectionRegionBodyStmt, | ||
this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, SectionRegionBodyStmt, AllocaIP, CodeGenIP, "section"); | ||
*this, SectionRegionBodyStmt, AllocIP, CodeGenIP, "section"); | ||
return llvm::Error::success(); | ||
}; | ||
|
||
|
@@ -4580,10 +4584,11 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { | |
return llvm::Error::success(); | ||
}; | ||
|
||
auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [MasterRegionBodyStmt, | ||
this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, MasterRegionBodyStmt, AllocaIP, CodeGenIP, "master"); | ||
*this, MasterRegionBodyStmt, AllocIP, CodeGenIP, "master"); | ||
return llvm::Error::success(); | ||
}; | ||
|
||
|
@@ -4630,10 +4635,11 @@ void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) { | |
return llvm::Error::success(); | ||
}; | ||
|
||
auto BodyGenCB = [MaskedRegionBodyStmt, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [MaskedRegionBodyStmt, | ||
this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, MaskedRegionBodyStmt, AllocaIP, CodeGenIP, "masked"); | ||
*this, MaskedRegionBodyStmt, AllocIP, CodeGenIP, "masked"); | ||
return llvm::Error::success(); | ||
}; | ||
|
||
|
@@ -4673,10 +4679,11 @@ void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) { | |
return llvm::Error::success(); | ||
}; | ||
|
||
auto BodyGenCB = [CriticalRegionBodyStmt, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [CriticalRegionBodyStmt, | ||
this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, CriticalRegionBodyStmt, AllocaIP, CodeGenIP, "critical"); | ||
*this, CriticalRegionBodyStmt, AllocIP, CodeGenIP, "critical"); | ||
return llvm::Error::success(); | ||
}; | ||
|
||
|
@@ -5643,8 +5650,8 @@ void CodeGenFunction::EmitOMPTaskgroupDirective( | |
InsertPointTy AllocaIP(AllocaInsertPt->getParent(), | ||
AllocaInsertPt->getIterator()); | ||
|
||
auto BodyGenCB = [&, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [&, this](InsertPointTy AllocIP, InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
Builder.restoreIP(CodeGenIP); | ||
EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt()); | ||
return llvm::Error::success(); | ||
|
@@ -5653,7 +5660,8 @@ void CodeGenFunction::EmitOMPTaskgroupDirective( | |
if (!CapturedStmtInfo) | ||
CapturedStmtInfo = &CapStmtInfo; | ||
llvm::OpenMPIRBuilder::InsertPointTy AfterIP = | ||
cantFail(OMPBuilder.createTaskgroup(Builder, AllocaIP, BodyGenCB)); | ||
cantFail(OMPBuilder.createTaskgroup(Builder, AllocaIP, | ||
/*DeallocIPs=*/{}, BodyGenCB)); | ||
Builder.restoreIP(AfterIP); | ||
return; | ||
} | ||
|
@@ -6233,8 +6241,9 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) { | |
return llvm::Error::success(); | ||
}; | ||
|
||
auto BodyGenCB = [&S, C, this](InsertPointTy AllocaIP, | ||
InsertPointTy CodeGenIP) { | ||
auto BodyGenCB = [&S, C, this](InsertPointTy AllocIP, | ||
InsertPointTy CodeGenIP, | ||
ArrayRef<InsertPointTy> DeallocIPs) { | ||
Builder.restoreIP(CodeGenIP); | ||
|
||
const CapturedStmt *CS = S.getInnermostCapturedStmt(); | ||
|
@@ -6251,7 +6260,7 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) { | |
OutlinedFn, CapturedVars); | ||
} else { | ||
OMPBuilderCBHelpers::EmitOMPInlinedRegionBody( | ||
*this, CS->getCapturedStmt(), AllocaIP, CodeGenIP, "ordered"); | ||
*this, CS->getCapturedStmt(), AllocIP, CodeGenIP, "ordered"); | ||
} | ||
return llvm::Error::success(); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we gain very little from renaming
AllocaIP
->AllocIP
. But this change is bloating the overall diff quite a lot, and also unnecessarily taints the git history for these.I'd suggest reverting this.