[PATCH] D110064: [SelectionDAG] Assume that a GlobalAlias may alias other global values

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 20 03:59:30 PDT 2021


bjope created this revision.
bjope added reviewers: courbet, niravd, efriedma.
Herald added subscribers: jeroen.dobbelaere, ecnelises, steven.zhang, hiraditya.
bjope requested review of this revision.
Herald added a project: LLVM.

This fixes a bug detected in DAGCombiner when using global alias
variables. Here is an example:

  @foo = global i16 0, align 1
  @aliasFoo = alias i16, i16 * @foo
  define i16 @bar() {
    ...
    store i16 7, i16 * @foo, align 1
    store i16 8, i16 * @aliasFoo, align 1
    ...
  }

BaseIndexOffset::computeAliasing would incorrectly derive NoAlias
for the two accesses in the example above, resulting in DAGCombiner
miscompiles.

This patch fixes the problem by a defensive approach letting
BaseIndexOffset::computeAliasing return false, i.e. that the aliasing
couldn't be determined, when comparing two global values and at least
one is a GlobalAlias. In the future we might improve this with a
deeper analysis to look at the aliasee for the GlobalAlias etc. But
that is a bit more complicated considering that we could have
'local_unnamed_addr' and situations with several 'alias' variables.

Fixes PR51878.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110064

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
  llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110064.373549.patch
Type: text/x-patch
Size: 4878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/d9690887/attachment.bin>


More information about the llvm-commits mailing list