-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce temporary CheerpLowerAtomic pass
This pass is meant to remove atomics by invoking the existing LowerAtomicPass only on genericjs functions.
- Loading branch information
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef CHEERP_LOWER_ATOMIC_H | ||
#define CHEERP_LOWER_ATOMIC_H | ||
|
||
#include "llvm/IR/PassManager.h" | ||
|
||
namespace cheerp | ||
{ | ||
|
||
class CheerpLowerAtomicPass : public llvm::PassInfoMixin<CheerpLowerAtomicPass> | ||
{ | ||
public: | ||
llvm::PreservedAnalyses run(llvm::Module& M, llvm::ModuleAnalysisManager& MAM); | ||
static bool isRequired() { return true; } | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "llvm/Cheerp/CheerpLowerAtomic.h" | ||
#include "llvm/Transforms/Scalar/LowerAtomicPass.h" | ||
|
||
using namespace llvm; | ||
using namespace cheerp; | ||
// Module pass that invokes the LLVM LowerAtomicPass on genericjs functions. | ||
PreservedAnalyses CheerpLowerAtomicPass::run(Module& M, ModuleAnalysisManager& MAM) | ||
{ | ||
FunctionAnalysisManager& FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); | ||
FunctionPassManager FPM; | ||
FPM.addPass(LowerAtomicPass()); | ||
|
||
// Loop over the functions, and only pass genericjs ones to LowerAtomicPass | ||
for (Function& F : M) | ||
{ | ||
if (F.isDeclaration()) | ||
continue; | ||
|
||
if (F.getSection() == "asmjs") | ||
continue; | ||
|
||
FPM.run(F, FAM); | ||
} | ||
|
||
return PreservedAnalyses::none(); | ||
} |