<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><div>hi,</div><div>  I compile a case (test.c) to get IR file (test.ll) using clang as follows:</div><div>  "clang -emit-llvm -S -O2 test.c -o test.ll"</div><div>My clang source code version is release 3.3 and debugging build.</div><div>  //test.c</div><div>  int foo(int j) {</div><div>    return ++j > 0;</div><div>  }</div><div>  int main() {</div><div>    if (foo(((~0U)>>1)))</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>  abort();</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>exit(0)</div><div>  }</div><div>  //end test.c</div><div><br></div><div>  Here are the generated IR file:</div><div>  //test.ll</div><div>  ; Function Attrs: noreturn nounwind uwtable</div><div>  define i32 @main #1 {</div><div>  if.then:</div><div>    tail call void @abort() #3</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>unreachable</div><div>  }</div><div>  //end test.ll</div><div>  </div><div>  As we can see from test.ll, foo function is optimized out by clang.</div><div>  And then call abort function directly.</div><div>    </div><div>  However, the real is that this test never executes abort function.</div><div>  So, I debug source code of clang.</div><div>  In the 3167 line of ExprConstant.cpp(tools/clang/lib/AST/ExprConstant.cpp),</div><div>  these codes are</div><div>   3166:  // Don't call function pointers which have been cast to some other type.</div><div>   3167:  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))</div><div>   3168:    return Error(E);</div><div>   It returns  Error(E) . Then, the expression "foo(((~0U)>>1))" is optimized out in the later stage.</div><div>   Here FD is foo's function pointer, so I think it should not return Error.</div><div>   Maybe it is bug, could someone help me with that?</div><div>   </div><div>   Thanks a million in advance.</div><div>--Haishan</div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>