Mercurial > hg > CbC > CbC_llvm
changeset 14:a71c80ca9668
add CodeGenPreparepass when input file has code segment. And we can eliminate tail call now!
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 24 Aug 2013 14:49:59 +0900 |
parents | 0c91843d63c0 |
children | 66597e792247 |
files | include/llvm/CodeGen/Passes.h include/llvm/Target/TargetOptions.h lib/CodeGen/Passes.cpp tools/clang/lib/CodeGen/BackendUtil.cpp |
diffstat | 4 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/include/llvm/CodeGen/Passes.h Mon Aug 19 14:02:11 2013 +0900 +++ b/include/llvm/CodeGen/Passes.h Sat Aug 24 14:49:59 2013 +0900 @@ -138,6 +138,9 @@ void setInitialized() { Initialized = true; } CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); } +#ifndef noCbC + unsigned hasCodeSegment() { return TM->Options.HasCodeSegment; } +#endif /// setStartStopPasses - Set the StartAfter and StopAfter passes to allow /// running only a portion of the normal code-gen pass sequence. If the
--- a/include/llvm/Target/TargetOptions.h Mon Aug 19 14:02:11 2013 +0900 +++ b/include/llvm/Target/TargetOptions.h Sat Aug 24 14:49:59 2013 +0900 @@ -205,6 +205,11 @@ FPOpFusion::FPOpFusionMode AllowFPOpFusion; bool operator==(const TargetOptions &); + +#ifndef noCbC + unsigned HasCodeSegment : 1; +#endif + }; } // End llvm namespace
--- a/lib/CodeGen/Passes.cpp Mon Aug 19 14:02:11 2013 +0900 +++ b/lib/CodeGen/Passes.cpp Sat Aug 24 14:49:59 2013 +0900 @@ -415,7 +415,11 @@ /// Add pass to prepare the LLVM IR for code generation. This should be done /// before exception handling preparation passes. void TargetPassConfig::addCodeGenPrepare() { +#ifndef noCbC + if ((getOptLevel() != CodeGenOpt::None || hasCodeSegment()) && !DisableCGP) +#else if (getOptLevel() != CodeGenOpt::None && !DisableCGP) +#endif addPass(createCodeGenPreparePass(getTargetLowering())); } @@ -730,6 +734,7 @@ /// Add passes that optimize machine instructions after register allocation. void TargetPassConfig::addMachineLateOptimization() { // Branch folding must be run after regalloc and prolog/epilog insertion. + if (addPass(&BranchFolderPassID)) printAndVerify("After BranchFolding"); @@ -740,6 +745,7 @@ // Copy propagation. if (addPass(&MachineCopyPropagationID)) printAndVerify("After copy propagation pass"); + } /// Add standard GC passes.
--- a/tools/clang/lib/CodeGen/BackendUtil.cpp Mon Aug 19 14:02:11 2013 +0900 +++ b/tools/clang/lib/CodeGen/BackendUtil.cpp Sat Aug 24 14:49:59 2013 +0900 @@ -459,7 +459,7 @@ Options.SSPBufferSize = CodeGenOpts.SSPBufferSize; Options.EnableSegmentedStacks = CodeGenOpts.EnableSegmentedStacks; #ifndef noCbC - Options.GuaranteedTailCallOpt = LangOpts.HasCodeSegment; + Options.HasCodeSegment = LangOpts.HasCodeSegment; #endif