Skip to content

Commit

Permalink
possibly fixed empty container problem
Browse files Browse the repository at this point in the history
  • Loading branch information
eliecuevas committed Dec 19, 2024
1 parent 5d642f2 commit 466b163
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions clang/lib/CodeGen/CGCilk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#include "CGCleanup.h"
#include "clang/AST/ExprCilk.h"
#include "clang/AST/StmtCilk.h"
#include <iostream>

using namespace clang;
using namespace CodeGen;
using namespace std;

CodeGenFunction::IsSpawnedScope::IsSpawnedScope(CodeGenFunction *CGF)
: CGF(CGF), OldIsSpawned(CGF->IsSpawned),
Expand Down Expand Up @@ -530,16 +532,27 @@ CodeGenFunction::EmitCilkForRangeStmt(const CilkForRangeStmt &S,
// increment, the continue scope will be overwritten later.
JumpDest Continue = getJumpDestInCurrentScope("pfor.cond");
llvm::BasicBlock *CondBlock = Continue.getBlock();

// TODO: need to check condition and then get to pfor.end
llvm::BasicBlock *InitialEntryBlock = createBasicBlock("pfor.initial.entry");
EmitBlock(InitialEntryBlock);
llvm::Value *InitialBoolCondVal = EvaluateExprAsBool(S.getCond());
// llvm::MDNode *Weights =
// createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));

// Do we need weights?
Builder.CreateCondBr(InitialBoolCondVal, Continue.getBlock(), LoopExit.getBlock());



EmitBlock(CondBlock);
Expr::EvalResult Result;
bool CondIsConstInt = S.getCond()->EvaluateAsInt(Result, getContext());

LoopStack.setSpawnStrategy(LoopAttributes::DAC);
const SourceRange &R = S.getSourceRange();
LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs,
SourceLocToDebugLoc(R.getBegin()),
SourceLocToDebugLoc(R.getEnd()),
checkIfLoopMustProgress(CondIsConstInt));
SourceLocToDebugLoc(R.getEnd()));

const Expr *Inc = S.getInc();
assert(Inc && "_Cilk_for range loop has no increment");
Expand Down

0 comments on commit 466b163

Please sign in to comment.