<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Thank you! This solved my issue!</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Craig Topper <craig.topper@gmail.com><br>
<b>Sent:</b> 04 December 2017 17:46:01<br>
<b>To:</b> Kyriakos Georgiou<br>
<b>Cc:</b> cfe-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [cfe-dev] Opt seems to report fewer stats when splitting the compilation to the several stages, rather than using clang</font>
<div> </div>
</div>
<div>
<div>
<div dir="auto">You need to invoke clang with -O2 -Xclang -disable-llvm-optzns instead of -O0</div>
<div dir="auto"><br>
</div>
<div dir="auto">-O0 implies to clang to mark all functions as optnone in the generated IR</div>
<br>
<div class="x_gmail_quote">
<div>On Mon, Dec 4, 2017 at 4:31 AM Kyriakos Georgiou via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div id="x_m_957289593907998234divtagdefaultwrapper">
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">Hi,</span><font color="#333333" face="Segoe UI WestEuropean, Segoe UI, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, sans-serif"><span style="font-size:17px; white-space:nowrap"></span></font></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<br>
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
I am trying to recreate the compilation of using clang and -O2 by splitting the compilation to the several stages using the several llvm tools (clang as front-end, opt, llc..) but the optimiser seems to behave differently if called individually than when called
 by clang. I am using the latest llvm version. So I am calling the front end using:</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"><br>
</span></p>
<blockquote style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin:0px 0px 0px 40px; border:none; padding:0px">
<p style="margin-top:0; margin-bottom:0"><span style="font-size:12pt"></span></p>
<div>clang  -mllvm -stats -mllvm -debug-pass=Structure -target arm-none-eabi -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include -DHAVE_CONFIG_H -I. -I../.. -Wall -I ../../i^Clude -I ../../config/arm/boards/lpcxpresso_1769_xpresso/
 -I ../../config/arm/chips/lpc175x_6x/ "-DCALIB_SCALE=0" --static -mthumb -mcpu=cortex-m3 -D__USE_LPCOPEN -D__CODE_RED -D__REDLIB__ -DCHIP_LPC175X_6X -DCORE_M3 -ffunction-sections -fdata-sections -O2 -c -emit-llvm  -o adpcm_optimized.bc adpcm.c</div>
<p></p>
</blockquote>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"></span></p>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</div>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
<br>
</div>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
this also gives me the optimizer statistics and the structure of calling the passes.</div>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
<br>
</div>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
then I am using </div>
<span style="font-size:12pt">  </span>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
</p>
<blockquote style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin:0px 0px 0px 40px; border:none; padding:0px">
<p><span style="font-size:12pt"></span></p>
<div>clang  -mllvm -stats -mllvm -debug-pass=Structure -target arm-none-eabi -isystem /usr/local/lpcxpresso_8.2.2_650/lpcxpresso/tools/arm-none-eabi/include -DHAVE_CONFIG_H -I. -I../.. -Wall -I ../../i^Clude -I ../../config/arm/boards/lpcxpresso_1769_xpresso/
 -I ../../config/arm/chips/lpc175x_6x/ "-DCALIB_SCALE=0" --static -mthumb -mcpu=cortex-m3 -D__USE_LPCOPEN -D__CODE_RED -D__REDLIB__ -DCHIP_LPC175X_6X -DCORE_M3 -ffunction-sections -fdata-sections -O0 -c -emit-llvm  -o adpcm_no_opt.bc adpcm.c</div>
<div><br>
</div>
<div>and then</div>
<div><br>
</div>
<div><span>opt -stats -O2 -S  -debug-pass=Structure adpcm<span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">_no_opt</span>.bc -o
 adpcm.ll</span><br>
</div>
<div><br>
</div>
</blockquote>
<span style="font-size:12pt">I was expecting the stats coming out of the opt call to be the same as calling clang with -O2. Instead they are very little:
</span>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</p>
<blockquote style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin:0px 0px 0px 40px; border:none; padding:0px">
<p style="margin-top:0; margin-bottom:0"></p>
<div> 18 basicaa          - Number of times a GEP is decomposed</div>
<p></p>
<p style="margin-top:0; margin-bottom:0"></p>
<div>  1 cgscc-passmgr    - Maximum CGSCCPassMgr iterations on one SCC</div>
<p></p>
<p style="margin-top:0; margin-bottom:0"></p>
<div>104 globalopt        - Number of globals marked unnamed_addr</div>
<p></p>
<p style="margin-top:0; margin-bottom:0"></p>
<div>  6 globalsmodref-aa - Number of global vars without address taken</div>
<p></p>
</blockquote>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
</p>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</div>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
<br>
</div>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
Am I doing something wrong or missing something? The Structure of calling the passes is still the same,  and also the  emitted code from the clang with -O2 and the opt with -O2 seems to be the same. So why is the optimiser called individually not reporting
 the full stats?</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<br>
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
Thank you,</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
Kyriakos<br>
</p>
<blockquote style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin:0px 0px 0px 40px; border:none; padding:0px">
<p></p>
</blockquote>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
<span style="font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols"></span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols"></span></span></p>
<div style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">
</div>
<br>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt">
</p>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
<div dir="ltr">-- <br>
</div>
<div class="x_gmail_signature">~Craig</div>
</div>
</body>
</html>