Skip to content
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

Cilk For-Range Loop #301

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0045572
running version of PR - unintended behavior with empty containers
eliecuevas Nov 1, 2024
3d155db
remove unneeded namespace
eliecuevas Nov 1, 2024
cff34c8
possibly fixed empty container problem
eliecuevas Nov 17, 2024
a34857c
fixed forrangelooptest
eliecuevas Dec 18, 2024
1bebf7c
fixed ir test
eliecuevas Dec 18, 2024
0a4f5c2
Call llvm.reducer.register to register hyperobject struct members
VoxSciurorum Dec 27, 2023
9c63d33
Automatically register hyperobject struct members in C++
VoxSciurorum Dec 30, 2023
3809fcb
Structs with hyperobject members can not be treated as aggregates
VoxSciurorum Jan 2, 2024
ffcb02b
Mark destructor of hyperobject member referenced
VoxSciurorum Feb 7, 2024
dcbd7cd
Test for reducer struct member register and unregister.
VoxSciurorum Aug 27, 2024
5dc4299
Hyperobject struct members must be initialized
VoxSciurorum Sep 6, 2024
31e7041
Field construction should ignore hyperobject wrapper
VoxSciurorum Oct 29, 2024
135e05b
Unregister a hyperobject field before calling its destructor
VoxSciurorum Oct 31, 2024
c16797f
Test for hyperobject fields
VoxSciurorum Oct 31, 2024
7c95874
[runtimes] Make sure that llvm-link is available to build cheetah or …
neboat Nov 3, 2024
b2077c2
Remove unused HyperToken attribute
VoxSciurorum Aug 23, 2024
c93a777
[AST] Fix inconsistencies in handling of Hyperobject types in the AST.
neboat Nov 16, 2024
d9215c4
[test/Cilk] Fix test case failure on macOS.
neboat Nov 12, 2024
dbd6822
[InlineFunction] Fix inlining to properly forward inlined resume inst…
neboat Nov 12, 2024
50581a7
[TaskSimplify] Fix task-simplify to handle unusual inputs generated b…
neboat Nov 12, 2024
86b4650
[TapirUtils] Remove taskframe.resume instructions when removing taskf…
neboat Nov 12, 2024
41e56a7
[TapirTaskInfo] Add first set of methods to update TaskInfo analysis …
neboat Nov 12, 2024
272979f
[TapirUtils] Perform basic updates to TaskInfo analysis when serializ…
neboat Nov 12, 2024
a4bd496
[CGCilk] Fix code generation of normal cleanup destination slot aroun…
neboat Nov 22, 2024
998e4ee
Use lighter weight map accesses
VoxSciurorum Nov 20, 2024
b61001d
[SemaExpr] Fix hyperobject-lookup lvalue conversion involving qualifi…
neboat Nov 30, 2024
689bfa0
[CilkSanitizer] Ensure that __csan_task and __csan_detach_continue ho…
neboat Dec 1, 2024
0294110
[CilkSanitizer] Add support to synthesize hooks, such as __csan_llvm_…
neboat Dec 1, 2024
cc3f501
View types should not be const or volatile
VoxSciurorum Dec 1, 2024
91955ac
Improve handling of unsupported view types
VoxSciurorum Dec 3, 2024
d7a4e80
[Verifier] Improve verifier checks of Tapir taskframes and intrinsics.
neboat Dec 7, 2024
3e1fe77
[Tapir] Improve logic for inserting and cleaning up taskframe intrins…
neboat Dec 7, 2024
1bcb243
[SimplifyCFG] To handle test cases with no syncregion intrinsic, avoi…
neboat Dec 7, 2024
7bb89bd
[TapirUtils] Fix logic to insert fixups for outputs of taskframes.
neboat Dec 7, 2024
13b7894
[Verifier] Require Tapir instructions to have valid syncregions.
neboat Dec 7, 2024
e5750da
[ToolChains] Remove linker flags to wrap cilkrts hyperobject methods …
neboat Dec 7, 2024
897c786
[lld] Add flag to specify a Cilk tool to use, such as Cilkscale, that…
neboat Dec 7, 2024
0721c07
[clang] Fix handling of Cilkscale tool variants, specifically cilksca…
neboat Dec 7, 2024
80ad569
[CSI] Mark CSI hooks as does-not-throw and limited memory effects.
neboat Dec 7, 2024
9baa8f8
[CI] Update setup-python action to v5 for GHA (#95414)
DeinAlptraum Jun 13, 2024
ddf5c88
[github] Switch to using Ubuntu 22.04 image to work around Python issue.
neboat Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
with:
fetch-depth: 1
- name: Setup Python env
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/llvm-project-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
required: false
os_list:
required: false
default: '["ubuntu-latest", "windows-2019", "macOS-13"]'
default: '["ubuntu-22.04", "windows-2019", "macOS-13"]'
python_version:
required: false
type: string
Expand All @@ -39,7 +39,7 @@ on:
type: string
# Use windows-2019 due to:
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
default: '["ubuntu-latest", "macOS-13"]'
default: '["ubuntu-22.04", "macOS-13"]'

python_version:
required: false
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
# lldb. Using this setup-python action to make 3.10 the default
# python fixes this.
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
- name: Install Ninja
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
clangformat: 17.0.1

- name: Setup Python env
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Python env
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
cache: 'pip'
cache-dependency-path: './llvm/docs/requirements.txt'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Setup Python env
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
cache: 'pip'
cache-dependency-path: './llvm/docs/requirements.txt'
Expand Down
6 changes: 5 additions & 1 deletion clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,11 @@ enum CXCursorKind {
*/
CXCursor_CilkScopeStmt = 311,

CXCursor_LastStmt = CXCursor_CilkScopeStmt,
/** A _Cilk_for range statement.
*/
CXCursor_CilkForRangeStmt = 312,

CXCursor_LastStmt = CXCursor_CilkForRangeStmt,

/**
* Cursor that represents the translation unit itself.
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1332,9 +1332,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
return CanQualType::CreateUnsafe(getComplexType((QualType) T));
}

QualType getHyperobjectType(QualType T, Expr *R, Expr *I) const;
CanQualType getHyperobjectType(CanQualType T, Expr *R, Expr *I) const {
return CanQualType::CreateUnsafe(getHyperobjectType((QualType) T, R, I));
QualType getHyperobjectType(QualType T, Expr *I, Expr *R) const;
CanQualType getHyperobjectType(CanQualType T, Expr *I, Expr *R) const {
return CanQualType::CreateUnsafe(getHyperobjectType((QualType) T, I, R));
}

/// Return the uniqued reference to the type for a pointer to
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,7 @@ DEF_TRAVERSE_STMT(CilkForStmt, {
}
})
DEF_TRAVERSE_STMT(CilkScopeStmt, {})
DEF_TRAVERSE_STMT(CilkForRangeStmt, {})

// These operators (all of them) do not need any action except
// iterating over the children.
Expand Down
76 changes: 76 additions & 0 deletions clang/include/clang/AST/StmtCilk.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define LLVM_CLANG_AST_STMTCILK_H

#include "clang/AST/Stmt.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Basic/SourceLocation.h"

namespace clang {
Expand Down Expand Up @@ -92,6 +93,81 @@ class CilkSyncStmt : public Stmt {
}
};

/// CilkForRangeStmt - This represents a '_Cilk_for(range-declarator :
/// range-expression)' or a '_Cilk_for (init-statement range-declarator :
/// range-expression)', based on a CXXForRangeStmt which is a C++0x
/// [stmt.ranged]'s ranged for stmt
///
/// This is stored as a FORRANGE stmt embedded inside a CILKFORRANGE with some
/// other necessary semantic components.
class CilkForRangeStmt : public Stmt {
enum {
FORRANGE,
LOOPINDEX,
LOOPINDEXSTMT,
LOCALLOOPINDEX,
LIMIT,
COND,
INC,
END
};
Stmt *SubExprs[END];

public:
CilkForRangeStmt(const ASTContext &C, CXXForRangeStmt *ForRange,
VarDecl *LoopIndex, DeclStmt *LocalLoopIndex,
DeclStmt *Limit, Expr *Cond, Expr *Inc,
DeclStmt *LoopIndexStmt);

/// \brief Build an empty cilk for range statement.
explicit CilkForRangeStmt(EmptyShell Empty)
: Stmt(CilkForRangeStmtClass, Empty) {}

static bool classof(const Stmt *T) {
return T->getStmtClass() == CilkForRangeStmtClass;
}

CXXForRangeStmt *getCXXForRangeStmt() const;

void setForRange(Stmt *S) { SubExprs[FORRANGE] = S; }

VarDecl *getLoopIndex() const;
void setLoopIndex(const ASTContext &C, VarDecl *V);

VarDecl *getLocalLoopIndex();
const VarDecl *getLocalLoopIndex() const;

Expr *getCond() { return reinterpret_cast<Expr *>(SubExprs[COND]); }
Expr *getInc() { return reinterpret_cast<Expr *>(SubExprs[INC]); }
DeclStmt *getLoopIndexStmt() {
return cast_or_null<DeclStmt>(SubExprs[LOOPINDEXSTMT]);
}
DeclStmt *getLimitStmt() { return cast_or_null<DeclStmt>(SubExprs[LIMIT]); }
DeclStmt *getLocalLoopIndexStmt() {
return cast<DeclStmt>(SubExprs[LOCALLOOPINDEX]);
}

const Expr *getCond() const {
return reinterpret_cast<Expr *>(SubExprs[COND]);
}
const Expr *getInc() const { return reinterpret_cast<Expr *>(SubExprs[INC]); }
const DeclStmt *getLoopIndexStmt() const {
return cast_or_null<DeclStmt>(SubExprs[LOOPINDEXSTMT]);
}
const DeclStmt *getLimitStmt() const {
return cast_or_null<DeclStmt>(SubExprs[LIMIT]);
}
const DeclStmt *getLocalLoopIndexStmt() const {
return cast<DeclStmt>(SubExprs[LOCALLOOPINDEX]);
}

SourceLocation getBeginLoc() const LLVM_READONLY;
SourceLocation getEndLoc() const LLVM_READONLY;

// Iterators
child_range children() { return child_range(&SubExprs[0], &SubExprs[END]); }
};

/// CilkForStmt - This represents a '_Cilk_for(init;cond;inc)' stmt.
class CilkForStmt : public Stmt {
SourceLocation CilkForLoc;
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/AST/TypeProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ let Class = HyperobjectType in {
def : Property<"elementType", QualType> {
let Read = [{ node->getElementType() }];
}
def : Property<"reduce", ExprRef> {
let Read = [{ node->getReduce() }];
}
def : Property<"identity", ExprRef> {
let Read = [{ node->getIdentity() }];
}
def : Property<"reduce", ExprRef> {
let Read = [{ node->getReduce() }];
}

def : Creator<[{
return ctx.getHyperobjectType(elementType, reduce, identity);
return ctx.getHyperobjectType(elementType, identity, reduce);
}]>;
}

Expand Down
6 changes: 0 additions & 6 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -4501,12 +4501,6 @@ def HyperView : InheritableAttr {
let Documentation = [StrandMallocDocs];
}

def HyperToken : InheritableAttr {
let Spellings = [Clang<"hyper_token">];
let Subjects = SubjectList<[FunctionLike]>;
let Documentation = [StrandMallocDocs];
}

def ReducerRegister : InheritableAttr {
let Spellings = [Clang<"reducer_register">];
let Subjects = SubjectList<[FunctionLike]>;
Expand Down
5 changes: 3 additions & 2 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,6 @@ def err_cilk_for_missing_increment: Error<
"missing loop increment expression in 'cilk_for'">;
def err_cilk_for_missing_semi: Error<
"expected ';' in 'cilk_for'">;
def err_cilk_for_forrange_loop_not_supported: Error<
"'cilk_for' not supported on for-range loops">;
def err_cilk_for_foreach_loop_not_supported: Error<
"'cilk_for' not supported on for-each loops">;
def err_pragma_cilk_invalid_option : Error<
Expand All @@ -1401,6 +1399,9 @@ def warn_cilk_for_following_grainsize: Warning<
def warn_pragma_cilk_grainsize_equals: Warning<
"'#pragma cilk grainsize' no longer requires '='">,
InGroup<SourceUsesCilkPlus>;
def warn_cilk_for_forrange_loop_experimental: Warning<
"'cilk_for' support for for-range loops is currently EXPERIMENTAL only!">,
InGroup<SourceUsesCilkPlus>;
def error_hyperobject_arguments: Error<
"hyperobject must have 0 or 2 callbacks">;

Expand Down
16 changes: 12 additions & 4 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -5896,7 +5896,7 @@ def note_deleted_special_member_class_subobject : Note<
def note_deleted_default_ctor_uninit_field : Note<
"%select{default constructor of|constructor inherited by}0 "
"%1 is implicitly deleted because field %2 of "
"%select{reference|const-qualified}4 type %3 would not be initialized">;
"%select{reference|const-qualified|reducer}4 type %3 would not be initialized">;
def note_deleted_default_ctor_all_const : Note<
"%select{default constructor of|constructor inherited by}0 "
"%1 is implicitly deleted because all "
Expand Down Expand Up @@ -10892,11 +10892,14 @@ def confusing_hyperobject : Error<
def incomplete_hyperobject : Error<
"incomplete type %0 may not be a hyperobject">;

def qualified_hyperobject : Error<
"qualified type %0 may not be a hyperobject">;

def nested_hyperobject : Error<
"type %0, which contains a hyperobject, may not be a hyperobject">;

def reducer_callbacks_not_allowed: Warning<
"reducer callbacks not implemented for structure members">,
def reducer_registration_not_implemented: Warning<
"reducer registration not implemented for structure members">,
InGroup<CilkIgnored>;

def err_invalid_reducer_callback : Error<
Expand All @@ -10916,7 +10919,12 @@ def err_hyperobject_struct_assign : Error<
def no_reducer_array : Warning<
"array of reducer not implemented">,
InGroup<CilkIgnored>;
} // end of Cilk category

// cilk for_range
def err_cilk_for_range_end_minus_begin : Error<
"Cannot determine length with '__end - __begin'. Please use a random access iterator.">;
}
// end of Cilk category

let CategoryName = "OpenMP Issue" in {
// OpenMP support.
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/StmtNodes.td
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def CilkSpawnStmt : StmtNode<Stmt>;
def CilkSpawnExpr : StmtNode<Expr>;
def CilkForStmt : StmtNode<Stmt>;
def CilkScopeStmt : StmtNode<Stmt>;
def CilkForRangeStmt: StmtNode<Stmt>;

// OpenMP Directives.
def OMPCanonicalLoop : StmtNode<Stmt>;
Expand Down
8 changes: 7 additions & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -5332,7 +5332,13 @@ class Sema final {
SourceLocation RParenLoc, Stmt *Body,
DeclStmt *LoopVar = nullptr,
Expr *OgCond = nullptr, Expr *OgInc = nullptr);

StmtResult ActOnCilkForRangeStmt(Scope *S, SourceLocation ForLoc,
Stmt *InitStmt, Stmt *First,
SourceLocation ColonLoc, Expr *Range,
SourceLocation RParenLoc,
BuildForRangeKind Kind);
StmtResult BuildCilkForRangeStmt(CXXForRangeStmt *S);
StmtResult FinishCilkForRangeStmt(Stmt *S, Stmt *B);
StmtResult BuildCilkForStmt(SourceLocation CilkForLoc,
SourceLocation LParenLoc,
Stmt *Init, Expr *Cond, Expr *Inc,
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Serialization/ASTBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ enum StmtCode {
STMT_CILKSYNC,
STMT_CILKFOR,
STMT_CILKSCOPE,
STMT_CILKFORRANGE,
};

/// The kinds of designators that can occur in a
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ ExpectedType ASTNodeImporter::VisitHyperobjectType(const HyperobjectType *T) {
return ToReduceOrErr.takeError();

return Importer.getToContext().getHyperobjectType(
*ToElementTypeOrErr, *ToReduceOrErr, *ToIdentityOrErr);
*ToElementTypeOrErr, *ToIdentityOrErr, *ToReduceOrErr);
}

ExpectedType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTStructuralEquivalence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
const HyperobjectType *H2 = cast<HyperobjectType>(T2);
Expr *R1 = H1->getReduce(), *R2 = H2->getReduce();
Expr *I1 = H1->getIdentity(), *I2 = H2->getIdentity();
if (!!I2 != !!I2 || !!R1 != !!R2)
if (!!I1 != !!I2 || !!R1 != !!R2)
return false;
if (I1 && !IsStructurallyEquivalent(Context, I1, I2))
return false;
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,15 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().DefaultedCopyConstructorIsDeleted = true;
}

if (T->isHyperobjectType()) {
// Do not allow braced list initialization, which would
// suppress hyperobject registration.
data().Aggregate = false;
data().HasIrrelevantDestructor = false;
data().HasTrivialSpecialMembers &= ~SMF_All;
data().HasTrivialSpecialMembersForCall &= ~SMF_All;
}

if (!Field->hasInClassInitializer() && !Field->isMutable()) {
if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
Expand Down
Loading