llvm.org GIT mirror llvm / dc70679
[WinEH] CatchHandler which don't have catch objects in StackColoring StackColoring rewrites the frame indicies of operations involving allocas if it can find that the life time of two objects do not overlap. MSVC EH needs to be kept aware of this if happens in the event that a catch object has moved around. However, we represent the non-existance of a catch object with a sentinel frame index (INT_MAX). This sentinel also happens to be the EmptyKey of the SlotRemap DenseMap. Testing for whether or not we need to translate the frame index fails in this case because we call the count method on the DenseMap with the EmptyKey, leading to assertions. Instead, check if it is our sentinel value before trying to look into the DenseMap. This fixes PR26073. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257182 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
2 changed file(s) with 41 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
570570 }
571571 }
572572
573 // Update the location of C++ catch objects for the MSVC personality routine.
573574 if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
574575 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
575576 for (WinEHHandlerType &H : TBME.HandlerArray)
576 if (SlotRemap.count(H.CatchObj.FrameIndex))
577 if (H.CatchObj.FrameIndex != INT_MAX &&
578 SlotRemap.count(H.CatchObj.FrameIndex))
577579 H.CatchObj.FrameIndex = SlotRemap[H.CatchObj.FrameIndex];
578580
579581 DEBUG(dbgs()<<"Fixed "<
4343 ; CHECK-LABEL: $cppxdata$test1:
4444 ; CHECK: .long 32 # CatchObjOffset
4545
46 define void @test2() personality i32 (...)* @__CxxFrameHandler3 {
47 entry:
48 %alloca2 = alloca i8*, align 4
49 %alloca1 = alloca i8*, align 4
50 store volatile i8* null, i8** %alloca1
51 invoke void @throw()
52 to label %unreachable unwind label %catch.dispatch
53
54 ; CHECK-LABEL: test2:
55 ; CHECK: movq $0, -16(%rbp)
56 ; CHECK: callq throw
57
58 catch.dispatch: ; preds = %entry
59 %cs = catchswitch within none [label %catch.pad] unwind to caller
60
61 catch.pad: ; preds = %catch.dispatch
62 %cp = catchpad within %cs [i8* null, i32 0, i8** null]
63 store volatile i8* null, i8** %alloca1
64 %bc1 = bitcast i8** %alloca1 to i8*
65 call void @llvm.lifetime.end(i64 4, i8* nonnull %bc1)
66 %bc2 = bitcast i8** %alloca2 to i8*
67 call void @llvm.lifetime.start(i64 4, i8* %bc2)
68 store volatile i8* null, i8** %alloca1
69 unreachable
70
71 ; CHECK-LABEL: "?catch$2@?0?test2@4HA"
72 ; CHECK: movq $0, -16(%rbp)
73 ; CHECK: movq $0, -16(%rbp)
74 ; CHECK: ud2
75
76 unreachable: ; preds = %entry
77 unreachable
78 }
79
80 ; CHECK-LABEL: $cppxdata$test2:
81 ; CHECK: .long 0 # CatchObjOffset
82
83
4684 ; Function Attrs: argmemonly nounwind
4785 declare void @llvm.lifetime.start(i64, i8* nocapture) #0
4886