This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare] Freeze condition when transforming select to br
ClosedPublic

Authored by aqjune on Mar 14 2020, 9:45 AM.

Details

Summary

This is a simple fix for CodeGenPrepare that freezes branch condition when transforming select to branch.
If it is not frozen, instsimplify or the later pipeline can potentially exploit undefined behavior.

The diff shows optimized form becase D75859 and D76048 already made a few changes to CodeGenPrepare for optimizing freeze(cmp).

Diff Detail

Event Timeline

aqjune created this revision.Mar 14 2020, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2020, 9:45 AM
lebedev.ri accepted this revision.Mar 14 2020, 10:56 AM

If it is not freezed, instsimplify or the later pipeline can potentially exploit undefined behavior.

Do we actually have instsimplify invocations so late, after CGP? I thought we didn't.

llvm/lib/CodeGen/CodeGenPrepare.cpp
6223

+".frozen"

This revision is now accepted and ready to land.Mar 14 2020, 10:56 AM

InstSimplify is called by CodeGenPrepare itself when visiting phis.

aqjune updated this revision to Diff 250397.Mar 14 2020, 7:09 PM

Rename suffix to .frozen

aqjune marked an inline comment as done.Mar 14 2020, 7:10 PM
This revision was automatically updated to reflect the committed changes.
aqjune edited the summary of this revision. (Show Details)Mar 15 2020, 8:47 PM