[PATCH] D19268: [DAGCombiner] Skip folding constants when optimizations are disabled

Marianne Mailhot-Sarrasin via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 08:58:30 PDT 2016


mamai created this revision.
mamai added a reviewer: resistor.
mamai added a subscriber: llvm-commits.
mamai set the repository for this revision to rL LLVM.

This combiner breaks debug experience and should not be run when optimizations are disabled.

For example:
int main() {
	int j = 0;
	j += 2;
	if (j == 2) return 0;
	return 5;
}
When debugging this code compiled in /O0, it should be valid to break at line "j+=2;" and edit the value of j. It should change the return value of the function.

Repository:
  rL LLVM

http://reviews.llvm.org/D19268

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -10002,8 +10002,11 @@
     if (ISD::isNON_TRUNCStore(Chain.getNode())) {
       StoreSDNode *PrevST = cast<StoreSDNode>(Chain);
       if (PrevST->getBasePtr() == Ptr &&
-          PrevST->getValue().getValueType() == N->getValueType(0))
-      return CombineTo(N, Chain.getOperand(1), Chain);
+          PrevST->getValue().getValueType() == N->getValueType(0)) {
+        if (OptLevel != CodeGenOpt::None ||
+            !isa<ConstantSDNode>(Chain.getOperand(1)))
+          return CombineTo(N, Chain.getOperand(1), Chain);
+      }
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19268.54199.patch
Type: text/x-patch
Size: 757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160419/cfabc1c6/attachment.bin>


More information about the llvm-commits mailing list