@@ -388,9 +388,6 @@ class DxilFinalizeModule : public ModulePass {
388388 unsigned DxilMinor = 0 ;
389389 M.GetDxilModule ().GetDxilVersion (DxilMajor, DxilMinor);
390390
391- // Move all allocas to the top of the entry block
392- ConsolidateAllocas (M);
393-
394391 bool IsLib = DM.GetShaderModel ()->IsLib ();
395392 // Skip validation patch for lib.
396393 if (!IsLib) {
@@ -449,22 +446,6 @@ class DxilFinalizeModule : public ModulePass {
449446 }
450447
451448private:
452- void ConsolidateAllocas (Module &M) {
453- for (Function &F : M) {
454- if (F.isDeclaration ())
455- continue ;
456- Instruction *insertPt = nullptr ;
457- for (llvm::Instruction &I : llvm::inst_range (&F)) {
458- if (!insertPt) {
459- if (!isa<AllocaInst>(I) && !isa<DbgInfoIntrinsic>(I))
460- insertPt = &I;
461- } else if (isa<AllocaInst>(I)) {
462- I.moveBefore (insertPt);
463- }
464- }
465- }
466- }
467-
468449 void RemoveUnusedStaticGlobal (Module &M) {
469450 // Remove unused internal global.
470451 std::vector<GlobalVariable *> staticGVs;
@@ -671,7 +652,7 @@ class DxilFinalizeModule : public ModulePass {
671652 Function *F = CI->getParent ()->getParent ();
672653 ICmpInst *Cmp = DxBreakCmpMap.lookup (F);
673654 if (!Cmp) {
674- Instruction *IP = dxilutil::FindInsertionPt (F);
655+ Instruction *IP = dxilutil::FirstNonAllocaInsertionPt (F);
675656 LoadInst *LI = new LoadInst (Gep, nullptr , false , IP);
676657 Cmp = new ICmpInst (IP, ICmpInst::ICMP_EQ, LI, llvm::ConstantInt::get (i32Ty,0 ));
677658 DxBreakCmpMap[F] = Cmp;
0 commit comments