[LLVMdev] llvm linking issue
Guo, Xiaoyi
Xiaoyi.Guo at amd.com
Wed Oct 31 20:35:49 PDT 2012
I have 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
}
Shouldn't the second linked IR be generated regardless of the order the modules are linked in?
Thanks,
Xiaoyi
More information about the llvm-dev
mailing list