Ignore PhiNodes when mapping sample profile data
authorDavid Callahan <dcallahan@fb.com>
Mon, 14 Jan 2019 19:05:59 +0000 (19:05 +0000)
committerDavid Callahan <dcallahan@fb.com>
Mon, 14 Jan 2019 19:05:59 +0000 (19:05 +0000)
Summary: Like branch instructions, phi nodes frequently do not have debug information related to the block they are in and so they should be ignored.

Reviewers: danielcdh, twoh, Kader, wmi

Reviewed By: wmi

Subscribers: aprantl, llvm-commits

Differential Revision: https://reviews.llvm.org/D55094

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351102 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/SampleProfile.cpp

index 06a1ce89827f65265ecce14a60021fce6504415f..1e86e04a79d320417e0ddafccc4ebc1b6113d2eb 100644 (file)
@@ -544,10 +544,10 @@ ErrorOr<uint64_t> SampleProfileLoader::getInstWeight(const Instruction &Inst) {
   if (!FS)
     return std::error_code();
 
-  // Ignore all intrinsics and branch instructions.
-  // Branch instruction usually contains debug info from sources outside of
+  // Ignore all intrinsics, phinodes and branch instructions.
+  // Branch and phinodes instruction usually contains debug info from sources outside of
   // the residing basic block, thus we ignore them during annotation.
-  if (isa<BranchInst>(Inst) || isa<IntrinsicInst>(Inst))
+  if (isa<BranchInst>(Inst) || isa<IntrinsicInst>(Inst) || isa<PHINode>(Inst))
     return std::error_code();
 
   // If a direct call/invoke instruction is inlined in profile