diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-07-22 22:29:30 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-07-22 22:29:30 +0000 |
commit | ed9abe119b3cfa2b4019782dbe10180e1e71b8cf (patch) | |
tree | 827702d3eb30e33ad0e76683d8d86d66b6048595 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | e92ae2dcd153dd73ba1c374f01f546b04502a351 (diff) | |
download | llvm-ed9abe119b3cfa2b4019782dbe10180e1e71b8cf.zip llvm-ed9abe119b3cfa2b4019782dbe10180e1e71b8cf.tar.gz llvm-ed9abe119b3cfa2b4019782dbe10180e1e71b8cf.tar.bz2 |
[ConstantFolding] Support folding loads from a GlobalAlias
The MSVC ABI requires that we generate an alias for the vtable which
means looking through a GlobalAlias which cannot be overridden improves
our ability to devirtualize.
Found while investigating PR20801.
Patch by Andrew Zhogin!
Differential Revision: http://reviews.llvm.org/D11306
llvm-svn: 242955
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index bd9439ec..70c929b 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -532,6 +532,10 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, if (GV->isConstant() && GV->hasDefinitiveInitializer()) return GV->getInitializer(); + if (auto *GA = dyn_cast<GlobalAlias>(C)) + if (GA->getAliasee() && !GA->mayBeOverridden()) + return ConstantFoldLoadFromConstPtr(GA->getAliasee(), DL); + // If the loaded value isn't a constant expr, we can't handle it. ConstantExpr *CE = dyn_cast<ConstantExpr>(C); if (!CE) |