[llvm-bugs] [Bug 37788] New: `llvm.experimental.stackmap` is erroneously marked `Throws`?

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 13 06:32:41 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37788

            Bug ID: 37788
           Summary: `llvm.experimental.stackmap` is erroneously marked
                    `Throws`?
           Product: new-bugs
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: vext01 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Over the last few days I have been experimenting with inserting stackmaps from
the Rust compiler.

After inserting some `call`s (not `invoke`s) to llvm.experimental.stackmap into
rustc's llvm
codegen, and then allowing the compiler to build itself using this change, I
was surprised to see:

```
Cannot invoke an intrinsic other than donothing, patchpoint, statepoint,
coro_resume or coro_destroy
invoke void (i64, i32, ...%) @llvm.experimental.stackmap(i64 1, i32 0)
          to label 13
```

As I understand, this is LLVM's way of saying, you can't `invoke` (expecting a
possible exception) an intrinsic which cannot raise an exception.

Having spoke to one of the Rust developers about this, and after trying
a few things, it seems that LLVM's inlining pass is itself allowing `call`s to
the stackmap intrinsic to be translated to `invoke`s. Then the verifier rejects
the resulting code.

We suspect that the fix is as follows:

```
diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td
index a2a1f26292c..9bbe22645ac 100644
--- a/include/llvm/IR/Intrinsics.td
+++ b/include/llvm/IR/Intrinsics.td
@@ -720,8 +720,7 @@ def int_invariant_group_barrier :
Intrinsic<[llvm_anyptr_ty],
 //===------------------------ Stackmap Intrinsics
-------------------------===//
 //
 def int_experimental_stackmap : Intrinsic<[],
-                                  [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
-                                  [Throws]>;
+                                  [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
[]>;
 def int_experimental_patchpoint_void : Intrinsic<[],
                                                  [llvm_i64_ty, llvm_i32_ty,
                                                   llvm_ptr_ty, llvm_i32_ty,
```

In other words, remove `Throws` from the signature of
`int_experimental_stackmap`.

With this patch applied, I managed to run a stage 2 rustc build without the
verifier getting upset.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180613/f703d917/attachment.html>


More information about the llvm-bugs mailing list