aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2016-09-08 21:53:33 +0000
committerDehao Chen <dehao@google.com>2016-09-08 21:53:33 +0000
commit87823f8e4d861a03da136d8de02e9140c53bad25 (patch)
tree2e2428b3a80fd43d2ebaa2779647bdf4b17f2f13 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentc442cff96ec579ef9bb5232f9d6dd9cb1c4f0bd4 (diff)
downloadllvm-87823f8e4d861a03da136d8de02e9140c53bad25.zip
llvm-87823f8e4d861a03da136d8de02e9140c53bad25.tar.gz
llvm-87823f8e4d861a03da136d8de02e9140c53bad25.tar.bz2
Remove debug info when hoisting instruction from then/else branch.
Summary: The hoisted instruction is executed speculatively. It could affect the debugging experience as user would see gdb go into code that may not be expected to execute. It will also affect sample profile accuracy by assigning incorrect frequency to source within then/else branch. Reviewers: davidxl, dblaikie, chandlerc, kcc, echristo Subscribers: mehdi_amini, probinson, eric_niebler, andreadb, llvm-commits Differential Revision: https://reviews.llvm.org/D24164 llvm-svn: 280995
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 1d5d853..921f325 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1242,6 +1242,14 @@ static bool HoistThenElseCodeToIf(BranchInst *BI,
LLVMContext::MD_dereferenceable_or_null,
LLVMContext::MD_mem_parallel_loop_access};
combineMetadata(I1, I2, KnownIDs);
+
+ // If the debug loc for I1 and I2 are different, as we are combining them
+ // into one instruction, we do not want to select debug loc randomly from
+ // I1 or I2. Instead, we set the 0-line DebugLoc to note that we do not
+ // know the debug loc of the hoisted instruction.
+ if (!isa<CallInst>(I1) && I1->getDebugLoc() != I2->getDebugLoc())
+ I1->setDebugLoc(DebugLoc());
+
I2->eraseFromParent();
Changed = true;