|
@@ -18,6 +18,7 @@
|
|
#include "llvm/IR/Instructions.h"
|
|
#include "llvm/IR/Instructions.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/LLVMContext.h"
|
|
#include "llvm/IR/Module.h"
|
|
#include "llvm/IR/Module.h"
|
|
|
|
+#include "llvm/IR/Operator.h"
|
|
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
|
|
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
|
|
#include "llvm/Transforms/Utils/SSAUpdater.h"
|
|
#include "llvm/Transforms/Utils/SSAUpdater.h"
|
|
#include <unordered_set>
|
|
#include <unordered_set>
|
|
@@ -184,11 +185,21 @@ bool DxilPromoteStaticResources::PromoteStaticGlobalResources(
|
|
GlobalVariable *GV = *(it++);
|
|
GlobalVariable *GV = *(it++);
|
|
// Build list of instructions to promote.
|
|
// Build list of instructions to promote.
|
|
for (User *U : GV->users()) {
|
|
for (User *U : GV->users()) {
|
|
- Instruction *I = cast<Instruction>(U);
|
|
|
|
- Insts.emplace_back(I);
|
|
|
|
|
|
+ if (isa<LoadInst>(U) || isa<StoreInst>(U)) {
|
|
|
|
+ Insts.emplace_back(cast<Instruction>(U));
|
|
|
|
+ } else if (GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
|
|
|
|
+ for (User *gepU : GEP->users()) {
|
|
|
|
+ DXASSERT_NOMSG(isa<LoadInst>(gepU) || isa<StoreInst>(gepU));
|
|
|
|
+ if (isa<LoadInst>(gepU) || isa<StoreInst>(gepU))
|
|
|
|
+ Insts.emplace_back(cast<Instruction>(gepU));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ DXASSERT(false, "Unhandled user of resource static global");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
LoadAndStorePromoter(Insts, SSA).run(Insts);
|
|
LoadAndStorePromoter(Insts, SSA).run(Insts);
|
|
|
|
+ GV->removeDeadConstantUsers();
|
|
if (GV->user_empty()) {
|
|
if (GV->user_empty()) {
|
|
bUpdated = true;
|
|
bUpdated = true;
|
|
staticResources.erase(GV);
|
|
staticResources.erase(GV);
|