From: Dan Gohman Date: Mon, 18 Oct 2010 18:50:27 +0000 (+0000) Subject: Add TypeBasedAliasAnalysis to the standard pass lists. Note that it X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4021fccf9fdb60906e5f16c98e72042240867495;p=oota-llvm.git Add TypeBasedAliasAnalysis to the standard pass lists. Note that it is currently inert by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116732 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/StandardPasses.h b/include/llvm/Support/StandardPasses.h index deee00e686a..a608f2ceaba 100644 --- a/include/llvm/Support/StandardPasses.h +++ b/include/llvm/Support/StandardPasses.h @@ -69,10 +69,18 @@ namespace llvm { // Implementations + static inline void createStandardAliasAnalysisPasses(PassManagerBase *PM) { + // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that + // BasicAliasAnalysis wins if they disagree. This is intended to help + // support "obvious" type-punning idioms. + PM->add(createTypeBasedAliasAnalysisPass()); + PM->add(createBasicAliasAnalysisPass()); + } + static inline void createStandardFunctionPasses(PassManagerBase *PM, unsigned OptimizationLevel) { if (OptimizationLevel > 0) { - PM->add(createBasicAliasAnalysisPass()); + createStandardAliasAnalysisPasses(PM); PM->add(createCFGSimplificationPass()); if (OptimizationLevel == 1) PM->add(createPromoteMemoryToRegisterPass()); @@ -92,7 +100,7 @@ namespace llvm { bool SimplifyLibCalls, bool HaveExceptions, Pass *InliningPass) { - PM->add(createBasicAliasAnalysisPass()); + createStandardAliasAnalysisPasses(PM); if (OptimizationLevel == 0) { if (InliningPass) @@ -181,7 +189,7 @@ namespace llvm { bool RunInliner, bool VerifyEach) { // Provide AliasAnalysis services for optimizations. - PM->add(createBasicAliasAnalysisPass()); + createStandardAliasAnalysisPasses(PM); // Now that composite has been compiled, scan through the module, looking // for a main function. If main is defined, mark all other functions diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index a3b605238ab..60aa1e5c984 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -14,7 +14,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Analysis/Passes.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" @@ -31,6 +30,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/StandardPasses.h" using namespace llvm; namespace llvm { @@ -256,7 +256,7 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, // Standard LLVM-Level Passes. // Basic AliasAnalysis support. - PM.add(createBasicAliasAnalysisPass()); + createStandardAliasAnalysisPasses(&PM); // Before running any passes, run the verifier to determine if the input // coming from the front-end and/or optimizer is valid.