This is an archive of the discontinued LLVM Phabricator instance.

Fix the assert in Annotate the loop in SIAnnotateControlFlow pass when the loop terminator condition is a constant.
ClosedPublic

Authored by cfang on Nov 30 2015, 2:22 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

cfang updated this revision to Diff 41431.Nov 30 2015, 2:22 PM
cfang retitled this revision from to Fix the assert in Annotate the loop in SIAnnotateControlFlow pass when the loop terminator condition is a constant..
cfang updated this object.
arsenm edited edge metadata.Nov 30 2015, 2:25 PM
arsenm added a subscriber: llvm-commits.

The test is missing check lines, so FileCheck will error on it

test/CodeGen/AMDGPU/si-annotate-cfg-loop-assert.ll
1–2 ↗(On Diff #41431)

Isn't this fixing the test? Why is this xfailed?

6–7 ↗(On Diff #41431)

These should be removed

11 ↗(On Diff #41431)

Remove the align 2

15 ↗(On Diff #41431)

Can you run opt -strip -instnamer on this test?

cfang updated this revision to Diff 41444.Nov 30 2015, 3:20 PM

Updated based on Matt's comments.

cfang updated this revision to Diff 41447.Nov 30 2015, 3:33 PM

indeed update the LIT test based on Matt's comment.

tstellarAMD added inline comments.Dec 1 2015, 8:59 AM
lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
276–278 ↗(On Diff #41447)

Usually getting a branch on constant in the SIAnnotateControlFlow means that there is a bug in the StructurizeCFG pass.
There is no harm in handling this here, but I think it may just be covering over a bug in the structurizer pass.

cfang added inline comments.Dec 1 2015, 9:15 AM
lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
276–278 ↗(On Diff #41447)

Why do you think there is a bug in the structurizer? My understanding is that, for an infinite loop or a one-trip (do-while) loop, the condition can be a constant, even though we may be able to optimize away the loop for the later case.

cfang updated this revision to Diff 41528.Dec 1 2015, 9:39 AM

Add CHECKS

tstellarAMD added inline comments.Dec 1 2015, 2:30 PM
lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
276–278 ↗(On Diff #41528)

This kind of failure is a common symptom of strurcturizer bugs. You should run llc with -print-before-all to see if the constant branch exists before the structurizer is run.

cfang added a comment.Feb 11 2016, 2:24 PM

Any further comment?

lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
276–278 ↗(On Diff #41528)

It is true that the structrizer has a bug generating wrong constant condition. However, in a general sense, nothing prevents
the condition from being constant. And as a result, we should handle constant condition in annotating loops.

arsenm accepted this revision.Feb 11 2016, 5:15 PM
arsenm added a reviewer: arsenm.

LGTM

This revision is now accepted and ready to land.Feb 11 2016, 5:15 PM
This revision was automatically updated to reflect the committed changes.