Remove the `nosync` attribute from the memory intrinsic definitions (i.e. memset, memcpy, memmove). Like native memory accesses, memory intrinsics can be volatile. This is indicated by an immarg in the intrinsic call. All else equal, a volatile memory intrinsic is `sync`, so we cannot annotate the intrinsic functions themselves as `nosync`. The attributor and function-attr passes know to take the volatile bit into account. Since `nosync` is a default attribute, this means we have to stop using the DefaultAttrIntrinsic tablegen class for memory intrinsics, and specify all default attributes other than `nosync` explicitly. Most of the test changes are trivial churn, but one test case (in nosync.ll) was in fact incorrect before this change.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Fired too quickly, the Attributor actually had a bug and an incorrect lit test. This version should fix that.
llvm/lib/Transforms/IPO/AttributorAttributes.cpp | ||
---|---|---|
1337 | This doesn't make sense to me now. I think I figured out my problem (below) but I wanted to keep my reasoning:
| |
llvm/test/Transforms/Attributor/nosync.ll | ||
419 | FWIW, this looks like a bug to me too. |
llvm/lib/Transforms/IPO/FunctionAttrs.cpp | ||
---|---|---|
1519 | This removal breaks our ability to infer nosync on a non-volatile memset, exactly as the comment describes. There should be a test for this, if there isn't, let me know and I'll add one. |
llvm/lib/Transforms/IPO/FunctionAttrs.cpp | ||
---|---|---|
1519 | I think what happened is: MemXXX was not marked nosync before, we had to derive it explicitly. To be correct, we checked for the volatile flag. Here and in the Attributor code above. |
Invert the logic of the patch: mem intrinsics shouldn't be unconditionally marked nosync in the first place.
clang-format not found in user's PATH; not linting file.