Skip to content

Commit 71360e9

Browse files
committed
Remove EarlyCSE hack for OmpSs-2. Add our PassManager
Closes llvm#77
1 parent c74a931 commit 71360e9

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

clang/lib/CodeGen/BackendUtil.cpp

+16-11
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ class PassManagerBuilderWrapper : public PassManagerBuilder {
185185
};
186186
}
187187

188-
static void addOmpSsPass(const PassManagerBuilder &Builder, PassManagerBase &PM) {
189-
PM.add(createOmpSsPass());
190-
}
191-
192188
static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, PassManagerBase &PM) {
193189
if (Builder.OptLevel > 0)
194190
PM.add(createObjCARCAPElimPass());
@@ -619,13 +615,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
619615
if (TM)
620616
TM->adjustPassManager(PMBuilder);
621617

622-
if (LangOpts.OmpSs) {
623-
PMBuilder.addExtension(PassManagerBuilder::EP_ModuleOptimizerEarly,
624-
addOmpSsPass);
625-
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
626-
addOmpSsPass);
627-
}
628-
629618
if (CodeGenOpts.DebugInfoForProfiling ||
630619
!CodeGenOpts.SampleProfileFile.empty())
631620
PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
@@ -863,6 +852,16 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
863852
if (TM)
864853
TheModule->setDataLayout(TM->createDataLayout());
865854

855+
legacy::PassManager EarlyPerModulePasses;
856+
// TODO: Do we need this?
857+
EarlyPerModulePasses.add(
858+
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
859+
860+
if (LangOpts.OmpSs) {
861+
if (!CodeGenOpts.DisableLLVMPasses)
862+
EarlyPerModulePasses.add(createOmpSsPass());
863+
}
864+
866865
legacy::PassManager PerModulePasses;
867866
PerModulePasses.add(
868867
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
@@ -936,6 +935,12 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
936935
// Run passes. For now we do all passes at once, but eventually we
937936
// would like to have the option of streaming code generation.
938937

938+
{
939+
PrettyStackTraceString CrashInfo("Early per-module transformation");
940+
llvm::TimeTraceScope TimeScope("EarlyPerModulePasses");
941+
EarlyPerModulePasses.run(*TheModule);
942+
}
943+
939944
{
940945
PrettyStackTraceString CrashInfo("Per-function optimization");
941946
llvm::TimeTraceScope TimeScope("PerFunctionPasses");

llvm/lib/Transforms/Scalar/EarlyCSE.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@
3333
#include "llvm/IR/DataLayout.h"
3434
#include "llvm/IR/Dominators.h"
3535
#include "llvm/IR/Function.h"
36-
#include "llvm/IR/InstIterator.h"
3736
#include "llvm/IR/InstrTypes.h"
3837
#include "llvm/IR/Instruction.h"
3938
#include "llvm/IR/Instructions.h"
4039
#include "llvm/IR/IntrinsicInst.h"
4140
#include "llvm/IR/Intrinsics.h"
42-
#include "llvm/IR/IntrinsicsOmpSs.h"
4341
#include "llvm/IR/LLVMContext.h"
4442
#include "llvm/IR/PassManager.h"
4543
#include "llvm/IR/PatternMatch.h"
@@ -1410,16 +1408,6 @@ class EarlyCSELegacyCommonPass : public FunctionPass {
14101408
if (skipFunction(F))
14111409
return false;
14121410

1413-
// OmpSs-2: for now skip functions that have oss intrinsics
1414-
for (Instruction &Inst : instructions(F)) {
1415-
if (match(&Inst, m_Intrinsic<Intrinsic::directive_region_entry>()))
1416-
return false;
1417-
if (match(&Inst, m_Intrinsic<Intrinsic::directive_region_exit>()))
1418-
return false;
1419-
if (match(&Inst, m_Intrinsic<Intrinsic::directive_marker>()))
1420-
return false;
1421-
}
1422-
14231411
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
14241412
auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
14251413
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();

0 commit comments

Comments
 (0)