From: Philip Reames Date: Tue, 21 Jul 2015 00:49:55 +0000 (+0000) Subject: [RewriteStatepointsForGC] Minor code cleanup [NFC] X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=052b66199df12988ddb5ba4df4bbbd637a4204b5;ds=sidebyside [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242751 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index ae2ae3af0c7..c48321586ba 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -848,14 +848,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) { 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(v); @@ -864,14 +857,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) { 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 LiveVariables, // 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(