[PATCH] D49039: [BitcodeReader] Infer the correct runtime preemption for GlobalValue

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 6 13:36:25 PDT 2018


steven_wu created this revision.
steven_wu added reviewers: sfertile, vsk.
Herald added a subscriber: dexonsmith.

To allow bitcode built by old compiler to pass the current verifer,
BitcodeReader needs to auto infer the correct runtime preemption from
linkage and visibility for GlobalValues.

Since llvm-6.0 bitcode already contains the new field but can be
incorrect in some cases, the attribute needs to be recomputed all the
time in BitcodeReader. This will make all the GVs has dso_local marked
correctly if read from bitcode, and it should still allow the verifier
to catch mistakes in optimization passes.

This should fix PR38009.


Repository:
  rL LLVM

https://reviews.llvm.org/D49039

Files:
  lib/Bitcode/Reader/BitcodeReader.cpp


Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2924,6 +2924,11 @@
     NewGV->setDSOLocal(getDecodedDSOLocal(Record[13]));
   }
 
+  if (NewGV->hasLocalLinkage() ||
+      (!NewGV->hasDefaultVisibility() && !NewGV->hasExternalWeakLinkage())) {
+    NewGV->setDSOLocal(true);
+  }
+
   return Error::success();
 }
 
@@ -3008,6 +3013,12 @@
     Func->setDSOLocal(getDecodedDSOLocal(Record[15]));
   }
 
+  if (Func->hasLocalLinkage() ||
+      (!Func->hasDefaultVisibility() && !Func->hasExternalWeakLinkage())) {
+    // infer dso_local from linkage and visibility if it is not encoded.
+    Func->setDSOLocal(true);
+  }
+
   ValueList.push_back(Func);
 
   // If this is a function with a body, remember the prototype we are
@@ -3083,6 +3094,10 @@
   }
   if (OpNum != Record.size())
     NewGA->setDSOLocal(getDecodedDSOLocal(Record[OpNum++]));
+
+  if (NewGA->hasLocalLinkage() ||
+      (!NewGA->hasDefaultVisibility() && !NewGA->hasExternalWeakLinkage()))
+    NewGA->setDSOLocal(true);
   ValueList.push_back(NewGA);
   IndirectSymbolInits.push_back(std::make_pair(NewGA, Val));
   return Error::success();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49039.154449.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180706/d99b9502/attachment.bin>


More information about the llvm-commits mailing list