[all-commits] [llvm/llvm-project] 750b3d: [WebAssembly] Handle indirect uses of longjmp

Heejin Ahn via All-commits all-commits at lists.llvm.org
Thu Oct 8 11:45:43 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 750b3ddd80f15334409ae6890de035634e14aa72
      https://github.com/llvm/llvm-project/commit/750b3ddd80f15334409ae6890de035634e14aa72
  Author: Heejin Ahn <aheejin at gmail.com>
  Date:   2020-10-08 (Thu, 08 Oct 2020)

  Changed paths:
    M llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
    M llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll

  Log Message:
  -----------
  [WebAssembly] Handle indirect uses of longjmp

In LowerEmscriptenEHSjLj, `longjmp` used to be replaced with
`emscripten_longjmp_jmpbuf(jmp_buf*, i32)`, which will eventually be
lowered to `emscripten_longjmp(i32, i32)`. The reason we used two
different names was because they had different signatures in the IR
pass.

D88697 fixed this by only using `emscripten_longjmp(i32, i32)` and
adding a `ptrtoint` cast to its first argument, so
```
longjmp(buf, 0)
```
becomes
```
emscripten_longjmp((i32)buf, 0)
```

But this assumed all uses of `longjmp` was a direct call to it, which
was not the case. This patch handles indirect uses of `longjmp` by
replacing
```
longjmp
```
with
```
(i32(*)(jmp_buf*, i32))emscripten_longjmp
```

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D89032




More information about the All-commits mailing list