mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 20:29:53 +00:00
Revert "Convert linkonce* to weak* instead of strong."
This reverts commit r195470. Debugging failure in some bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195472 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0f778794c8
commit
4be5f33f65
@ -21,38 +21,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
/// Make sure GV is visible from both modules. Delete is true if it is
|
|
||||||
/// being deleted from this module.
|
|
||||||
/// This also makes sure GV cannot be dropped so that references from
|
|
||||||
/// the split module remain valid.
|
|
||||||
static void makeVisible(GlobalValue &GV, bool Delete) {
|
|
||||||
bool Local = GV.hasLocalLinkage();
|
|
||||||
if (Local)
|
|
||||||
GV.setVisibility(GlobalValue::HiddenVisibility);
|
|
||||||
|
|
||||||
if (Local || Delete) {
|
|
||||||
GV.setLinkage(GlobalValue::ExternalLinkage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GV.hasLinkOnceLinkage()) {
|
|
||||||
assert(!GV.isDiscardableIfUnused());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map linkonce* to weak* so that llvm doesn't drop this GV.
|
|
||||||
switch(GV.getLinkage()) {
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unexpected linkage");
|
|
||||||
case GlobalValue::LinkOnceAnyLinkage:
|
|
||||||
GV.setLinkage(GlobalValue::WeakAnyLinkage);
|
|
||||||
return;
|
|
||||||
case GlobalValue::LinkOnceODRLinkage:
|
|
||||||
GV.setLinkage(GlobalValue::WeakODRLinkage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
/// @brief A pass to extract specific functions and their dependencies.
|
/// @brief A pass to extract specific functions and their dependencies.
|
||||||
class GVExtractorPass : public ModulePass {
|
class GVExtractorPass : public ModulePass {
|
||||||
@ -92,7 +60,12 @@ namespace {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeVisible(*I, Delete);
|
bool Local = I->isDiscardableIfUnused();
|
||||||
|
if (Local)
|
||||||
|
I->setVisibility(GlobalValue::HiddenVisibility);
|
||||||
|
|
||||||
|
if (Local || Delete)
|
||||||
|
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
|
|
||||||
if (Delete)
|
if (Delete)
|
||||||
I->setInitializer(0);
|
I->setInitializer(0);
|
||||||
@ -107,7 +80,12 @@ namespace {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeVisible(*I, Delete);
|
bool Local = I->isDiscardableIfUnused();
|
||||||
|
if (Local)
|
||||||
|
I->setVisibility(GlobalValue::HiddenVisibility);
|
||||||
|
|
||||||
|
if (Local || Delete)
|
||||||
|
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
|
|
||||||
if (Delete)
|
if (Delete)
|
||||||
I->deleteBody();
|
I->deleteBody();
|
||||||
@ -119,10 +97,12 @@ namespace {
|
|||||||
Module::alias_iterator CurI = I;
|
Module::alias_iterator CurI = I;
|
||||||
++I;
|
++I;
|
||||||
|
|
||||||
bool Delete = deleteStuff == (bool)Named.count(CurI);
|
if (CurI->isDiscardableIfUnused()) {
|
||||||
makeVisible(*I, Delete);
|
CurI->setVisibility(GlobalValue::HiddenVisibility);
|
||||||
|
CurI->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
|
}
|
||||||
|
|
||||||
if (Delete) {
|
if (deleteStuff == (bool)Named.count(CurI)) {
|
||||||
Type *Ty = CurI->getType()->getElementType();
|
Type *Ty = CurI->getType()->getElementType();
|
||||||
|
|
||||||
CurI->removeFromParent();
|
CurI->removeFromParent();
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
; RUN: llvm-extract -func foo -S < %s | FileCheck %s
|
; RUN: llvm-extract -func foo -S < %s | FileCheck %s
|
||||||
; RUN: llvm-extract -delete -func foo -S < %s | FileCheck --check-prefix=DELETE %s
|
; RUN: llvm-extract -delete -func foo -S < %s | FileCheck --check-prefix=DELETE %s
|
||||||
|
|
||||||
; Test that linkonce definitions are mapped to weak so that they are not
|
; Test that we don't convert weak_odr to external definitions.
|
||||||
; dropped.
|
|
||||||
|
|
||||||
; CHECK: @bar = external global i32
|
; CHECK: @bar = external hidden global i32
|
||||||
; CHECK: define weak i32* @foo() {
|
; CHECK: define hidden i32* @foo() {
|
||||||
; CHECK-NEXT: ret i32* @bar
|
; CHECK-NEXT: ret i32* @bar
|
||||||
; CHECK-NEXT: }
|
; CHECK-NEXT: }
|
||||||
|
|
||||||
; DELETE: @bar = weak global i32 42
|
; DELETE: @bar = hidden global i32 42
|
||||||
; DELETE: declare i32* @foo()
|
; DELETE: declare hidden i32* @foo()
|
||||||
|
|
||||||
@bar = linkonce global i32 42
|
@bar = linkonce global i32 42
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user