mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[OpenMP][NFC] Expose AAExecutionDomain and rename its getter
The initial use for AAExecutionDomain was to determine if a single thread executes a block. While this is sometimes informative most of the time, and for other reasons, we actually want to know if it is the "initial thread". Thus, the thread that started execution on the current device. The deduction needs to be adjusted in a follow up as the methods we use right not are looking for the OpenMP thread id which is resets whenever a thread enters a parallel region. What we basically want is to look for `llvm.nvvm.read.ptx.sreg.ntid.x` and equivalent functions.
This commit is contained in:
parent
4c4da5cf4e
commit
1d462a0452
@ -4018,6 +4018,37 @@ struct DOTGraphTraits<AttributorCallGraph *> : public DefaultDOTGraphTraits {
|
||||
}
|
||||
};
|
||||
|
||||
struct AAExecutionDomain
|
||||
: public StateWrapper<BooleanState, AbstractAttribute> {
|
||||
using Base = StateWrapper<BooleanState, AbstractAttribute>;
|
||||
AAExecutionDomain(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
|
||||
|
||||
/// Create an abstract attribute view for the position \p IRP.
|
||||
static AAExecutionDomain &createForPosition(const IRPosition &IRP,
|
||||
Attributor &A);
|
||||
|
||||
/// See AbstractAttribute::getName().
|
||||
const std::string getName() const override { return "AAExecutionDomain"; }
|
||||
|
||||
/// See AbstractAttribute::getIdAddr().
|
||||
const char *getIdAddr() const override { return &ID; }
|
||||
|
||||
/// Check if an instruction is executed only by the initial thread.
|
||||
virtual bool isExecutedByInitialThreadOnly(const Instruction &) const = 0;
|
||||
|
||||
/// Check if a basic block is executed only by the initial thread.
|
||||
virtual bool isExecutedByInitialThreadOnly(const BasicBlock &) const = 0;
|
||||
|
||||
/// This function should return true if the type of the \p AA is
|
||||
/// AAExecutionDomain.
|
||||
static bool classof(const AbstractAttribute *AA) {
|
||||
return (AA->getIdAddr() == &ID);
|
||||
}
|
||||
|
||||
/// Unique ID (due to the unique address)
|
||||
static const char ID;
|
||||
};
|
||||
|
||||
/// Run options, used by the pass manager.
|
||||
enum AttributorRunOption {
|
||||
NONE = 0,
|
||||
|
@ -82,36 +82,6 @@ static constexpr auto TAG = "[" DEBUG_TYPE "]";
|
||||
|
||||
namespace {
|
||||
|
||||
struct AAExecutionDomain
|
||||
: public StateWrapper<BooleanState, AbstractAttribute> {
|
||||
using Base = StateWrapper<BooleanState, AbstractAttribute>;
|
||||
AAExecutionDomain(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
|
||||
|
||||
/// Create an abstract attribute view for the position \p IRP.
|
||||
static AAExecutionDomain &createForPosition(const IRPosition &IRP,
|
||||
Attributor &A);
|
||||
|
||||
/// See AbstractAttribute::getName().
|
||||
const std::string getName() const override { return "AAExecutionDomain"; }
|
||||
|
||||
/// See AbstractAttribute::getIdAddr().
|
||||
const char *getIdAddr() const override { return &ID; }
|
||||
|
||||
/// Check if an instruction is executed by a single thread.
|
||||
virtual bool isSingleThreadExecution(const Instruction &) const = 0;
|
||||
|
||||
virtual bool isSingleThreadExecution(const BasicBlock &) const = 0;
|
||||
|
||||
/// This function should return true if the type of the \p AA is
|
||||
/// AAExecutionDomain.
|
||||
static bool classof(const AbstractAttribute *AA) {
|
||||
return (AA->getIdAddr() == &ID);
|
||||
}
|
||||
|
||||
/// Unique ID (due to the unique address)
|
||||
static const char ID;
|
||||
};
|
||||
|
||||
struct AAICVTracker;
|
||||
|
||||
/// OpenMP specific information. For now, stores RFIs and ICVs also needed for
|
||||
@ -2314,11 +2284,11 @@ struct AAExecutionDomainFunction : public AAExecutionDomain {
|
||||
ChangeStatus updateImpl(Attributor &A) override;
|
||||
|
||||
/// Check if an instruction is executed by a single thread.
|
||||
bool isSingleThreadExecution(const Instruction &I) const override {
|
||||
return isSingleThreadExecution(*I.getParent());
|
||||
bool isExecutedByInitialThreadOnly(const Instruction &I) const override {
|
||||
return isExecutedByInitialThreadOnly(*I.getParent());
|
||||
}
|
||||
|
||||
bool isSingleThreadExecution(const BasicBlock &BB) const override {
|
||||
bool isExecutedByInitialThreadOnly(const BasicBlock &BB) const override {
|
||||
return SingleThreadedBBs.contains(&BB);
|
||||
}
|
||||
|
||||
@ -2339,7 +2309,8 @@ ChangeStatus AAExecutionDomainFunction::updateImpl(Attributor &A) {
|
||||
const auto &ExecutionDomainAA = A.getAAFor<AAExecutionDomain>(
|
||||
*this, IRPosition::function(*ACS.getInstruction()->getFunction()),
|
||||
DepClassTy::REQUIRED);
|
||||
return ExecutionDomainAA.isSingleThreadExecution(*ACS.getInstruction());
|
||||
return ExecutionDomainAA.isExecutedByInitialThreadOnly(
|
||||
*ACS.getInstruction());
|
||||
};
|
||||
|
||||
if (!A.checkForAllCallSites(PredForCallSite, *this,
|
||||
|
Loading…
Reference in New Issue
Block a user