[SYCL] Always store last event (for ioq) if scheduler was not bypassed
This fixes an issue for cases where the kernel depends on events coming from the scheduler (host task events or unenqueued commands). The logic in submit_impl for calculating noLastEventPath did not take into account all dependencies which could result in skipping storing last even if handler.finalize() ended up submitting work to the scheduler.
I also restored the lock on the submit path. It is needed to store the last event in case handler.finalize() returns an event coming from the scheduler.
This looks like it has unintended changes to image.cpp in UR?
@intel/llvm-gatekeepers this is ready to be merge. The failure is related to https://github.com/intel/llvm/issues/18932 and wrong exclusion check in lit.local.cfg - fix is here: https://github.com/intel/llvm/pull/19061