Skip to content

Commit

Permalink
Fix bug caused by LowerSwitchPass.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeadroyaL committed Apr 19, 2020
1 parent 0a75aef commit e3acd12
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Armariris/Enter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static void registerArmaririsModulePass(const PassManagerBuilder &,

static void registerArmaririsFunctionPass(const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
#if LLVM_VERSION_MAJOR >= 9
PM.add(createLowerSwitchPass());
#endif
PM.add(createFlattening(true));
PM.add(createSubstitution(true));
}
Expand Down
3 changes: 2 additions & 1 deletion Armariris/Flattening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ bool Flattening::flatten(Function *f) {

// Lower switch
#if LLVM_VERSION_MAJOR >= 9
// FIXME: Pass has not been inserted into a PassManager object!
// >=9.0, LowerSwitchPass depends on LazyValueInfoWrapperPass, which cause AssertError.
// So I move LowerSwitchPass into register function, just before FlatteningPass.
#else
FunctionPass *lower = createLowerSwitchPass();
lower->runOnFunction(*f);
Expand Down
3 changes: 3 additions & 0 deletions Hikari/Enter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static void registerHikariModulePass(const PassManagerBuilder &,
static void registerHikariFunctionPass(const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
PM.add(createBogusControlFlowPass(true));
#if LLVM_VERSION_MAJOR >= 9
PM.add(createLowerSwitchPass());
#endif
PM.add(createFlatteningPass(true));
PM.add(createFunctionCallObfuscatePass(true));
PM.add(createIndirectBranchPass(true));
Expand Down
3 changes: 2 additions & 1 deletion Hikari/Flattening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ bool Flattening::flatten(Function *f) {
// END OF SCRAMBLER

#if LLVM_VERSION_MAJOR >= 9
// FIXME: Pass has not been inserted into a PassManager object!
// >=9.0, LowerSwitchPass depends on LazyValueInfoWrapperPass, which cause AssertError.
// So I move LowerSwitchPass into register function, just before FlatteningPass.
#else
FunctionPass *lower = createLowerSwitchPass();
lower->runOnFunction(*f);
Expand Down
3 changes: 3 additions & 0 deletions ollvm/Enter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ using namespace llvm;
static void registerOllvmPass(const PassManagerBuilder &,
legacy::PassManagerBase &PM) {
PM.add(createBogus(true));
#if LLVM_VERSION_MAJOR >= 9
PM.add(createLowerSwitchPass());
#endif
PM.add(createFlattening(true));
PM.add(createSplitBasicBlock(true));
PM.add(createSubstitution(true));
Expand Down
3 changes: 2 additions & 1 deletion ollvm/Flattening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ bool Flattening::flatten(Function *f) {

// Lower switch
#if LLVM_VERSION_MAJOR >= 9
// FIXME: Pass has not been inserted into a PassManager object!
// >=9.0, LowerSwitchPass depends on LazyValueInfoWrapperPass, which cause AssertError.
// So I move LowerSwitchPass into register function, just before FlatteningPass.
#else
FunctionPass *lower = createLowerSwitchPass();
lower->runOnFunction(*f);
Expand Down

0 comments on commit e3acd12

Please sign in to comment.