Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Scalar/GVN.cpp
Show First 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | |||||
/// add - Insert a value into the table with a specified value number. | /// add - Insert a value into the table with a specified value number. | ||||
void GVNPass::ValueTable::add(Value *V, uint32_t num) { | void GVNPass::ValueTable::add(Value *V, uint32_t num) { | ||||
valueNumbering.insert(std::make_pair(V, num)); | valueNumbering.insert(std::make_pair(V, num)); | ||||
if (PHINode *PN = dyn_cast<PHINode>(V)) | if (PHINode *PN = dyn_cast<PHINode>(V)) | ||||
NumberingPhi[num] = PN; | NumberingPhi[num] = PN; | ||||
} | } | ||||
uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) { | uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) { | ||||
if (AA->doesNotAccessMemory(C)) { | if (AA->doesNotAccessMemory(C) && | ||||
// FIXME: Currently the calls which may access the thread id may | |||||
// be considered as not accessing the memory. But this is | |||||
// problematic for coroutines, since coroutines may resume in a | |||||
// different thread. So we disable the optimization here for the | |||||
// correctness. However, it may block many other correct | |||||
// optimizations. Revert this one when we detect the memory | |||||
// accessing kind more precisely. | |||||
!C->getFunction()->isPresplitCoroutine()) { | |||||
Expression exp = createExpr(C); | Expression exp = createExpr(C); | ||||
uint32_t e = assignExpNewValueNum(exp).first; | uint32_t e = assignExpNewValueNum(exp).first; | ||||
valueNumbering[C] = e; | valueNumbering[C] = e; | ||||
return e; | return e; | ||||
} else if (MD && AA->onlyReadsMemory(C)) { | } else if (MD && AA->onlyReadsMemory(C) && | ||||
// FIXME: Currently the calls which may access the thread id may | |||||
// be considered as not accessing the memory. But this is | |||||
// problematic for coroutines, since coroutines may resume in a | |||||
// different thread. So we disable the optimization here for the | |||||
// correctness. However, it may block many other correct | |||||
// optimizations. Revert this one when we detect the memory | |||||
// accessing kind more precisely. | |||||
!C->getFunction()->isPresplitCoroutine()) { | |||||
Expression exp = createExpr(C); | Expression exp = createExpr(C); | ||||
auto ValNum = assignExpNewValueNum(exp); | auto ValNum = assignExpNewValueNum(exp); | ||||
if (ValNum.second) { | if (ValNum.second) { | ||||
valueNumbering[C] = ValNum.first; | valueNumbering[C] = ValNum.first; | ||||
return ValNum.first; | return ValNum.first; | ||||
} | } | ||||
MemDepResult local_dep = MD->getDependency(C); | MemDepResult local_dep = MD->getDependency(C); | ||||
▲ Show 20 Lines • Show All 2,770 Lines • Show Last 20 Lines |