[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 19:20:49 PDT 2018
steven_wu updated this revision to Diff 154480.
steven_wu added a comment.
Add testcase using 6.0 bitcode.
Repository:
rL LLVM
https://reviews.llvm.org/D49039
Files:
lib/Bitcode/Reader/BitcodeReader.cpp
test/Bitcode/Inputs/infer_dso_local.bc
test/Bitcode/infer_dso_local.ll
Index: test/Bitcode/infer_dso_local.ll
===================================================================
--- /dev/null
+++ test/Bitcode/infer_dso_local.ll
@@ -0,0 +1,3 @@
+; RUN: opt -verify %S/Inputs/infer_dso_local.bc | llvm-dis | FileCheck %s
+
+; CHECK: define linkonce_odr hidden void @test()
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2831,6 +2831,13 @@
return Error::success();
}
+static void inferDSOLocal(GlobalValue *GV) {
+ // infer dso_local from linkage and visibility if it is not encoded.
+ if (GV->hasLocalLinkage() ||
+ (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage()))
+ GV->setDSOLocal(true);
+}
+
Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
// v1: [pointer type, isconst, initid, linkage, alignment, section,
// visibility, threadlocal, unnamed_addr, externally_initialized,
@@ -2923,6 +2930,7 @@
if (Record.size() > 13) {
NewGV->setDSOLocal(getDecodedDSOLocal(Record[13]));
}
+ inferDSOLocal(NewGV);
return Error::success();
}
@@ -3007,6 +3015,7 @@
if (Record.size() > 15) {
Func->setDSOLocal(getDecodedDSOLocal(Record[15]));
}
+ inferDSOLocal(Func);
ValueList.push_back(Func);
@@ -3083,6 +3092,8 @@
}
if (OpNum != Record.size())
NewGA->setDSOLocal(getDecodedDSOLocal(Record[OpNum++]));
+ inferDSOLocal(NewGA);
+
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.154480.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180707/84ce5b9c/attachment.bin>
More information about the llvm-commits
mailing list