Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/CGStmtOpenMP.cpp
Show First 20 Lines • Show All 1,513 Lines • ▼ Show 20 Lines | if (DoneBB) | ||||
EmitBlock(DoneBB, /*IsFinished=*/true); | EmitBlock(DoneBB, /*IsFinished=*/true); | ||||
} | } | ||||
static void emitAlignedClause(CodeGenFunction &CGF, | static void emitAlignedClause(CodeGenFunction &CGF, | ||||
const OMPExecutableDirective &D) { | const OMPExecutableDirective &D) { | ||||
if (!CGF.HaveInsertPoint()) | if (!CGF.HaveInsertPoint()) | ||||
return; | return; | ||||
for (const auto *Clause : D.getClausesOfKind<OMPAlignedClause>()) { | for (const auto *Clause : D.getClausesOfKind<OMPAlignedClause>()) { | ||||
unsigned ClauseAlignment = 0; | size_t ClauseAlignment = 0; | ||||
rsmith: It's not appropriate to assume that `size_t` is any bigger than `unsigned` or generally that… | |||||
if (const Expr *AlignmentExpr = Clause->getAlignment()) { | if (const Expr *AlignmentExpr = Clause->getAlignment()) { | ||||
auto *AlignmentCI = | auto *AlignmentCI = | ||||
cast<llvm::ConstantInt>(CGF.EmitScalarExpr(AlignmentExpr)); | cast<llvm::ConstantInt>(CGF.EmitScalarExpr(AlignmentExpr)); | ||||
ClauseAlignment = static_cast<unsigned>(AlignmentCI->getZExtValue()); | ClauseAlignment = AlignmentCI->getZExtValue(); | ||||
} | } | ||||
for (const Expr *E : Clause->varlists()) { | for (const Expr *E : Clause->varlists()) { | ||||
unsigned Alignment = ClauseAlignment; | size_t Alignment = ClauseAlignment; | ||||
if (Alignment == 0) { | if (Alignment == 0) { | ||||
// OpenMP [2.8.1, Description] | // OpenMP [2.8.1, Description] | ||||
// If no optional parameter is specified, implementation-defined default | // If no optional parameter is specified, implementation-defined default | ||||
// alignments for SIMD instructions on the target platforms are assumed. | // alignments for SIMD instructions on the target platforms are assumed. | ||||
Alignment = | Alignment = | ||||
CGF.getContext() | CGF.getContext() | ||||
.toCharUnitsFromBits(CGF.getContext().getOpenMPDefaultSimdAlign( | .toCharUnitsFromBits(CGF.getContext().getOpenMPDefaultSimdAlign( | ||||
E->getType()->getPointeeType())) | E->getType()->getPointeeType())) | ||||
.getQuantity(); | .getQuantity(); | ||||
} | } | ||||
assert((Alignment == 0 || llvm::isPowerOf2_32(Alignment)) && | assert((Alignment == 0 || llvm::isPowerOf2_32(Alignment)) && | ||||
"alignment is not power of 2"); | "alignment is not power of 2"); | ||||
if (Alignment != 0) { | if (Alignment != 0) { | ||||
llvm::Value *PtrValue = CGF.EmitScalarExpr(E); | llvm::Value *PtrValue = CGF.EmitScalarExpr(E); | ||||
CGF.EmitAlignmentAssumption( | CGF.EmitAlignmentAssumption( | ||||
PtrValue, E, /*No second loc needed*/ SourceLocation(), Alignment); | PtrValue, E, /*No second loc needed*/ SourceLocation(), | ||||
llvm::ConstantInt::get(CGF.SizeTy, Alignment)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void CodeGenFunction::EmitOMPPrivateLoopCounters( | void CodeGenFunction::EmitOMPPrivateLoopCounters( | ||||
const OMPLoopDirective &S, CodeGenFunction::OMPPrivateScope &LoopScope) { | const OMPLoopDirective &S, CodeGenFunction::OMPPrivateScope &LoopScope) { | ||||
if (!HaveInsertPoint()) | if (!HaveInsertPoint()) | ||||
▲ Show 20 Lines • Show All 3,629 Lines • Show Last 20 Lines |
It's not appropriate to assume that size_t is any bigger than unsigned or generally that it's meaningful on the target. If you want 64 bits here, use uint64_t, but the right choice is probably llvm::APInt.