Skip to content

Commit

Permalink
[RS4GC] NFC cleanup of the DeferredReplacement class
Browse files Browse the repository at this point in the history
Instead of constructors use clearly named factory methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265486 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
sanjoy committed Apr 5, 2016
1 parent 0ed4be7 commit 8e366b3
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,9 +1283,20 @@ class DeferredReplacement {
DeferredReplacement() {}

public:
explicit DeferredReplacement(Instruction *Old, Instruction *New) :
Old(Old), New(New) {
assert(Old != New && "Not allowed!");
static DeferredReplacement createRAUW(Instruction *Old, Instruction *New) {
assert(Old != New && Old && New &&
"Cannot RAUW equal values or to / from null!");

DeferredReplacement D;
D.Old = Old;
D.New = New;
return D;
}

static DeferredReplacement createDelete(Instruction *ToErase) {
DeferredReplacement D;
D.Old = ToErase;
return D;
}

static DeferredReplacement createDeoptimizeReplacement(Instruction *Old) {
Expand Down Expand Up @@ -1488,9 +1499,11 @@ makeStatepointExplicitImpl(const CallSite CS, /* to replace */
// llvm::Instruction. Instead, we defer the replacement and deletion to
// after the live sets have been made explicit in the IR, and we no longer
// have raw pointers to worry about.
Replacements.emplace_back(CS.getInstruction(), GCResult);
Replacements.emplace_back(
DeferredReplacement::createRAUW(CS.getInstruction(), GCResult));
} else {
Replacements.emplace_back(CS.getInstruction(), nullptr);
Replacements.emplace_back(
DeferredReplacement::createDelete(CS.getInstruction()));
}
}

Expand Down

0 comments on commit 8e366b3

Please sign in to comment.