[llvm] r219184 - gold plugin: create internal replacement with original linkage first.
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 6 20:19:55 PDT 2014
Author: rafael
Date: Mon Oct 6 22:19:55 2014
New Revision: 219184
URL: http://llvm.org/viewvc/llvm-project?rev=219184&view=rev
Log:
gold plugin: create internal replacement with original linkage first.
The call to copyAttributesFrom will copy the visibility, which might assert
if it were to produce something invalid like "internal hidden". We avoid it
by first creating the replacement with the original linkage and then setting
it to internal affter the call to copyAttributesFrom.
Modified:
llvm/trunk/test/tools/gold/Inputs/comdat.ll
llvm/trunk/test/tools/gold/comdat.ll
llvm/trunk/tools/gold/gold-plugin.cpp
Modified: llvm/trunk/test/tools/gold/Inputs/comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/Inputs/comdat.ll?rev=219184&r1=219183&r2=219184&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/Inputs/comdat.ll (original)
+++ llvm/trunk/test/tools/gold/Inputs/comdat.ll Mon Oct 6 22:19:55 2014
@@ -1,7 +1,7 @@
$c2 = comdat any
@v1 = weak_odr global i32 41, comdat $c2
-define weak_odr i32 @f1(i8* %this) comdat $c2 {
+define weak_odr protected i32 @f1(i8* %this) comdat $c2 {
bb20:
store i8* %this, i8** null
br label %bb21
Modified: llvm/trunk/test/tools/gold/comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/comdat.ll?rev=219184&r1=219183&r2=219184&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/comdat.ll (original)
+++ llvm/trunk/test/tools/gold/comdat.ll Mon Oct 6 22:19:55 2014
@@ -49,7 +49,7 @@ bb11:
; CHECK: @a23 = alias i32 (i8*)* @f12{{$}}
; CHECK: @a24 = alias bitcast (i32 (i8*)* @f12 to i16*)
-; CHECK: define weak_odr i32 @f1(i8*) comdat $c1 {
+; CHECK: define weak_odr protected i32 @f1(i8*) comdat $c1 {
; CHECK-NEXT: bb10:
; CHECK-NEXT: br label %bb11{{$}}
; CHECK: bb11:
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=219184&r1=219183&r2=219184&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Mon Oct 6 22:19:55 2014
@@ -491,8 +491,8 @@ static GlobalObject *makeInternalReplace
Module *M = GO->getParent();
GlobalObject *Ret;
if (auto *F = dyn_cast<Function>(GO)) {
- auto *NewF = Function::Create(
- F->getFunctionType(), GlobalValue::InternalLinkage, F->getName(), M);
+ auto *NewF = Function::Create(F->getFunctionType(), F->getLinkage(),
+ F->getName(), M);
ValueToValueMapTy VM;
Function::arg_iterator NewI = NewF->arg_begin();
@@ -514,12 +514,13 @@ static GlobalObject *makeInternalReplace
auto *Var = cast<GlobalVariable>(GO);
Ret = new GlobalVariable(
*M, Var->getType()->getElementType(), Var->isConstant(),
- GlobalValue::InternalLinkage, Var->getInitializer(), Var->getName(),
+ Var->getLinkage(), Var->getInitializer(), Var->getName(),
nullptr, Var->getThreadLocalMode(), Var->getType()->getAddressSpace(),
Var->isExternallyInitialized());
Var->setInitializer(nullptr);
}
Ret->copyAttributesFrom(GO);
+ Ret->setLinkage(GlobalValue::InternalLinkage);
Ret->setComdat(GO->getComdat());
return Ret;
More information about the llvm-commits
mailing list