Fix UB found by -Wtautological-undefined-compare
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 20 Mar 2017 18:01:07 +0000 (18:01 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 20 Mar 2017 18:01:07 +0000 (18:01 +0000)
llvm-svn: 298279

llvm/lib/Transforms/Utils/InlineFunction.cpp

index 0f08d7f..b486df8 100644 (file)
@@ -1439,10 +1439,9 @@ static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap,
                CalleeEntryCount.getValue());
 
   for (auto const &Entry : VMap)
-    if (isa<CallInst>(Entry.first) && &*Entry.second != nullptr &&
-        isa<CallInst>(Entry.second))
-      cast<CallInst>(Entry.second)
-          ->updateProfWeight(CallCount, CalleeEntryCount.getValue());
+    if (isa<CallInst>(Entry.first))
+      if (auto *CI = dyn_cast_or_null<CallInst>(Entry.second))
+        CI->updateProfWeight(CallCount, CalleeEntryCount.getValue());
   for (BasicBlock &BB : *Callee)
     // No need to update the callsite if it is pruned during inlining.
     if (VMap.count(&BB))