[llvm] d72c586 - [NFC] Rename function to match Coding Convention and fix typo in KnowledgeRetention

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 10:36:04 PDT 2020


Author: Tyker
Date: 2020-03-25T18:31:13+01:00
New Revision: d72c586aebaff1e47f246bef1ea7cb6408852a01

URL: https://github.com/llvm/llvm-project/commit/d72c586aebaff1e47f246bef1ea7cb6408852a01
DIFF: https://github.com/llvm/llvm-project/commit/d72c586aebaff1e47f246bef1ea7cb6408852a01.diff

LOG: [NFC] Rename function to match Coding Convention and fix typo in KnowledgeRetention

Added: 
    

Modified: 
    llvm/include/llvm/IR/KnowledgeRetention.h
    llvm/lib/IR/KnowledgeRetention.cpp
    llvm/lib/Transforms/Utils/InlineFunction.cpp
    llvm/unittests/IR/KnowledgeRetentionTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/KnowledgeRetention.h b/llvm/include/llvm/IR/KnowledgeRetention.h
index a7de7cd16b66..3c6766e79ed0 100644
--- a/llvm/include/llvm/IR/KnowledgeRetention.h
+++ b/llvm/include/llvm/IR/KnowledgeRetention.h
@@ -28,10 +28,7 @@ class IntrinsicInst;
 /// from the given instruction.
 /// If no information derived from \p I, this call returns null.
 /// The returned instruction is not inserted anywhere.
-CallInst *BuildAssumeFromInst(const Instruction *I, Module *M);
-inline CallInst *BuildAssumeFromInst(Instruction *I) {
-  return BuildAssumeFromInst(I, I->getModule());
-}
+IntrinsicInst *buildAssumeFromInst(Instruction *I);
 
 /// It is possible to have multiple Value for the argument of an attribute in
 /// the same llvm.assume on the same llvm::Value. This is rare but need to be

diff  --git a/llvm/lib/IR/KnowledgeRetention.cpp b/llvm/lib/IR/KnowledgeRetention.cpp
index aa83d0fd6df8..04a27ed0f82a 100644
--- a/llvm/lib/IR/KnowledgeRetention.cpp
+++ b/llvm/lib/IR/KnowledgeRetention.cpp
@@ -149,7 +149,7 @@ struct AssumeBuilderState {
       addAttrList(Fn->getAttributes());
   }
 
-  CallInst *build() {
+  IntrinsicInst *build() {
     if (AssumedKnowledgeSet.empty())
       return nullptr;
     Function *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
@@ -169,8 +169,8 @@ struct AssumeBuilderState {
       OpBundle.push_back(OperandBundleDefT<Value *>(Elem.Name, Args));
     }
     llvm::sort(OpBundle, isLowerOpBundle);
-    return CallInst::Create(
-        FnAssume, ArrayRef<Value *>({ConstantInt::getTrue(C)}), OpBundle);
+    return cast<IntrinsicInst>(CallInst::Create(
+        FnAssume, ArrayRef<Value *>({ConstantInt::getTrue(C)}), OpBundle));
   }
 
   void addInstruction(const Instruction *I) {
@@ -183,15 +183,15 @@ struct AssumeBuilderState {
 
 } // namespace
 
-CallInst *llvm::BuildAssumeFromInst(const Instruction *I, Module *M) {
+IntrinsicInst *llvm::buildAssumeFromInst(Instruction *I) {
   if (!EnableKnowledgeRetention)
     return nullptr;
-  AssumeBuilderState Builder(M);
+  AssumeBuilderState Builder(I->getModule());
   Builder.addInstruction(I);
   return Builder.build();
 }
 
-static bool BundleHasArguement(const CallBase::BundleOpInfo &BOI,
+static bool bundleHasArgument(const CallBase::BundleOpInfo &BOI,
                                unsigned Idx) {
   return BOI.End - BOI.Begin > Idx;
 }
@@ -199,7 +199,7 @@ static bool BundleHasArguement(const CallBase::BundleOpInfo &BOI,
 static Value *getValueFromBundleOpInfo(IntrinsicInst &Assume,
                                 const CallBase::BundleOpInfo &BOI,
                                 unsigned Idx) {
-  assert(BundleHasArguement(BOI, Idx) && "index out of range");
+  assert(bundleHasArgument(BOI, Idx) && "index out of range");
   return (Assume.op_begin() + BOI.Begin + Idx)->get();
 }
 
@@ -249,12 +249,12 @@ void llvm::fillMapFromAssume(CallInst &AssumeCI, RetainedKnowledgeMap &Result) {
   for (auto &Bundles : Assume.bundle_op_infos()) {
     std::pair<Value *, Attribute::AttrKind> Key{
         nullptr, Attribute::getAttrKindFromName(Bundles.Tag->getKey())};
-    if (BundleHasArguement(Bundles, BOIE_WasOn))
+    if (bundleHasArgument(Bundles, BOIE_WasOn))
       Key.first = getValueFromBundleOpInfo(Assume, Bundles, BOIE_WasOn);
 
     if (Key.first == nullptr && Key.second == Attribute::None)
       continue;
-    if (!BundleHasArguement(Bundles, BOIE_Argument)) {
+    if (!bundleHasArgument(Bundles, BOIE_Argument)) {
       Result[Key][&Assume] = {0, 0};
       continue;
     }
@@ -301,7 +301,7 @@ bool llvm::isAssumeWithEmptyBundle(CallInst &CI) {
 PreservedAnalyses AssumeBuilderPass::run(Function &F,
                                          FunctionAnalysisManager &AM) {
   for (Instruction &I : instructions(F))
-    if (Instruction *Assume = BuildAssumeFromInst(&I))
+    if (Instruction *Assume = buildAssumeFromInst(&I))
       Assume->insertBefore(&I);
   return PreservedAnalyses::all();
 }

diff  --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 3c921060070c..b8b3d1895093 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1703,7 +1703,7 @@ llvm::InlineResult llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
     AddAlignmentAssumptions(CS, IFI);
 
     /// Preserve all attributes on of the call and its parameters.
-    if (Instruction *Assume = BuildAssumeFromInst(CS.getInstruction()))
+    if (Instruction *Assume = buildAssumeFromInst(CS.getInstruction()))
       Assume->insertBefore(CS.getInstruction());
 
     // We want the inliner to prune the code as it copies.  We would LOVE to

diff  --git a/llvm/unittests/IR/KnowledgeRetentionTest.cpp b/llvm/unittests/IR/KnowledgeRetentionTest.cpp
index aca801d2b296..2ed90b8b4e1e 100644
--- a/llvm/unittests/IR/KnowledgeRetentionTest.cpp
+++ b/llvm/unittests/IR/KnowledgeRetentionTest.cpp
@@ -22,10 +22,6 @@ using namespace llvm;
 extern cl::opt<bool> ShouldPreserveAllAttributes;
 extern cl::opt<bool> EnableKnowledgeRetention;
 
-static IntrinsicInst *buildAssumeFromInst(Instruction *I) {
-  return cast_or_null<IntrinsicInst>(BuildAssumeFromInst(I));
-}
-
 static void RunTest(
     StringRef Head, StringRef Tail,
     std::vector<std::pair<StringRef, llvm::function_ref<void(Instruction *)>>>


        


More information about the llvm-commits mailing list