// SSAUpdater.AddAvailableValue(...) later.
BasicBlock *Entry = &F.getEntryBlock();
DebugLoc FirstDL = getOrCreateDebugLoc(&*Entry->begin(), F.getSubprogram());
+ SplitBlock(Entry, &*Entry->getFirstInsertionPt());
+
BinaryOperator *SetjmpTableSize =
BinaryOperator::Create(Instruction::Add, IRB.getInt32(4), IRB.getInt32(0),
- "setjmpTableSize", &*Entry->getFirstInsertionPt());
+ "setjmpTableSize", Entry->getTerminator());
SetjmpTableSize->setDebugLoc(FirstDL);
// setjmpTable = (int *) malloc(40);
Instruction *SetjmpTable = CallInst::CreateMalloc(
invoke void @foo()
to label %try.cont unwind label %lpad
-; CHECK: entry.split:
+; CHECK: entry.split.split:
; CHECK: %[[CMP0:.*]] = icmp ne i32 %__THREW__.val, 0
; CHECK-NEXT: %__threwValue.val = load i32, i32* @__threwValue
; CHECK-NEXT: %[[CMP1:.*]] = icmp ne i32 %__threwValue.val, 0
; CHECK-NEXT: br i1 %[[CMP]], label %if.then1, label %if.else1
; This is exception checking part. %if.else1 leads here
-; CHECK: entry.split.split:
+; CHECK: entry.split.split.split:
; CHECK-NEXT: %[[CMP:.*]] = icmp eq i32 %__THREW__.val, 1
; CHECK-NEXT: br i1 %[[CMP]], label %lpad, label %try.cont
; CHECK-LABEL: @malloc_test
define void @malloc_test() {
entry:
-; CHECK-LABEL: entry
- ; All setjmp table preparations have to happen within the entry block. These
- ; check lines list only some of the instructions for that.
; CHECK: call i8* @malloc
- ; CHECK: call i32* @saveSetjmp
- ; CHECK: call i32 @getTempRet0
%retval = alloca i32, align 4
%jmp = alloca [1 x %struct.__jmp_buf_tag], align 16
store i32 0, i32* %retval, align 4
%call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #0
call void @foo()
ret void
-
-; CHECK-LABEL: entry.split
}
; This is a dummy dlmalloc implemenation only to make compiler pass, because an
; CHECK: entry:
; CHECK-NEXT: call i8* @malloc(i32 40), !dbg ![[DL0:.*]]
; CHECK-NEXT: bitcast {{.*}}, !dbg ![[DL0]]
+
+; CHECK: entry.split:
; CHECK: alloca {{.*}}, !dbg ![[DL0]]
; CHECK: call i32* @saveSetjmp{{.*}}, !dbg ![[DL1:.*]]
; CHECK-NEXT: call i32 @getTempRet0{{.*}}, !dbg ![[DL1]]
; CHECK-NEXT: br {{.*}}, !dbg ![[DL2:.*]]
-; CHECK: entry.split:
+; CHECK: entry.split.split:
; CHECK: call {{.*}} void @__invoke_void{{.*}}, !dbg ![[DL2]]
-; CHECK: entry.split.split:
+; CHECK: entry.split.split.split:
; CHECK-NEXT: bitcast {{.*}}, !dbg ![[DL3:.*]]
; CHECK-NEXT: call void @free{{.*}}, !dbg ![[DL3]]
; CHECK-NEXT: %[[SETJMP_TABLE:.*]] = bitcast i8* %[[MALLOCCALL]] to i32*
; CHECK-NEXT: store i32 0, i32* %[[SETJMP_TABLE]]
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE:.*]] = add i32 4, 0
+; CHECK-NEXT: br label %entry.split
+
+; CHECK: entry.split
; CHECK-NEXT: %[[BUF:.*]] = alloca [1 x %struct.__jmp_buf_tag]
; CHECK-NEXT: %[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %[[BUF]], i32 0, i32 0
; CHECK-NEXT: %[[SETJMP_TABLE1:.*]] = call i32* @saveSetjmp(%struct.__jmp_buf_tag* %[[ARRAYDECAY]], i32 1, i32* %[[SETJMP_TABLE]], i32 %[[SETJMP_TABLE_SIZE]])
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE1:.*]] = call i32 @getTempRet0()
-; CHECK-NEXT: br label %entry.split
+; CHECK-NEXT: br label %entry.split.split
-; CHECK: entry.split:
-; CHECK-NEXT: phi i32 [ 0, %entry ], [ %[[LONGJMP_RESULT:.*]], %if.end ]
+; CHECK: entry.split.split:
+; CHECK-NEXT: phi i32 [ 0, %entry.split ], [ %[[LONGJMP_RESULT:.*]], %if.end ]
; CHECK-NEXT: %[[ARRAYDECAY1:.*]] = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %[[BUF]], i32 0, i32 0
; CHECK-NEXT: %[[JMPBUF:.*]] = ptrtoint %struct.__jmp_buf_tag* %[[ARRAYDECAY1]] to [[PTR]]
; CHECK-NEXT: store [[PTR]] 0, [[PTR]]* @__THREW__
; CHECK-NEXT: %[[CMP:.*]] = and i1 %[[CMP0]], %[[CMP1]]
; CHECK-NEXT: br i1 %[[CMP]], label %if.then1, label %if.else1
-; CHECK: entry.split.split:
+; CHECK: entry.split.split.split:
; CHECK-NEXT: unreachable
; CHECK: if.then1:
; CHECK: if.end:
; CHECK-NEXT: %[[LABEL_PHI:.*]] = phi i32 [ %[[LABEL:.*]], %if.end2 ], [ -1, %if.else1 ]
; CHECK-NEXT: %[[LONGJMP_RESULT]] = call i32 @getTempRet0()
-; CHECK-NEXT: switch i32 %[[LABEL_PHI]], label %entry.split.split [
-; CHECK-NEXT: i32 1, label %entry.split
+; CHECK-NEXT: switch i32 %[[LABEL_PHI]], label %entry.split.split.split [
+; CHECK-NEXT: i32 1, label %entry.split.split
; CHECK-NEXT: ]
; CHECK: if.then2:
; CHECK: entry:
; CHECK: %[[SETJMP_TABLE:.*]] = call i32* @saveSetjmp(
-; CHECK: entry.split:
+; CHECK: entry.split.split:
; CHECK: @__invoke_void(void ()* @foo)
-; CHECK: entry.split.split:
+; CHECK: entry.split.split.split:
; CHECK-NEXT: %[[BUF:.*]] = bitcast i32* %[[SETJMP_TABLE]] to i8*
; CHECK-NEXT: tail call void @free(i8* %[[BUF]])
; CHECK-NEXT: ret void
call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 5) #1
unreachable
; CHECK: if.end:
-; CHECK: %[[VAR2]] = phi i32 [ %[[VAR1]], %if.then.split ], [ undef, %entry ]
-; CHECK: %[[SETJMP_TABLE_SIZE3]] = phi i32 [ %[[SETJMP_TABLE_SIZE2]], %if.then.split ], [ %[[SETJMP_TABLE_SIZE0]], %entry ]
-; CHECK: %[[SETJMP_TABLE3]] = phi i32* [ %[[SETJMP_TABLE2]], %if.then.split ], [ %[[SETJMP_TABLE0]], %entry ]
+; CHECK: %[[VAR2]] = phi i32 [ %[[VAR1]], %if.then.split ], [ undef, %entry.split ]
+; CHECK: %[[SETJMP_TABLE_SIZE3]] = phi i32 [ %[[SETJMP_TABLE_SIZE2]], %if.then.split ], [ %[[SETJMP_TABLE_SIZE0]], %entry.split ]
+; CHECK: %[[SETJMP_TABLE3]] = phi i32* [ %[[SETJMP_TABLE2]], %if.then.split ], [ %[[SETJMP_TABLE0]], %entry.split ]
}
; Test a case when a function only calls other functions that are neither setjmp nor longjmp