Hello If I optimize (opt -std-compile-opts ) the following .ll ; ModuleID = 'call0.ll' target datalayout "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" target triple = "i386-mingw32" define i32 @t(i32 %a) nounwind { entry: %0 = tail call i32 inttoptr (i32 0 to i32 (i32)*)(i32 %a) nounwind ; <i32> [#uses=1] ret i32 %0 } The call to address 0 gets removed. define i32 @t(i32 %a) noreturn nounwind readnone { entry: unreachable } How can I prevent that the call is removed, without making the function addr volatile? Does anyone know which optimization removes it? Thanks, Marius Wachtler -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090609/14641775/attachment.html>
On Jun 8, 2009, at 4:48 PMPDT, Marius Wachtler wrote:> Hello > > If I optimize (opt -std-compile-opts ) the following .ll > > ; ModuleID = 'call0.ll' > target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64- > f80:32:32" > target triple = "i386-mingw32" > > define i32 @t(i32 %a) nounwind { > entry: > %0 = tail call i32 inttoptr (i32 0 to i32 (i32)*)(i32 %a) > nounwind ; <i32> [#uses=1] > ret i32 %0 > } > > The call to address 0 gets removed. > > define i32 @t(i32 %a) noreturn nounwind readnone { > entry: > unreachable > } > > How can I prevent that the call is removed, without making the > function addr volatile? > Does anyone know which optimization removes it?Calling 0 is undefined behavior; the optimizer is within its rights to remove this. Why do you want to call 0?
> Calling 0 is undefined behavior; the optimizer is within its rights to > remove this. Why do you want to call 0?For example, on embedded platforms you call 0 to do a soft reset.> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev