When llvm Interpreter is used to execute bitcode, it shall be able to handle TargetExtType.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Sorry for the delay in reviewing this patch.
I'm not an expert in the JIT code, so I'm not completely certain that this code covers all the bases (in particular, it's somewhat unclear to me if this is handling globals correctly).
You should be able to add a test for this code along the lines of test/ExecutionEngine/test-interp-aggregate.ll, that would at least make sure that load/store, global variables, ConstantTargetNone, and poison value initializers work correctly. That would definitely make me more comfortable re the global variable support.
I don't have a test case of global variable with target extension type.
poison value initializers
doe this mean something like "store target("spirv.Event") poison, ptr %event, align 8"?
An alterative approach to this patch is to lower target extension type to its layout type before executing interpreter. I'm proposing this patch as I think it might worth adding natively support of target extension type to interpreter. I don't know if this support will be useful for someone else. There could be cases that target extension type exists in bitcode input of an interpreter.
A simple @global = target("spirv.Event") zeroinitializer should suffice, combined with a load or store of that global. The point is to make sure that the interpreter can handle a global variable having a target extension type without crashing.
poison value initializers
doe this mean something like "store target("spirv.Event") poison, ptr %event, align 8"?
Yes.
An alterative approach to this patch is to lower target extension type to its layout type before executing interpreter. I'm proposing this patch as I think it might worth adding natively support of target extension type to interpreter. I don't know if this support will be useful for someone else. There could be cases that target extension type exists in bitcode input of an interpreter.
That's another approach I considered, but I think this approach works a little better. Although you did remind me that there should be a comment somewhere justifying that it is safe to treat the target extension type as its layout type, since the only thing the interpreter is doing is zero-initializing or copying the bits around, and never otherwise inspecting or touching them.
add test of global and poison value, add comment of 'It is safe to treat TargetExtType as its layout type'