Calls to constants should probably be generally handled.
Diff Detail
Event Timeline
What's the point of hiding an error? We should rather produce a normal error message.
HCC had a bug recently that was producing calls to under. I assume a call to null would appear for a pure virtual call. They are undefined to execute, but they could appear in dead code that is never reached so it’s not an error to have them exist
A standard reaction to pure virtual call is a runtime error message and abort. We cannot produce an error message from kernel but we can abort. I would suggest to lower it to s_trap.
I don't think this is how that's implemented. Other targets generate a literal call to null in this case. This is an edge case since typically undef/null calls are turned into unreachable in simplifycfg, which there is a flag to generate a trap on separately.
That is actually very inconvenient to debug kernels which simply hang or misbehave, even if that is an UB. I still suggest our action of preference on unreachable code is to trap. Whenever we can or cannot do it consistently for all unreachable does not seem to matter, we need to start somewhere.
Considering emitting traps requires fixing traps first, otherwise a program that should work will incorrectly trap
Do you agree that is how we have to handle it in principle? If that requres further fixes I do not object a todo comment here.
I think this purpose would be better served by some sort of sanitizer pass. These would typically be deleted, and it's an anomaly these would reach codegen to bother trapping on. Something else should have inserted a trap for useful debugging purposes
I think I've seen calls which should be undef recently, but should stay in a dead code. This is the way our library works, and recently the same behavior seems to appear normal with hcc. It is still a fuzzy logic, but that is way we are handling differences between targets, so let it be.
I would still want to emit a call to an error reporting function though. Although I understand that is difficult to emit a good error from a GPU RT.