llvm.org GIT mirror llvm / b4eeb6b
[WinEH] Make sure LSDA tables are 4 byte aligned Apparently this is important, otherwise _except_handler3 assumes that the registration node is corrupted and ignores it. Also fix a bug in WinEHPrepare where we would insert code after a terminator instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241877 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 5 years ago
7 changed file(s) with 12 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
349349 // EHFlags & 1 -> Synchronous exceptions only, no async exceptions.
350350 // EHFlags & 2 -> ???
351351 // EHFlags & 4 -> The function is noexcept(true), unwinding can't continue.
352 OS.EmitValueToAlignment(4);
352353 OS.EmitLabel(FuncInfoXData);
353354 OS.EmitIntValue(0x19930522, 4); // MagicNumber
354355 OS.EmitIntValue(FuncInfo.UnwindMap.size(), 4); // MaxState
577578
578579 // Emit the __ehtable label that we use for llvm.x86.seh.lsda.
579580 MCSymbol *LSDALabel = Asm->OutContext.getOrCreateLSDASymbol(FLinkageName);
581 OS.EmitValueToAlignment(4);
580582 OS.EmitLabel(LSDALabel);
581583
582584 const Function *Per = MMI->getPersonality();
439439
440440 // Replace the call (if it exists) with new one. Otherwise, insert at the end
441441 // of the entry block.
442 IRBuilder<> Builder(&F.getEntryBlock(),
443 EscapeCall ? EscapeCall : F.getEntryBlock().end());
442 Instruction *InsertPt = EscapeCall;
443 if (!EscapeCall)
444 InsertPt = F.getEntryBlock().getTerminator();
445 IRBuilder<> Builder(&F.getEntryBlock(), InsertPt);
444446 Builder.CreateCall(FrameEscape, Args);
445447 if (EscapeCall)
446448 EscapeCall->eraseFromParent();
113113 ; CHECK: .seh_handlerdata
114114 ; CHECK: .long ($cppxdata$main)@IMGREL
115115
116 ; CHECK: .align 4
116117 ; CHECK-NEXT: $cppxdata$main:
117118 ; CHECK-NEXT: .long 429065506
118119 ; CHECK-NEXT: .long 2
120120 ; CHECK-NOT: jmpq *
121121 ; CHECK: .seh_handlerdata
122122 ; CHECK-NEXT: .long ("$cppxdata$?f@@YAXXZ")@IMGREL
123 ; CHECK-NEXT: .align 4
123124 ; CHECK-NEXT:"$cppxdata$?f@@YAXXZ":
124125 ; CHECK-NEXT: .long 429065506
125126 ; CHECK-NEXT: .long 4
2929 ; CHECK-LABEL: "?test1@@YAXXZ":
3030 ; CHECK: .seh_handlerdata
3131 ; CHECK-NEXT: .long ("$cppxdata$?test1@@YAXXZ")@IMGREL
32 ; CHECK-NEXT: .align 4
3233 ; CHECK-NEXT:"$cppxdata$?test1@@YAXXZ":
3334 ; CHECK-NEXT: .long 429065506
3435 ; CHECK-NEXT: .long 1
9192 ; CHECK-LABEL: "?test2@@YAX_N@Z":
9293 ; CHECK: .seh_handlerdata
9394 ; CHECK-NEXT: .long ("$cppxdata$?test2@@YAX_N@Z")@IMGREL
95 ; CHECK-NEXT: .align 4
9496 ; CHECK-NEXT:"$cppxdata$?test2@@YAX_N@Z":
9597 ; CHECK-NEXT: .long 429065506
9698 ; CHECK-NEXT: .long 2
8989
9090 ; CHECK: .section .xdata,"dr"
9191 ; CHECK: Lmain$parent_frame_offset = Lmain$frame_escape_1
92 ; CHECK: .align 4
9293 ; CHECK: L__ehtable$main
9394 ; CHECK-NEXT: .long -1
9495 ; CHECK-NEXT: .long _filt$main
131131 ; CHECK: retl
132132
133133 ; CHECK: .section .xdata,"dr"
134 ; CHECK: .align 4
134135 ; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3:
135136 ; CHECK-NEXT: .long 429065506
136137 ; CHECK-NEXT: .long 2