[PATCH] D37463: Fix miscompile in LoopSink pass

Dehao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 5 09:20:19 PDT 2017


danielcdh added a comment.

Thanks for raising the issue.

But I'm not sure if this the right fix

- this disables sinking of all load instructions unless it's a constant load, or has invariant load metadata
- not sure why SafetyInfo would help identify the potential data race here

Additionally, about the original testcase, the data race is there even without loopsink optimization as the load outside of the loop is not guarded by any locks. I'm not a C++ standard expert and am not sure if data race like this is considered as undefined behavior (if yes, then it's legal for compiler to sink the load down to the loop to break the "everything in a[] should be the same" assumption)

Put it another way, is it legal to hoist the load for the following load with potential racy condition?

for (i = 0; i < N; ++i)

  a[i] = *p;


Repository:
  rL LLVM

https://reviews.llvm.org/D37463





More information about the llvm-commits mailing list