<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 2:40 PM, David Majnemer <<a href="mailto:david.majnemer@gmail.com" class="">david.majnemer@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mon, Dec 7, 2015 at 5:32 PM, David Blaikie via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Mon, Dec 7, 2015 at 2:27 PM, Mehdi Amini via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: mehdi_amini<br class="">Date: Mon Dec  7 16:27:19 2015<br class="">New Revision: 254956<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=254956&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=254956&view=rev</a><br class="">Log:<br class="">Remove useless hack that avoids calling LLVMLinkInInterpreter()<br class=""><br class="">This is supposed to force-link the Interpreter, by inserting a dead<br class="">call to LLVMLinkInInterpreter().<br class="">Since it is actually an empty function, there is no reason for the<br class="">call to be dead.<br class=""><br class="">From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" target="_blank" class="">mehdi.amini@apple.com</a>><br class=""><br class="">Modified:<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h<br class=""><br class="">Modified: llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h?rev=254956&r1=254955&r2=254956&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h?rev=254956&r1=254955&r2=254956&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h (original)<br class="">+++ llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h Mon Dec  7 16:27:19 2015<br class="">@@ -16,22 +16,12 @@<br class=""> #define LLVM_EXECUTIONENGINE_INTERPRETER_H<br class=""><br class=""> #include "llvm/ExecutionEngine/ExecutionEngine.h"<br class="">-#include <cstdlib><br class=""><br class=""> extern "C" void LLVMLinkInInterpreter();<br class=""><br class=""> namespace {<br class="">   struct ForceInterpreterLinking {<br class="">-    ForceInterpreterLinking() {<br class="">-      // We must reference the interpreter in such a way that compilers will not<br class="">-      // delete it all as dead code, even with whole program optimization,<br class="">-      // yet is effectively a NO-OP. As the compiler isn't smart enough<br class="">-      // to know that getenv() never returns -1, this will do the job.<br class="">-      if (std::getenv("bar") != (char*) -1)<br class="">-        return;<br class="">-<br class="">-      LLVMLinkInInterpreter();<br class="">-    }<br class="">+    ForceInterpreterLinking() { LLVMLinkInInterpreter(); }<br class="">   } ForceInterpreterLinking;<br class=""></blockquote><div class=""><br class=""></div></div></div><div class="">Not sure if you want to, but could possibly simplify this further with something like:<br class=""><br class="">int i = (LLVMLinkInInterpreter(), 1);<br class=""><br class="">Maybe? Not sure if that's any better, stylistically, etc.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Personally, I'd find that more surprising than a global ctor.</div></div></div></blockquote><br class=""></div><div>Actually I’d rather eliminate the global ctor entirely (it will be currently emitted anywhere this header is included) and have the call to `LLVMLinkInInterpreter()` to be inserted appropriately on the required path. </div><div>The “client" of the header being responsible to choose how to call it (global ctor or other).</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""></div></body></html>