<div dir="ltr">Not sure I understand the question - but usually a compiler would, on one compilation, only compile one versoin of the code with one set of defines. <br><br>There could be invalid code (it could literally be junk - or it could be code that's only valid when the define is true/false, etc) in an unreachable ifdef, so it doesn't make sense to compile it.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 18, 2019 at 2:09 PM Alberto Barbaro via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div>I have managed to compile libpng using wllvm and obtain the IR of pngpixel ( small tool which is part of libpng ).</div><div><br></div><div>libpng has a function called png_check_IHDR:</div><div><br></div><div>void /* PRIVATE */<br>png_check_IHDR(png_const_structrp png_ptr,<br>   png_uint_32 width, png_uint_32 height, int bit_depth,<br>   int color_type, int interlace_type, int compression_type,<br>   int filter_type)<br>{<br>   int error = 0;<br><br>   /* Check for width and height valid values */<br>   if (width == 0)<br>   {<br>      png_warning(png_ptr, "Image width is zero in IHDR");<br>      error = 1;<br>   }<br>   else if (width > PNG_UINT_31_MAX)<br>   {<br>      png_warning(png_ptr, "Invalid image width in IHDR");<br>      error = 1;<br>   }<br>  <b> else<br>   {<br>#     ifdef PNG_SET_USER_LIMITS_SUPPORTED<br>      if (width > png_ptr->user_width_max)<br>#     else<br>      if (width > PNG_USER_WIDTH_MAX)<br>#     endif<br>      {<br>         png_warning(png_ptr, "Image width exceeds user limit in IHDR");<br>         error = 1;<br>      }<br>   }</b></div><div>...</div><div>}</div><div><br></div><div>Unfortunately the relative IR does not seem to have the branch highlighted in bold:</div><div><br></div><div>; Function Attrs: nounwind uwtable<br>define void @png_check_IHDR(%struct.png_struct_def* noalias %png_ptr, i32 %width, i32 %height, i32 %bit_depth, i32 %color_type, i32 %interlace_type, i32 %compression_type, i32 %filter_type) #5 {<br>  <b>%1 = icmp eq i32 %width, 0</b><br>  br i1 %1, label %.thread, label %2<br><br>.thread:                                          ; preds = %0<br>  tail call void @png_warning(%struct.png_struct_def* %png_ptr, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str50, i64 0, i64 0)) #15<br>  br label %5<br><br>; <label>:2:                                      ; preds = %0<br>  <b>%3 = icmp slt i32 %width, 0</b><br>  br i1 %3, label %4, label %5<br><br>; <label>:4:                                      ; preds = %2<br>  tail call void @png_warning(%struct.png_struct_def* %png_ptr, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str51, i64 0, i64 0)) #15<br>  br label %5<br><br>; <label>:5:                                      ; preds = %4, %2, %.thread<br>  %error.1 = phi i32 [ 1, %4 ], [ 0, %2 ], [ 1, %.thread ]<br>  %6 = getelementptr inbounds %struct.png_struct_def, %struct.png_struct_def* %png_ptr, i64 0, i32 132<br>  %7 = load i32, i32* %6, align 4, !tbaa !22<br>  <b>%8 = icmp ult i32 %7, %width ; if (width > PNG_UINT_31_MAX)</b><br>  br i1 %8, label %9, label %10<br><br>; <label>:9:                                      ; preds = %5<br>  tail call void @png_warning(%struct.png_struct_def* %png_ptr, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str53, i64 0, i64 0)) #15<br>  br label %10<br><br>; <label>:10:                                     ; preds = %9, %5<br>  %error.3 = phi i32 [ 1, %9 ], [ %error.1, %5 ]<br>  <b>%11 = icmp eq i32 %height, 0 ; first check on the height</b><br>  br i1 %11, label %.thread27, label %12</div><div><br></div><div>Does anybody know why the else branch is completely missing?</div><div><br></div><div>Thanks,</div><div>Alberto<br></div><div><br></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>