This is an archive of the discontinued LLVM Phabricator instance.

[Attributor]Fix PR51249: Stores from memory intrinsics incorrectly being replaced by undef
AbandonedPublic

Authored by jhuber6 on Aug 5 2021, 9:26 AM.

Details

Summary

This patch fixes a bug observed in OpenMP reductions that occured when the
Attributor would attempt to simplify loads. The attributor would incorrectly
think that the memory intrinsic did not write to memory, and would then replace
the associated load with undef which would be turned to NaN in the final
output. This behaviour is observed in https://godbolt.org/z/j531848dv on line

  1. This patch fixes https://bugs.llvm.org/show_bug.cgi?id=48607.

Diff Detail

Event Timeline

jhuber6 created this revision.Aug 5 2021, 9:26 AM
jhuber6 requested review of this revision.Aug 5 2021, 9:26 AM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
ye-luo added a comment.EditedAug 5 2021, 9:34 AM

Please add a test to cover PR51249 case. Probably there are already tests for complex type but "-O3 -ffast-math" was not covered.

jhuber6 updated this revision to Diff 364538.Aug 5 2021, 10:25 AM

Adding test for bug.

Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2021, 10:25 AM
ye-luo accepted this revision.Aug 5 2021, 10:36 AM

LGTM

This revision is now accepted and ready to land.Aug 5 2021, 10:36 AM

Great! Thanks Joseph.

I think there might be an underlying problem below this one. I'm going to continue looking through it.

ye-luo added a comment.EditedAug 9 2021, 2:49 PM

I think there might be an underlying problem below this one. I'm going to continue looking through it.

Does this patch have negative impact such that you are hesitating to land it and prefer investigating the underlying problem before landing?
If not, could you please land this patch?

I think there might be an underlying problem below this one. I'm going to continue looking through it.

Does this patch have negative impact such that you are hesitating to land it and prefer investigating the underlying problem before landing?
If not, could you please land this patch?

Yes, I think this treats a secondary effect. I can land a patch that specifically ignores this case temporarily just to get it to work.

lebedev.ri requested changes to this revision.Aug 9 2021, 2:53 PM
lebedev.ri added a subscriber: lebedev.ri.

Please add an IR-level test for the attributor pass itself.

This revision now requires changes to proceed.Aug 9 2021, 2:53 PM
jdoerfert requested changes to this revision.Aug 9 2021, 8:37 PM

Categorizing this as READ is correct. The error occurs without memset as well, see D107798.

jhuber6 abandoned this revision.Aug 10 2021, 5:52 AM

Abandon in favor of D107798.