[PATCH] D79314: PR45733 : global weak symbol are excluded from the optimization .

Umesh Kalappa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 02:38:54 PDT 2020


umesh.kalappa0 updated this revision to Diff 263127.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79314/new/

https://reviews.llvm.org/D79314

Files:
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Transforms/Scalar/SCCP.cpp


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SCCP.cpp
+++ llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -201,7 +201,7 @@
   /// performing Interprocedural SCCP.
   void TrackValueOfGlobalVariable(GlobalVariable *GV) {
     // We only track the contents of scalar globals.
-    if (GV->getValueType()->isSingleValueType()) {
+    if (GV->getValueType()->isSingleValueType() && !GV->hasWeakLinkage()) {
       ValueLatticeElement &IV = TrackedGlobals[GV];
       if (!isa<UndefValue>(GV->getInitializer()))
         IV.markConstant(GV->getInitializer());
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -636,7 +636,7 @@
                                              const DataLayout &DL) {
   // First, try the easy cases:
   if (auto *GV = dyn_cast<GlobalVariable>(C))
-    if (GV->isConstant() && GV->hasDefinitiveInitializer())
+    if (GV->isConstant() && GV->hasDefinitiveInitializer() && !GV->hasWeakLinkage())
       return GV->getInitializer();
 
   if (auto *GA = dyn_cast<GlobalAlias>(C))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79314.263127.patch
Type: text/x-patch
Size: 1239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200511/7a3cc0d1/attachment.bin>


More information about the llvm-commits mailing list