Skip to content

Commit 0948e11

Browse files
committed
Port Atomicexpandpass to new PM
1 parent 59e79f0 commit 0948e11

File tree

76 files changed

+219
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+219
-154
lines changed

llvm/include/llvm/CodeGen/AtomicExpandUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using CreateCmpXchgInstFun =
3434
/// instructions directly into a platform specific intrinsics (because, say,
3535
/// those intrinsics don't exist). If such a pass is able to expand cmpxchg
3636
/// instructions directly however, then, with this function, it could avoid two
37-
/// extra module passes (avoiding passes by `-atomic-expand` and itself). A
37+
/// extra module passes (avoiding passes by `-expand-atomic` and itself). A
3838
/// specific example would be PNaCl's `RewriteAtomics` pass.
3939
///
4040
/// Given: atomicrmw some_op iN* %addr, iN %incr ordering
@@ -46,7 +46,7 @@ using CreateCmpXchgInstFun =
4646
/// loop:
4747
/// %loaded = phi iN [ %init_loaded, %entry ], [ %new_loaded, %loop ]
4848
/// %new = some_op iN %loaded, %incr
49-
/// ; This is what -atomic-expand will produce using this function on i686
49+
/// ; This is what -expand-atomic will produce using this function on i686
5050
/// targets:
5151
/// %pair = cmpxchg iN* %addr, iN %loaded, iN %new_val
5252
/// %new_loaded = extractvalue { iN, i1 } %pair, 0
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===-- ExpandAtomic.h - Expand Atomic Instructions -------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CODEGEN_EXPANDATOMIC_H
10+
#define LLVM_CODEGEN_EXPANDATOMIC_H
11+
12+
#include "llvm/IR/PassManager.h"
13+
14+
namespace llvm {
15+
16+
class Function;
17+
class TargetMachine;
18+
19+
class ExpandAtomicPass : public PassInfoMixin<ExpandAtomicPass> {
20+
private:
21+
const TargetMachine *TM;
22+
23+
public:
24+
ExpandAtomicPass(const TargetMachine *TM) : TM(TM) {}
25+
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
26+
};
27+
28+
} // end namespace llvm
29+
30+
#endif // LLVM_CODEGEN_EXPANDATOMIC_H

llvm/include/llvm/CodeGen/MachinePassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis,
135135
#ifndef DUMMY_FUNCTION_PASS
136136
#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
137137
#endif
138-
DUMMY_FUNCTION_PASS("atomic-expand", AtomicExpandPass, ())
138+
DUMMY_FUNCTION_PASS("expand-atomic", ExpandAtomicPass, ())
139139
#undef DUMMY_FUNCTION_PASS
140140

141141
#ifndef DUMMY_MACHINE_MODULE_PASS

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class FileSystem;
4141
// List of target independent CodeGen pass IDs.
4242
namespace llvm {
4343

44-
/// AtomicExpandPass - At IR level this pass replace atomic instructions with
44+
/// ExpandAtomicPass - At IR level this pass replace atomic instructions with
4545
/// __atomic_* library calls, or target specific instruction which implement the
4646
/// same semantics in a way which better fits the target backend.
47-
FunctionPass *createAtomicExpandPass();
47+
FunctionPass *createExpandAtomicPass();
4848

4949
/// createUnreachableBlockEliminationPass - The LLVM code generator does not
5050
/// work well with unreachable basic blocks (what live ranges make sense for a
@@ -101,9 +101,9 @@ namespace llvm {
101101
/// handling of complex number arithmetic
102102
FunctionPass *createComplexDeinterleavingPass(const TargetMachine *TM);
103103

104-
/// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
104+
/// ExpandAtomicID -- Lowers atomic operations in terms of either cmpxchg
105105
/// load-linked/store-conditional loops.
106-
extern char &AtomicExpandID;
106+
extern char &ExpandAtomicID;
107107

108108
/// MachineLoopInfo - This pass is a loop analysis pass.
109109
extern char &MachineLoopInfoID;

llvm/include/llvm/CodeGen/TargetSubtargetInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
215215
virtual bool enablePostRAMachineScheduler() const;
216216

217217
/// True if the subtarget should run the atomic expansion pass.
218-
virtual bool enableAtomicExpand() const;
218+
virtual bool enableExpandAtomic() const;
219219

220220
/// True if the subtarget should run the indirectbr expansion pass.
221221
virtual bool enableIndirectBrExpand() const;

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ void initializeAAResultsWrapperPassPass(PassRegistry&);
5252
void initializeAlwaysInlinerLegacyPassPass(PassRegistry&);
5353
void initializeAssignmentTrackingAnalysisPass(PassRegistry &);
5454
void initializeAssumptionCacheTrackerPass(PassRegistry&);
55-
void initializeAtomicExpandPass(PassRegistry&);
5655
void initializeBasicBlockPathCloningPass(PassRegistry &);
5756
void initializeBasicBlockSectionsProfileReaderWrapperPassPass(PassRegistry &);
5857
void initializeBasicBlockSectionsPass(PassRegistry &);
@@ -101,6 +100,7 @@ void initializeEarlyMachineLICMPass(PassRegistry&);
101100
void initializeEarlyTailDuplicatePass(PassRegistry&);
102101
void initializeEdgeBundlesPass(PassRegistry&);
103102
void initializeEHContGuardCatchretPass(PassRegistry &);
103+
void initializeExpandAtomicPass(PassRegistry&);
104104
void initializeExpandLargeFpConvertLegacyPassPass(PassRegistry&);
105105
void initializeExpandLargeDivRemLegacyPassPass(PassRegistry&);
106106
void initializeExpandMemCmpLegacyPassPass(PassRegistry &);

llvm/lib/CodeGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ add_llvm_component_library(LLVMCodeGen
4040
AllocationOrder.cpp
4141
Analysis.cpp
4242
AssignmentTrackingAnalysis.cpp
43-
AtomicExpandPass.cpp
4443
BasicTargetTransformInfo.cpp
4544
BranchFolding.cpp
4645
BranchRelaxation.cpp
@@ -69,6 +68,7 @@ add_llvm_component_library(LLVMCodeGen
6968
EdgeBundles.cpp
7069
EHContGuardCatchret.cpp
7170
ExecutionDomainFix.cpp
71+
ExpandAtomicPass.cpp
7272
ExpandLargeDivRem.cpp
7373
ExpandLargeFpConvert.cpp
7474
ExpandMemCmp.cpp

llvm/lib/CodeGen/CodeGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ using namespace llvm;
1919
/// initializeCodeGen - Initialize all passes linked into the CodeGen library.
2020
void llvm::initializeCodeGen(PassRegistry &Registry) {
2121
initializeAssignmentTrackingAnalysisPass(Registry);
22-
initializeAtomicExpandPass(Registry);
2322
initializeBasicBlockPathCloningPass(Registry);
2423
initializeBasicBlockSectionsPass(Registry);
2524
initializeBranchFolderPassPass(Registry);
@@ -39,6 +38,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
3938
initializeEarlyIfPredicatorPass(Registry);
4039
initializeEarlyMachineLICMPass(Registry);
4140
initializeEarlyTailDuplicatePass(Registry);
41+
initializeExpandAtomicLegacyPass(Registry);
4242
initializeExpandLargeDivRemLegacyPassPass(Registry);
4343
initializeExpandLargeFpConvertLegacyPassPass(Registry);
4444
initializeExpandMemCmpLegacyPassPass(Registry);

0 commit comments

Comments
 (0)