Skip to content

Commit ca13910

Browse files
committed
Fix pr33010, a 2 year old crashing regression
The problem was that we were creating a CMOV64rr <TargetFrameIndex>, <TargetFrameIndex>. The entire point of a TFI is that address code is not generated, so there's no way to legalize/lower this. Instead, simply prevent it's creation. Arguably, we shouldn't be using *Target*FrameIndices in StatepointLowering at all, but that's a much deeper change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360090 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c2f2a95 commit ca13910

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19008,6 +19008,10 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
1900819008
// locations are not in the default address space.
1900919009
LLD->getPointerInfo().getAddrSpace() != 0 ||
1901019010
RLD->getPointerInfo().getAddrSpace() != 0 ||
19011+
// We can't produce a CMOV of a TargetFrameIndex since we won't
19012+
// generate the address generation required.
19013+
LLD->getBasePtr().getOpcode() == ISD::TargetFrameIndex ||
19014+
RLD->getBasePtr().getOpcode() == ISD::TargetFrameIndex ||
1901119015
!TLI.isOperationLegalOrCustom(TheSelect->getOpcode(),
1901219016
LLD->getBasePtr().getValueType()))
1901319017
return false;

test/CodeGen/X86/pr33010.ll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=x86_64-linux-generic < %s | FileCheck %s
3+
4+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5+
6+
; We can't create a select of two TargetFrameIndices since the rest
7+
; of the backend doesn't know how to handle such a construct.
8+
define i32 addrspace(1)* @test(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i1 %which) gc "statepoint-example" {
9+
; CHECK-LABEL: test:
10+
; CHECK: # %bb.0: # %entry
11+
; CHECK-NEXT: pushq %rbx
12+
; CHECK-NEXT: .cfi_def_cfa_offset 16
13+
; CHECK-NEXT: subq $16, %rsp
14+
; CHECK-NEXT: .cfi_def_cfa_offset 32
15+
; CHECK-NEXT: .cfi_offset %rbx, -16
16+
; CHECK-NEXT: movl %edx, %ebx
17+
; CHECK-NEXT: movq %rdi, (%rsp)
18+
; CHECK-NEXT: movq %rsi, {{[0-9]+}}(%rsp)
19+
; CHECK-NEXT: callq f
20+
; CHECK-NEXT: .Ltmp0:
21+
; CHECK-NEXT: testb $1, %bl
22+
; CHECK-NEXT: je .LBB0_1
23+
; CHECK-NEXT: # %bb.2: # %entry
24+
; CHECK-NEXT: movq (%rsp), %rax
25+
; CHECK-NEXT: jmp .LBB0_3
26+
; CHECK-NEXT: .LBB0_1:
27+
; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rax
28+
; CHECK-NEXT: .LBB0_3: # %entry
29+
; CHECK-NEXT: addq $16, %rsp
30+
; CHECK-NEXT: .cfi_def_cfa_offset 16
31+
; CHECK-NEXT: popq %rbx
32+
; CHECK-NEXT: .cfi_def_cfa_offset 8
33+
; CHECK-NEXT: retq
34+
entry:
35+
%tok = tail call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @f, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* %a, i32 addrspace(1)* %b)
36+
%a.r = tail call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %tok, i32 7, i32 7) ; (%a, %a)
37+
%b.r = tail call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %tok, i32 8, i32 8) ; (%b, %b)
38+
%cond.v = select i1 %which, i8 addrspace(1)* %a.r, i8 addrspace(1)* %b.r
39+
%cond = bitcast i8 addrspace(1)* %cond.v to i32 addrspace(1)*
40+
ret i32 addrspace(1)* %cond
41+
}
42+
43+
declare void @f()
44+
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
45+
declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32, i32)

0 commit comments

Comments
 (0)