[SelectionDAG] Handle trapping aggregate (PR49839)

Call canTrap() on Constant to account for trapping
ConstantAggregate.
This commit is contained in:
Nikita Popov 2022-06-13 15:05:13 +02:00
parent 483a4b2226
commit b9a7dea917
2 changed files with 5 additions and 5 deletions

View 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

View 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