Grab an LLVM Context from an instruction that exists rather than one
authorDan Gohman <gohman@apple.com>
Sun, 27 Sep 2009 16:10:30 +0000 (16:10 +0000)
committerDan Gohman <gohman@apple.com>
Sun, 27 Sep 2009 16:10:30 +0000 (16:10 +0000)
that is deleted in some situations. This fixes a use-after-free.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82903 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LICM.cpp

index fe37ab4caa1b9ba8916184f7aa8f88217e939d78..6df246fa80e3d1ade9bbb61c7c0834003a721f13 100644 (file)
@@ -593,7 +593,7 @@ void LICM::sink(Instruction &I) {
     if (AI) {
       std::vector<AllocaInst*> Allocas;
       Allocas.push_back(AI);
-      PromoteMemToReg(Allocas, *DT, *DF, I.getContext(), CurAST);
+      PromoteMemToReg(Allocas, *DT, *DF, AI->getContext(), CurAST);
     }
   }
 }