Julia: meta nodes lost when converting back to legacy IR

Created on 15 May 2018  路  4Comments  路  Source: JuliaLang/julia

The new-style IR -> CodeInfo converter forgets about meta nodes, some of which are handled by codegen (@noinline for noinline LLVM IR attr as used by CUDAnative, @polly).
The fix seemed easy, but causes breakage, and I don't have time to look into this right now...

diff --git a/base/compiler/ssair/legacy.jl b/base/compiler/ssair/legacy.jl
index 6e0c9c1444..7593e9a6fa 100644
--- a/base/compiler/ssair/legacy.jl
+++ b/base/compiler/ssair/legacy.jl
@@ -260,6 +260,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs, linetable)
     resize!(ci.slotnames, nargs+1)
     resize!(ci.slotflags, nargs+1)
     ci.code = ir.stmts
+    prepend!(ci.code, ir.meta)
     ci.codelocs = ir.lines
     ci.linetable = linetable
     ci.ssavaluetypes = ir.types

The other replace_code! converter looks like it handled this, but that code seems dead?

gpu optimizer regression

All 4 comments

Why did you close this, without comment? This isn't fixed.

To check if it was fixed :P

I am working on https://github.com/JuliaLang/julia/issues/31442 and was going to propose a macro to activate a function argument for LLVM, similar to how @noinline and @polly are supposed to work, and also following the manual advice at https://docs.julialang.org/en/v1/devdocs/meta/ .

It seems I'm hitting this here issue, though. I can try to work on this if I have an idea of what to do, but I have the impression meta nodes should not be used at the codegen.cpp level anymore, and maybe adding a new node type at https://github.com/JuliaLang/julia/blob/d71310e6a65c2437e0ee4abbb3541f49eb7fce2e/src/codegen.cpp#L4006 is the way to go. Is this really the case? Otherwise how should I proceed preserving the meta nodes?

The first error I could see was just about ci.codelocs, but later is not clear. Are meta nodes ignored anywhere at code generation?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tkoolen picture tkoolen  路  3Comments

iamed2 picture iamed2  路  3Comments

omus picture omus  路  3Comments

ararslan picture ararslan  路  3Comments

musm picture musm  路  3Comments