Skip to content

Commit

Permalink
[nomp] Update nomp_run() to avoid passing jit variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thilinarmtb committed Dec 8, 2023
1 parent 12a8487 commit dfcf901
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions clang/lib/Parse/ParseNomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,22 +762,28 @@ static void CreateNompRunCall(llvm::SmallVector<Stmt *, 16> &Stmts,
DRE, nullptr, VK_PRValue, FPOptionsOverride()));

for (auto V : EV) {
QualType QT = V->getType();
// If the variable is a jit variable, we don't need to pass it to
// nomp_run() since it is already passed to nomp_jit().
const std::string name = V->getNameAsString();
if (std::find(jitVariables.begin(), jitVariables.end(), name) !=
jitVariables.end()) {
continue;
}

// Otherwise, pass a pointer to variable to nomp_run().
const QualType QT = V->getType();
const Type *T = QT.getTypePtrOrNull();
if (T) {
// Pointer to variable
DeclRefExpr *DRE =
DeclRefExpr::Create(AST, NestedNameSpecifierLoc(), SourceLocation(),
V, false, SourceLocation(), QT, VK_LValue);
if (T->isPointerType()) {
FuncArgs.push_back(
ImplicitCastExpr::Create(AST, QT, CastKind::CK_LValueToRValue, DRE,
nullptr, VK_PRValue, FPOptionsOverride()));
} else {
FuncArgs.push_back(UnaryOperator::Create(
AST, DRE, UO_AddrOf, AST.getPointerType(QT), VK_PRValue,
OK_Ordinary, SourceLocation(), false, FPOptionsOverride()));
}
DeclRefExpr *DRE =
DeclRefExpr::Create(AST, NestedNameSpecifierLoc(), SourceLocation(), V,
false, SourceLocation(), QT, VK_LValue);
if (T->isPointerType()) {
FuncArgs.push_back(
ImplicitCastExpr::Create(AST, QT, CastKind::CK_LValueToRValue, DRE,
nullptr, VK_PRValue, FPOptionsOverride()));
} else {
FuncArgs.push_back(UnaryOperator::Create(
AST, DRE, UO_AddrOf, AST.getPointerType(QT), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride()));
}
}

Expand Down

0 comments on commit dfcf901

Please sign in to comment.