This is an archive of the discontinued LLVM Phabricator instance.

[GVN] Bug fix to reportMayClobberedLoad remark
ClosedPublic

Authored by virnarula on Jul 6 2022, 3:48 PM.

Details

Summary

Bug fix to avoid assert crashing when generating remarks for GVN crashing.

Intention of assert is correct but ignores edge case of instructions being equivalent.

Reduced input that causes crash when remarks are turned on:

target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx12.0.0"

define ptr @ReplaceWithTidy(ptr %zz_hold) {
cond.end480.us:
  %0 = load ptr, ptr null, align 8
  store ptr %0, ptr %0, align 8
  store ptr null, ptr %zz_hold, align 8
  %1 = load ptr, ptr %0, align 8
  store ptr %1, ptr null, align 8
  ret ptr null
}

Diff Detail

Event Timeline

virnarula created this revision.Jul 6 2022, 3:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2022, 3:48 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
virnarula requested review of this revision.Jul 6 2022, 3:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2022, 3:48 PM
virnarula retitled this revision from [GVN] Add bug fix to reportMayClobberedLoad remark to [GVN] Bug fix to reportMayClobberedLoad remark.Jul 6 2022, 3:53 PM
virnarula edited the summary of this revision. (Show Details)
virnarula added reviewers: fhahn, anemet, thegameg.
fhahn added a comment.Jul 6 2022, 3:55 PM

Could please include the test case in the patch?

virnarula updated this revision to Diff 442716.Jul 6 2022, 4:29 PM

Add testing

fhahn added a comment.Jul 6 2022, 4:34 PM

Thanks for the update! It looks like the changes in GVN.cpp got dropped though

llvm/test/Transforms/GVN/remarks-selfdomination.ll
5

this is not needed

17

Could you updatee the name here to entry or something similar?

18

load from null is UB in LLVM IR. Could you instead add a ptr argument to the function and use it instead of null? Same for the store. It might be good to simplify the name of zz_hold as well.

virnarula updated this revision to Diff 442717.EditedJul 6 2022, 4:38 PM

Add test to patch

virnarula updated this revision to Diff 442727.Jul 6 2022, 5:11 PM

update test variable names

fhahn accepted this revision.Jul 6 2022, 5:13 PM

LGTM, thanks for the fix!

This revision is now accepted and ready to land.Jul 6 2022, 5:13 PM
This revision was landed with ongoing or failed builds.Jul 6 2022, 5:42 PM
This revision was automatically updated to reflect the committed changes.