From d933c895348b79a28cdb9e330e0ee5146bac5adf Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 19 May 2023 15:46:11 +0100 Subject: [PATCH] [GVN] Simplify presplit coroutine handling. NFC. --- llvm/lib/Transforms/Scalar/GVN.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 3f94cae..3e30f15 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -461,30 +461,26 @@ void GVNPass::ValueTable::add(Value *V, uint32_t num) { } uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *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()) { + // 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. + if (C->getFunction()->isPresplitCoroutine()) { + valueNumbering[C] = nextValueNumber; + return nextValueNumber++; + } + + if (AA->doesNotAccessMemory(C)) { Expression exp = createExpr(C); uint32_t e = assignExpNewValueNum(exp).first; valueNumbering[C] = e; return e; } - 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()) { + if (MD && AA->onlyReadsMemory(C)) { Expression exp = createExpr(C); auto ValNum = assignExpNewValueNum(exp); if (ValNum.second) { -- 2.7.4