Convert linkonce* to weak* instead of strong.

Also refactor the logic into a helper function. This is an important improvement
on mingw where the linker complains about mixed weak and strong symbols.
Converting to weak ensures that the symbol is not dropped, but keeps in a
comdat, making the linker happy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195470 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-11-22 16:14:30 +00:00
parent a24e7f7d8c
commit a6c0249619
2 changed files with 43 additions and 22 deletions

View File

@@ -1,15 +1,16 @@
; RUN: llvm-extract -func foo -S < %s | FileCheck %s
; RUN: llvm-extract -delete -func foo -S < %s | FileCheck --check-prefix=DELETE %s
; Test that we don't convert weak_odr to external definitions.
; Test that linkonce definitions are mapped to weak so that they are not
; dropped.
; CHECK: @bar = external hidden global i32
; CHECK: define hidden i32* @foo() {
; CHECK: @bar = external global i32
; CHECK: define weak i32* @foo() {
; CHECK-NEXT: ret i32* @bar
; CHECK-NEXT: }
; DELETE: @bar = hidden global i32 42
; DELETE: declare hidden i32* @foo()
; DELETE: @bar = weak global i32 42
; DELETE: declare i32* @foo()
@bar = linkonce global i32 42