[LLVMbugs] [Bug 14235] New: Linking modules in different order produces different results

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 1 11:45:10 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14235

             Bug #: 14235
           Summary: Linking modules in different order produces different
                    results
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Linker
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: xiao_yi_guo at yahoo.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Given three modules:
-----------------------------------------------------------------
s1.ll:

%0 = type <{ i32, i32 }>

define void @s1(%0* byval %myStruct) nounwind {
return:
  ret void
}
-----------------------------------------------------------------
s2.ll:

%0 = type <{ i32, i32 }>

define void @s2(%0* byval %myStruct) nounwind {
return:
  ret void
}
-----------------------------------------------------------------
s3.ll:
%0 = type <{ i32, i32 }>

declare void @s1(%0* byval) nounwind readonly declare void @s2(%0* byval)
nounwind readonly

define  void @s3(%0* byval %myStruct) nounwind {
    call void @s1(%0* %myStruct) nounwind
    call void @s2(%0* %myStruct) nounwind
    ret void
}
-----------------------------------------------------------------
If they are linked in one order:
$ llvm-link -o s.bc s1.ll s2.ll s3.ll
The linked IR is:

%0 = type <{ i32, i32 }>
%1 = type <{ i32, i32 }>

define  void @s1(%0* byval %myStruct) nounwind {
return:
  ret void
}

define  void @s2(%1* byval %myStruct) nounwind {
return:
  ret void
}

define  void @s3(%0* byval %myStruct) nounwind {
  call  void @s1(%0* %myStruct) nounwind
  call  void bitcast (void (%1*)* @s2 to void (%0*)*)(%0* %myStruct) nounwind
  ret void
}

-----------------------------------------------------------------
If they are linked in a different order:
$ llvm-link -o s.bc s3.ll s1.ll s2.ll
The linked IR is:

%0 = type <{ i32, i32 }>

define  void @s3(%0* byval %myStruct) nounwind {
  call  void @s1(%0* %myStruct) nounwind
  call  void @s2(%0* %myStruct) nounwind
  ret void
}

define  void @s1(%0* byval %myStruct) nounwind {
return:
  ret void
}

define  void @s2(%0* byval %myStruct) nounwind {
return:
  ret void
}

-----------------------------------------------------------------
The second linked IR should be generated regardless of the order the modules
are linked in.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list