forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor LateLowerGCFrame. We do not need inheritance.
- Loading branch information
Showing
5 changed files
with
61 additions
and
70 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
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 |
---|---|---|
@@ -1,6 +1,47 @@ | ||
#include "llvm-gc-interface-passes.h" | ||
|
||
bool LateLowerGCFrameCustom::runOnFunction(Function &F, bool *CFGModified) { | ||
need_gc_preserve_hook = 1; | ||
return LateLowerGCFrame::runOnFunction(F, CFGModified); | ||
void LateLowerGCFrame::cleanupGCPreserve(Function &F, CallInst *CI, Value *callee, Type *T_size) { | ||
if (callee == gc_preserve_begin_func) { | ||
// Initialize an IR builder. | ||
IRBuilder<> builder(CI); | ||
|
||
builder.SetCurrentDebugLocation(CI->getDebugLoc()); | ||
size_t nargs = 0; | ||
State S2(F); | ||
|
||
std::vector<Value*> args; | ||
for (Use &U : CI->args()) { | ||
Value *V = U; | ||
if (isa<Constant>(V)) | ||
continue; | ||
if (isa<PointerType>(V->getType())) { | ||
if (isSpecialPtr(V->getType())) { | ||
int Num = Number(S2, V); | ||
if (Num >= 0) { | ||
nargs++; | ||
Value *Val = GetPtrForNumber(S2, Num, CI); | ||
args.push_back(Val); | ||
} | ||
} | ||
} else { | ||
auto Nums = NumberAll(S2, V); | ||
for (int Num : Nums) { | ||
if (Num < 0) | ||
continue; | ||
Value *Val = GetPtrForNumber(S2, Num, CI); | ||
args.push_back(Val); | ||
nargs++; | ||
} | ||
} | ||
} | ||
args.insert(args.begin(), ConstantInt::get(T_size, nargs)); | ||
|
||
ArrayRef<Value*> args_llvm = ArrayRef<Value*>(args); | ||
builder.CreateCall(getOrDeclare(jl_well_known::GCPreserveBeginHook), args_llvm ); | ||
} else if (callee == gc_preserve_end_func) { | ||
// Initialize an IR builder. | ||
IRBuilder<> builder(CI); | ||
builder.SetCurrentDebugLocation(CI->getDebugLoc()); | ||
builder.CreateCall(getOrDeclare(jl_well_known::GCPreserveEndHook), {}); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#include "llvm-gc-interface-passes.h" | ||
|
||
bool LateLowerGCFrameCustom::runOnFunction(Function &F, bool *CFGModified) { | ||
need_gc_preserve_hook = 0; | ||
return LateLowerGCFrame::runOnFunction(F, CFGModified); | ||
void LateLowerGCFrame::cleanupGCPreserve(Function &F, CallInst *CI, Value *callee, Type *T_size) { | ||
// Do nothing for the stock GC | ||
} |
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