[LLVMdev] Exception filter IR model

Joseph Tremoulet jotrem at microsoft.com
Thu Apr 16 10:05:23 PDT 2015


Hi,

I have a question about the IR model for SEH filters (as I want to use the same model for CLR filters).  In particular, when an outer filter is invoked before entering an inner finally, which piece of IR reflects the filter's side-effects?  To take a concrete example, consider this C code:


void foo() {
  int x;
  __try {
    x = 0;
    __try {
      x = 2;
      may_throw();
    }
    __finally {
      if (x == 1) {
        printf("correct\n");
      }
      else {
        printf("incorrect\n");
      }
    }
  }
  __except (x = 1) {
  }
}



The IR for the path from "x = 2" to the load of x in the __finally (via the exception edge) looks like so:


  store i32 2, i32* %x, align 4
  invoke void bitcast (void (...)* @may_throw to void ()*)() #4
          to label %invoke.cont unwind label %lpad

lpad:                                             ; preds = %entry
  %1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
          cleanup
          catch i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0 at 0@foo@@" to i8*)
  %2 = extractvalue { i8*, i32 } %1, 0
  store i8* %2, i8** %exn.slot
  %3 = extractvalue { i8*, i32 } %1, 1
  store i32 %3, i32* %ehselector.slot
  store i8 1, i8* %abnormal.termination.slot
  br label %__finally

__finally:                                        ; preds = %lpad, %invoke.cont
  %0 = load i32, i32* %x, align 4



What I'm wondering is where exactly this models the call to @"\01?filt$0 at 0@foo@@" and its store to x.  Is it implicitly part of the execution of the landingpad instruction itself?  Or of the invoke?

Thanks
-Joseph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150416/29832a50/attachment.html>


More information about the llvm-dev mailing list