[SelectionDAG] Handle trapping aggregate (PR49839)
authorNikita Popov <npopov@redhat.com>
Mon, 13 Jun 2022 13:05:13 +0000 (15:05 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 13 Jun 2022 13:06:53 +0000 (15:06 +0200)
Call canTrap() on Constant to account for trapping
ConstantAggregate.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/test/CodeGen/X86/pr49839-trapping-aggregate.ll

index cd1d63086edc45c97244faf9ec74a7711c5674ec..2b63359c2b1b6503908a87e72c3e636386473f5a 100644 (file)
@@ -367,8 +367,8 @@ static void SplitCriticalSideEffectEdges(Function &Fn, DominatorTree *DT,
     // PHI.
     for (BasicBlock::iterator I = BB.begin(); (PN = dyn_cast<PHINode>(I)); ++I)
       for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
-        ConstantExpr *CE = dyn_cast<ConstantExpr>(PN->getIncomingValue(i));
-        if (!CE || !CE->canTrap()) continue;
+        Constant *C = dyn_cast<Constant>(PN->getIncomingValue(i));
+        if (!C || !C->canTrap()) continue;
 
         // The only case we have to worry about is when the edge is critical.
         // Since this block has a PHI Node, we assume it has multiple input
index 7b606acc9227a09ed8b99261fb3102e9a804eb34..e5c23839f0388edf0ed19b4c88fd6d85b1da799d 100644 (file)
@@ -9,12 +9,12 @@ define <1 x i64> @trapping_const_agg(i1 %c, i1 %c2) {
 ; CHECK-NEXT:    testb $1, %dil
 ; CHECK-NEXT:    je .LBB0_4
 ; CHECK-NEXT:  # %bb.1: # %if
+; CHECK-NEXT:    testb $1, %sil
+; CHECK-NEXT:    je .LBB0_4
+; CHECK-NEXT:  # %bb.2: # %if.end_crit_edge
 ; CHECK-NEXT:    movl $1, %eax
 ; CHECK-NEXT:    xorl %edx, %edx
 ; CHECK-NEXT:    idivq g@GOTPCREL(%rip)
-; CHECK-NEXT:    testb $1, %sil
-; CHECK-NEXT:    je .LBB0_4
-; CHECK-NEXT:  # %bb.2:
 ; CHECK-NEXT:    movq %rdx, %rax
 ; CHECK-NEXT:    retq
 ; CHECK-NEXT:  .LBB0_4: # %end2