[MemorySSA] Fix windows build breakage caused by r278028

r278028: [MemorySSA] Ensure address stability of MemorySSA object.
llvm-svn: 278035
This commit is contained in:
Geoff Berry 2016-08-08 18:27:22 +00:00
parent 777026b82c
commit 1ea90914c1
2 changed files with 12 additions and 5 deletions

View File

@ -675,7 +675,14 @@ class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
static char PassID;
public:
typedef std::unique_ptr<MemorySSA> Result;
// Wrap MemorySSA result to ensure address stability of internal MemorySSA
// pointers after construction. Use a wrapper class instead of plain
// unique_ptr<MemorySSA> to avoid build breakage on MSVC.
struct Result {
Result(std::unique_ptr<MemorySSA> &&MSSA) : MSSA(std::move(MSSA)) {}
MemorySSA &getMSSA() { return *MSSA.get(); }
std::unique_ptr<MemorySSA> MSSA;
};
Result run(Function &F, AnalysisManager<Function> &AM);
};

View File

@ -2078,24 +2078,24 @@ bool MemorySSAPrinterLegacyPass::runOnFunction(Function &F) {
char MemorySSAAnalysis::PassID;
std::unique_ptr<MemorySSA>
MemorySSAAnalysis::Result
MemorySSAAnalysis::run(Function &F, AnalysisManager<Function> &AM) {
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
auto &AA = AM.getResult<AAManager>(F);
return make_unique<MemorySSA>(F, &AA, &DT);
return MemorySSAAnalysis::Result(make_unique<MemorySSA>(F, &AA, &DT));
}
PreservedAnalyses MemorySSAPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) {
OS << "MemorySSA for function: " << F.getName() << "\n";
AM.getResult<MemorySSAAnalysis>(F)->print(OS);
AM.getResult<MemorySSAAnalysis>(F).getMSSA().print(OS);
return PreservedAnalyses::all();
}
PreservedAnalyses MemorySSAVerifierPass::run(Function &F,
FunctionAnalysisManager &AM) {
AM.getResult<MemorySSAAnalysis>(F)->verifyMemorySSA();
AM.getResult<MemorySSAAnalysis>(F).getMSSA().verifyMemorySSA();
return PreservedAnalyses::all();
}