summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSergey Dmitrouk <sdmitrouk@accesssoftek.com>2015-06-04 20:48:40 +0000
committerSergey Dmitrouk <sdmitrouk@accesssoftek.com>2015-06-04 20:48:40 +0000
commit3160d02b5b039d0b7b30c13e5410b9a1a5b6feed (patch)
tree342b3843402e530c7ab9907e5a988fb8eeffe560 /llvm/lib/CodeGen
parentd8445a5617d6af05883721afef4c32458923b7e3 (diff)
downloadbcm5719-llvm-3160d02b5b039d0b7b30c13e5410b9a1a5b6feed.tar.gz
bcm5719-llvm-3160d02b5b039d0b7b30c13e5410b9a1a5b6feed.zip
Erase constant dbgloc on reuse in PHI node
Basic block selection involves checking successor BBs for PHI nodes that depend on the current BB. In case such BBs are found, the value being selected is a constant and such constant already exists in current BB, it's value is reused. This might lead to wrong locations in some situations, especially if same constant value ends up being materialized twice in two different ways, which discards that sharing and leaves us with wrong debug location in the successor BB. In code this involves the following sequence of calls: SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks -> SelectionDAGBuilder::CopyValueToVirtualRegister -> SelectionDAGBuilder::getNonRegisterValue llvm-svn: 239089
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index a0eea9ffb06..cf0900f59e8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1002,7 +1002,16 @@ bool SelectionDAGBuilder::findValue(const Value *V) const {
SDValue SelectionDAGBuilder::getNonRegisterValue(const Value *V) {
// If we already have an SDValue for this value, use it.
SDValue &N = NodeMap[V];
- if (N.getNode()) return N;
+ if (N.getNode()) {
+ if (isa<ConstantSDNode>(N) || isa<ConstantFPSDNode>(N)) {
+ // Remove the debug location from the node as the node is about to be used
+ // in a location which may differ from the original debug location. This
+ // is relevant to Constant and ConstantFP nodes because they can appear
+ // as constant expressions inside PHI nodes.
+ N->setDebugLoc(DebugLoc());
+ }
+ return N;
+ }
// Otherwise create a new SDValue and remember it.
SDValue Val = getValueImpl(V);
OpenPOWER on IntegriCloud