Hi, Is this correct behaviour? test.ll: declare {} @__ex__print_int(i64) define i32 @main() { entry: %0 = call i64 @f.1() %1 = call {} @__ex__print_int(i64 %0) ret i32 0 } define internal fastcc i64 @f.1() { entry: ret i64 7 }> opt -std-compile-opts test.ll -S; ModuleID = 'test.ll' define i32 @main() noreturn nounwind { entry: tail call void @llvm.trap() unreachable } declare void @llvm.trap() nounwind If I remove fastcc then everything works as expected. Does this mean that one shouldn't use opt when you use fastcc functions (which are required when implementing tail recursive languages!)? Thanks! N
On Wed, Apr 6, 2011 at 10:48 PM, Nicolas Ojeda Bar <nojb at math.harvard.edu> wrote:> Hi, > > Is this correct behaviour? > > test.ll: > > declare {} @__ex__print_int(i64) > > define i32 @main() { > entry: > %0 = call i64 @f.1() > %1 = call {} @__ex__print_int(i64 %0) > ret i32 0 > } > > define internal fastcc i64 @f.1() { > entry: > ret i64 7 > } > >> opt -std-compile-opts test.ll -S > > ; ModuleID = 'test.ll' > > define i32 @main() noreturn nounwind { > entry: > tail call void @llvm.trap() > unreachable > } > > declare void @llvm.trap() nounwind > > If I remove fastcc then everything works as expected. > Does this mean that one shouldn't use opt when you > use fastcc functions (which are required when implementing > tail recursive languages!)?Try "%0 = call fastcc i64 @f.1()"; the conventions of the call and the callee are required to match. -Eli
See http://llvm.org/docs/FAQ.html#callconvwrong if you're wondering why LLVM can't just take the calling convention from the definition/declaration. Reid On Thu, Apr 7, 2011 at 1:56 AM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Wed, Apr 6, 2011 at 10:48 PM, Nicolas Ojeda Bar > <nojb at math.harvard.edu> wrote: >> Hi, >> >> Is this correct behaviour? >> >> test.ll: >> >> declare {} @__ex__print_int(i64) >> >> define i32 @main() { >> entry: >> %0 = call i64 @f.1() >> %1 = call {} @__ex__print_int(i64 %0) >> ret i32 0 >> } >> >> define internal fastcc i64 @f.1() { >> entry: >> ret i64 7 >> } >> >>> opt -std-compile-opts test.ll -S >> >> ; ModuleID = 'test.ll' >> >> define i32 @main() noreturn nounwind { >> entry: >> tail call void @llvm.trap() >> unreachable >> } >> >> declare void @llvm.trap() nounwind >> >> If I remove fastcc then everything works as expected. >> Does this mean that one shouldn't use opt when you >> use fastcc functions (which are required when implementing >> tail recursive languages!)? > > Try "%0 = call fastcc i64 @f.1()"; the conventions of the call and the > callee are required to match. > > -Eli > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >