|
@@ -2616,26 +2616,30 @@ static void ValidateGlobalVariable(GlobalVariable &GV,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static void
|
|
|
|
-CollectFixAddressAccess(Value *V, std::vector<Instruction *> &fixAddrTGSMList) {
|
|
|
|
|
|
+static void CollectFixAddressAccess(Value *V,
|
|
|
|
+ std::vector<StoreInst *> &fixAddrTGSMList) {
|
|
for (User *U : V->users()) {
|
|
for (User *U : V->users()) {
|
|
if (GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
|
|
if (GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
|
|
if (isa<ConstantExpr>(GEP) || GEP->hasAllConstantIndices()) {
|
|
if (isa<ConstantExpr>(GEP) || GEP->hasAllConstantIndices()) {
|
|
CollectFixAddressAccess(GEP, fixAddrTGSMList);
|
|
CollectFixAddressAccess(GEP, fixAddrTGSMList);
|
|
}
|
|
}
|
|
- } else if (isa<StoreInst>(U)) {
|
|
|
|
- fixAddrTGSMList.emplace_back(cast<Instruction>(U));
|
|
|
|
|
|
+ } else if (StoreInst *SI = dyn_cast<StoreInst>(U)) {
|
|
|
|
+ fixAddrTGSMList.emplace_back(SI);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static void
|
|
|
|
-ValidateTGSMRaceCondition(std::vector<Instruction *> &fixAddrTGSMList,
|
|
|
|
- ValidationContext &ValCtx) {
|
|
|
|
|
|
+static bool IsDivergent(Value *V) {
|
|
|
|
+ // TODO: return correct result.
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void ValidateTGSMRaceCondition(std::vector<StoreInst *> &fixAddrTGSMList,
|
|
|
|
+ ValidationContext &ValCtx) {
|
|
std::unordered_set<Function *> fixAddrTGSMFuncSet;
|
|
std::unordered_set<Function *> fixAddrTGSMFuncSet;
|
|
- for (Instruction *I : fixAddrTGSMList) {
|
|
|
|
- BasicBlock *BB = I->getParent();
|
|
|
|
- fixAddrTGSMFuncSet.insert(BB->getParent());
|
|
|
|
|
|
+ for (StoreInst *I : fixAddrTGSMList) {
|
|
|
|
+ BasicBlock *BB = I->getParent();
|
|
|
|
+ fixAddrTGSMFuncSet.insert(BB->getParent());
|
|
}
|
|
}
|
|
|
|
|
|
for (auto &F : ValCtx.DxilMod.GetModule()->functions()) {
|
|
for (auto &F : ValCtx.DxilMod.GetModule()->functions()) {
|
|
@@ -2647,11 +2651,12 @@ ValidateTGSMRaceCondition(std::vector<Instruction *> &fixAddrTGSMList,
|
|
|
|
|
|
BasicBlock *Entry = &F.getEntryBlock();
|
|
BasicBlock *Entry = &F.getEntryBlock();
|
|
|
|
|
|
- for (Instruction *I : fixAddrTGSMList) {
|
|
|
|
- BasicBlock *BB = I->getParent();
|
|
|
|
|
|
+ for (StoreInst *SI : fixAddrTGSMList) {
|
|
|
|
+ BasicBlock *BB = SI->getParent();
|
|
if (BB->getParent() == &F) {
|
|
if (BB->getParent() == &F) {
|
|
if (PDT.dominates(BB, Entry)) {
|
|
if (PDT.dominates(BB, Entry)) {
|
|
- ValCtx.EmitInstrError(I, ValidationRule::InstrTGSMRaceCond);
|
|
|
|
|
|
+ if (IsDivergent(SI->getValueOperand()))
|
|
|
|
+ ValCtx.EmitInstrError(SI, ValidationRule::InstrTGSMRaceCond);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2662,7 +2667,7 @@ static void ValidateGlobalVariables(ValidationContext &ValCtx) {
|
|
DxilModule &M = ValCtx.DxilMod;
|
|
DxilModule &M = ValCtx.DxilMod;
|
|
|
|
|
|
unsigned TGSMSize = 0;
|
|
unsigned TGSMSize = 0;
|
|
- std::vector<Instruction*> fixAddrTGSMList;
|
|
|
|
|
|
+ std::vector<StoreInst*> fixAddrTGSMList;
|
|
const DataLayout &DL = M.GetModule()->getDataLayout();
|
|
const DataLayout &DL = M.GetModule()->getDataLayout();
|
|
for (GlobalVariable &GV : M.GetModule()->globals()) {
|
|
for (GlobalVariable &GV : M.GetModule()->globals()) {
|
|
ValidateGlobalVariable(GV, ValCtx);
|
|
ValidateGlobalVariable(GV, ValCtx);
|