[llvm] r322378 - Allow dso_local on ifunc.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 12 09:03:43 PST 2018
Author: rafael
Date: Fri Jan 12 09:03:43 2018
New Revision: 322378
URL: http://llvm.org/viewvc/llvm-project?rev=322378&view=rev
Log:
Allow dso_local on ifunc.
It was never fully disallowed. We were rejecting it in the asm parser,
but not in the verifier.
Currently TargetMachine::shouldAssumeDSOLocal returns true for hidden
ifuncs. I considered changing it and moving the check from the asm
parser to the verifier.
The reason for deciding to allow it instead is that all linkers handle
a direct reference just fine. They use the plt address as the address
of the function. In fact doing that means that clang doesn't have the
same bug as gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83782.
This patch then removes the check from the asm parser and updates the
bitcode reader and writer.
Added:
llvm/trunk/test/Assembler/ifunc-dsolocal.ll
- copied, changed from r322375, llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll
Removed:
llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll
Modified:
llvm/trunk/include/llvm/IR/GlobalValue.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=322378&r1=322377&r2=322378&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Fri Jan 12 09:03:43 2018
@@ -437,8 +437,7 @@ public:
void setLinkage(LinkageTypes LT) {
if (isLocalLinkage(LT)) {
Visibility = DefaultVisibility;
- if (getValueID() != Value::GlobalIFuncVal)
- setDSOLocal(true);
+ setDSOLocal(true);
}
Linkage = LT;
}
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=322378&r1=322377&r2=322378&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Jan 12 09:03:43 2018
@@ -756,11 +756,6 @@ bool LLParser::parseIndirectSymbol(const
return Error(NameLoc,
"symbol with local linkage must have default visibility");
- if (DSOLocal && !IsAlias) {
- return Error(NameLoc,
- "dso_local is invalid on ifunc");
- }
-
Type *Ty;
LocTy ExplicitTypeLoc = Lex.getLoc();
if (ParseType(Ty) ||
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=322378&r1=322377&r2=322378&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Jan 12 09:03:43 2018
@@ -3054,14 +3054,17 @@ Error BitcodeReader::parseGlobalIndirect
// FIXME: Change to an error if non-default in 4.0.
NewGA->setVisibility(getDecodedVisibility(Record[VisInd]));
}
- if (OpNum != Record.size())
- NewGA->setDLLStorageClass(getDecodedDLLStorageClass(Record[OpNum++]));
- else
- upgradeDLLImportExportLinkage(NewGA, Linkage);
- if (OpNum != Record.size())
- NewGA->setThreadLocalMode(getDecodedThreadLocalMode(Record[OpNum++]));
- if (OpNum != Record.size())
- NewGA->setUnnamedAddr(getDecodedUnnamedAddrType(Record[OpNum++]));
+ if (BitCode == bitc::MODULE_CODE_ALIAS ||
+ BitCode == bitc::MODULE_CODE_ALIAS_OLD) {
+ if (OpNum != Record.size())
+ NewGA->setDLLStorageClass(getDecodedDLLStorageClass(Record[OpNum++]));
+ else
+ upgradeDLLImportExportLinkage(NewGA, Linkage);
+ if (OpNum != Record.size())
+ NewGA->setThreadLocalMode(getDecodedThreadLocalMode(Record[OpNum++]));
+ if (OpNum != Record.size())
+ NewGA->setUnnamedAddr(getDecodedUnnamedAddrType(Record[OpNum++]));
+ }
if (OpNum != Record.size())
NewGA->setDSOLocal(getDecodedDSOLocal(Record[OpNum++]));
ValueList.push_back(NewGA);
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=322378&r1=322377&r2=322378&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Fri Jan 12 09:03:43 2018
@@ -1302,7 +1302,7 @@ void ModuleBitcodeWriter::writeModuleInf
// Emit the ifunc information.
for (const GlobalIFunc &I : M.ifuncs()) {
// IFUNC: [strtab offset, strtab size, ifunc type, address space, resolver
- // val#, linkage, visibility]
+ // val#, linkage, visibility, DSO_Local]
Vals.push_back(addToStrtab(I.getName()));
Vals.push_back(I.getName().size());
Vals.push_back(VE.getTypeID(I.getValueType()));
@@ -1310,6 +1310,7 @@ void ModuleBitcodeWriter::writeModuleInf
Vals.push_back(VE.getValueID(I.getResolver()));
Vals.push_back(getEncodedLinkage(I));
Vals.push_back(getEncodedVisibility(I));
+ Vals.push_back(I.isDSOLocal());
Stream.EmitRecord(bitc::MODULE_CODE_IFUNC, Vals);
Vals.clear();
}
Removed: llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll?rev=322377&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll (original)
+++ llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll (removed)
@@ -1,9 +0,0 @@
-; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
-
- at foo = dso_local ifunc i32 (i32), i64 ()* @foo_ifunc
-; CHECK: error: dso_local is invalid on ifunc
-
-define internal i64 @foo_ifunc() {
-entry:
- ret i64 0
-}
Copied: llvm/trunk/test/Assembler/ifunc-dsolocal.ll (from r322375, llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/ifunc-dsolocal.ll?p2=llvm/trunk/test/Assembler/ifunc-dsolocal.ll&p1=llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll&r1=322375&r2=322378&rev=322378&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/ifunc-dsolocal-daig.ll (original)
+++ llvm/trunk/test/Assembler/ifunc-dsolocal.ll Fri Jan 12 09:03:43 2018
@@ -1,7 +1,7 @@
-; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
@foo = dso_local ifunc i32 (i32), i64 ()* @foo_ifunc
-; CHECK: error: dso_local is invalid on ifunc
+; CHECK: @foo = dso_local ifunc i32 (i32), i64 ()* @foo_ifunc
define internal i64 @foo_ifunc() {
entry:
More information about the llvm-commits
mailing list