[llvm] r242751 - [RewriteStatepointsForGC] Minor code cleanup [NFC]
Philip Reames
listmail at philipreames.com
Mon Jul 20 17:49:55 PDT 2015
Author: reames
Date: Mon Jul 20 19:49:55 2015
New Revision: 242751
URL: http://llvm.org/viewvc/llvm-project?rev=242751&view=rev
Log:
[RewriteStatepointsForGC] Minor code cleanup [NFC]
We can use builders to simplify part of the code and we only check for the existance of the metadata value; this enables us to delete some redundant code.
Modified:
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=242751&r1=242750&r2=242751&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Mon Jul 20 19:49:55 2015
@@ -848,14 +848,7 @@ static Value *findBasePointer(Value *I,
assert(num_preds > 0 && "how did we reach here");
PHINode *phi = PHINode::Create(v->getType(), num_preds, "base_phi", v);
// Add metadata marking this as a base value
- auto *const_1 = ConstantInt::get(
- Type::getInt32Ty(
- v->getParent()->getParent()->getParent()->getContext()),
- 1);
- auto MDConst = ConstantAsMetadata::get(const_1);
- MDNode *md = MDNode::get(
- v->getParent()->getParent()->getParent()->getContext(), MDConst);
- phi->setMetadata("is_base_value", md);
+ phi->setMetadata("is_base_value", MDNode::get(v->getContext(), {}));
states[v] = PhiState(PhiState::Conflict, phi);
} else {
SelectInst *sel = cast<SelectInst>(v);
@@ -864,14 +857,7 @@ static Value *findBasePointer(Value *I,
SelectInst *basesel = SelectInst::Create(sel->getCondition(), undef,
undef, "base_select", sel);
// Add metadata marking this as a base value
- auto *const_1 = ConstantInt::get(
- Type::getInt32Ty(
- v->getParent()->getParent()->getParent()->getContext()),
- 1);
- auto MDConst = ConstantAsMetadata::get(const_1);
- MDNode *md = MDNode::get(
- v->getParent()->getParent()->getParent()->getContext(), MDConst);
- basesel->setMetadata("is_base_value", md);
+ basesel->setMetadata("is_base_value", MDNode::get(v->getContext(), {}));
states[v] = PhiState(PhiState::Conflict, basesel);
}
}
@@ -1198,11 +1184,9 @@ static void CreateGCRelocates(ArrayRef<l
// Generate the gc.relocate call and save the result
Value *BaseIdx =
- ConstantInt::get(Type::getInt32Ty(M->getContext()),
- LiveStart + find_index(LiveVariables, BasePtrs[i]));
- Value *LiveIdx = ConstantInt::get(
- Type::getInt32Ty(M->getContext()),
- LiveStart + find_index(LiveVariables, LiveVariables[i]));
+ Builder.getInt32(LiveStart + find_index(LiveVariables, BasePtrs[i]));
+ Value *LiveIdx =
+ Builder.getInt32(LiveStart + find_index(LiveVariables, LiveVariables[i]));
// only specify a debug name if we can give a useful one
Value *Reloc = Builder.CreateCall(
More information about the llvm-commits
mailing list