Skip to content

Commit

Permalink
codegen: switch coverage counters from volatile to properly atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Apr 20, 2020
1 parent 54e8c00 commit 3e9d9af
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,16 +1195,14 @@ static uint64_t *allocLine(std::vector<logdata_block*> &vec, int line)
return &data[line];
}

static void visitLine(jl_codectx_t &ctx, std::vector<logdata_block*> &vec, int line, Value *addend, const char* name)
static void visitLine(jl_codectx_t &ctx, std::vector<logdata_block*> &vec, int line, Value *addend, const char *name)
{
uint64_t *ptr = allocLine(vec, line);
Value *pv = ConstantExpr::getIntToPtr(
ConstantInt::get(T_size, (uintptr_t)ptr),
T_pint64);
Value *v = ctx.builder.CreateLoad(pv, true, name);
v = ctx.builder.CreateAdd(v, addend);
ctx.builder.CreateStore(v, pv, true); // volatile, not atomic, so this might be an underestimate,
// but it's faster this way
Value *v = ctx.builder.CreateAtomicRMW(AtomicRMWInst::Add, pv, addend, AtomicOrdering::Monotonic);
v->setName(name);
}

// Code coverage
Expand Down

0 comments on commit 3e9d9af

Please sign in to comment.