llvm.org GIT mirror llvm / 204e31b
[WinEH] Update WinEHFuncInfo if StackColoring merges allocas Windows EH keeping track of which frame index corresponds to a catchpad in order to inform the runtime where the catch parameter should be initialized. LLVM's optimizations are able to prove that the memory used by the catch parameter can be reused with another memory optimization, changing it's frame index. We need to keep WinEHFuncInfo up to date with respect to this or we will miscompile/assert. This fixes PR26069. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257158 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 4 years ago
3 changed file(s) with 64 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4242 #include "llvm/CodeGen/PseudoSourceValue.h"
4343 #include "llvm/CodeGen/SlotIndexes.h"
4444 #include "llvm/CodeGen/StackProtector.h"
45 #include "llvm/CodeGen/WinEHFuncInfo.h"
4546 #include "llvm/IR/DebugInfo.h"
4647 #include "llvm/IR/Dominators.h"
4748 #include "llvm/IR/Function.h"
569570 }
570571 }
571572
573 if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
574 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
575 for (WinEHHandlerType &H : TBME.HandlerArray)
576 if (SlotRemap.count(H.CatchObj.FrameIndex))
577 H.CatchObj.FrameIndex = SlotRemap[H.CatchObj.FrameIndex];
578
572579 DEBUG(dbgs()<<"Fixed "<
573580 DEBUG(dbgs()<<"Fixed "<
574581 DEBUG(dbgs()<<"Fixed "<
143143 HT.TypeDescriptor = cast(TypeInfo->stripPointerCasts());
144144 HT.Adjectives = cast(CPI->getArgOperand(1))->getZExtValue();
145145 HT.Handler = CPI->getParent();
146 if (isa(CPI->getArgOperand(2)))
146 if (auto *AI =
147 dyn_cast(CPI->getArgOperand(2)->stripPointerCasts()))
148 HT.CatchObj.Alloca = AI;
149 else
147150 HT.CatchObj.Alloca = nullptr;
148 else
149 HT.CatchObj.Alloca = cast(CPI->getArgOperand(2));
150151 TBME.HandlerArray.push_back(HT);
151152 }
152153 FuncInfo.TryBlockMap.push_back(TBME);
0 ; RUN: llc < %s | FileCheck %s
1
2 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
3 target triple = "x86_64-pc-windows-msvc"
4
5 declare void @throw()
6
7 declare i32 @__CxxFrameHandler3(...)
8
9 define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
10 entry:
11 %alloca2 = alloca i8*, align 4
12 %alloca1 = alloca i8*, align 4
13 store volatile i8* null, i8** %alloca1
14 invoke void @throw()
15 to label %unreachable unwind label %catch.dispatch
16
17 ; CHECK-LABEL: test1:
18 ; CHECK: movq $0, -16(%rbp)
19 ; CHECK: callq throw
20
21 catch.dispatch: ; preds = %entry
22 %cs = catchswitch within none [label %catch.pad] unwind to caller
23
24 catch.pad: ; preds = %catch.dispatch
25 %cp = catchpad within %cs [i8* null, i32 0, i8** %alloca1]
26 store volatile i8* null, i8** %alloca1
27 %bc1 = bitcast i8** %alloca1 to i8*
28 call void @llvm.lifetime.end(i64 4, i8* nonnull %bc1)
29 %bc2 = bitcast i8** %alloca2 to i8*
30 call void @llvm.lifetime.start(i64 4, i8* %bc2)
31 store volatile i8* null, i8** %alloca1
32 unreachable
33
34 ; CHECK-LABEL: "?catch$2@?0?test1@4HA"
35 ; CHECK: movq $0, -16(%rbp)
36 ; CHECK: movq $0, -16(%rbp)
37 ; CHECK: ud2
38
39 unreachable: ; preds = %entry
40 unreachable
41 }
42
43 ; CHECK-LABEL: $cppxdata$test1:
44 ; CHECK: .long 32 # CatchObjOffset
45
46 ; Function Attrs: argmemonly nounwind
47 declare void @llvm.lifetime.start(i64, i8* nocapture) #0
48
49 ; Function Attrs: argmemonly nounwind
50 declare void @llvm.lifetime.end(i64, i8* nocapture) #0
51
52 attributes #0 = { argmemonly nounwind }