@@ -1217,6 +1217,14 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
1217
1217
if (CI->isConvergent ())
1218
1218
return false ;
1219
1219
1220
+ // FIXME: Current LLVM IR semantics don't work well with coroutines and
1221
+ // thread local globals. We currently treat getting the address of a thread
1222
+ // local global as not accessing memory, even though it may not be a
1223
+ // constant throughout a function with coroutines. Remove this check after
1224
+ // we better model semantics of thread local globals.
1225
+ if (CI->getFunction ()->isPresplitCoroutine ())
1226
+ return false ;
1227
+
1220
1228
using namespace PatternMatch ;
1221
1229
if (match (CI, m_Intrinsic<Intrinsic::assume>()))
1222
1230
// Assumes don't actually alias anything or throw
@@ -1225,14 +1233,6 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
1225
1233
// Handle simple cases by querying alias analysis.
1226
1234
MemoryEffects Behavior = AA->getMemoryEffects (CI);
1227
1235
1228
- // FIXME: we don't handle the semantics of thread local well. So that the
1229
- // address of thread locals are fake constants in coroutines. So We forbid
1230
- // to treat onlyReadsMemory call in coroutines as constants now. Note that
1231
- // it is possible to hide a thread local access in a onlyReadsMemory call.
1232
- // Remove this check after we handle the semantics of thread locals well.
1233
- if (Behavior.onlyReadsMemory () && CI->getFunction ()->isPresplitCoroutine ())
1234
- return false ;
1235
-
1236
1236
if (Behavior.doesNotAccessMemory ())
1237
1237
return true ;
1238
1238
if (Behavior.onlyReadsMemory ()) {
0 commit comments