[PATCH] Add a Windows EH preparation pass that zaps resumes

Reid Kleckner rnk at google.com
Wed Jan 28 16:33:43 PST 2015


Seems like the IR to IR test worked... I'm surprised TargetMachine isn't null, causing DwarfEHPrepare crashes... but I'll take what I can get.


================
Comment at: lib/CodeGen/WinEHPrepare.cpp:28-29
@@ +27,4 @@
+
+namespace {
+  class WinEHPrepare : public FunctionPass {
+    const TargetMachine *TM;
----------------
majnemer wrote:
> I wouldn't indent `WinEHPrepare`: http://llvm.org/docs/CodingStandards.html#namespace-indentation
True, thanks. This was cribbed from DwarfEHPrepare.

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:78
@@ +77,3 @@
+  // Classify the personality to see what kind of preparation we need.
+  EHPersonality Pers = ClassifyEHPersonality(LPads[0]->getPersonalityFn());
+
----------------
majnemer wrote:
> `LPads.back()` perhaps?
> 
> I bet you intended on using this `LPads` vector in the future, right now it seems pretty useless though.
Sure. I am collecting the landing pads for future use.

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:92-93
@@ +91,4 @@
+    IRBuilder<> Builder(Resume);
+    Builder.CreateCall(Trap);
+    Builder.CreateUnreachable();
+    Resume->eraseFromParent();
----------------
majnemer wrote:
> Why do you create a call to `@llvm.trap` and an `unreachable` instruction?
unreachable is typically not ud2a, but literally "nothing" on non-windows platforms, but I guess unreachable is fine on Windows. We'll get one ud2a.

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:101
@@ +100,3 @@
+bool WinEHPrepare::doFinalization(Module &M) {
+  return DwarfPrepare->doFinalization(M);
+}
----------------
majnemer wrote:
> Does it make sense to do this unconditionally, even if the function has MSVC personality?
Yes, this is whole module finalization, so some functions could be MSVC and some could be GCC.

================
Comment at: lib/CodeGen/WinEHPrepare.cpp:105
@@ +104,3 @@
+void WinEHPrepare::getAnalysisUsage(AnalysisUsage &AU) const {
+  DwarfPrepare->getAnalysisUsage(AU);
+}
----------------
majnemer wrote:
> Does it make sense to do this unconditionally, even if the function has MSVC personality?
ditto

http://reviews.llvm.org/D7216

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list