[llvm] r254956 - Remove useless hack that avoids calling LLVMLinkInInterpreter()
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 14:43:48 PST 2015
> On Dec 7, 2015, at 2:40 PM, David Majnemer <david.majnemer at gmail.com> wrote:
>
>
>
> On Mon, Dec 7, 2015 at 5:32 PM, David Blaikie via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>
>
> On Mon, Dec 7, 2015 at 2:27 PM, Mehdi Amini via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: mehdi_amini
> Date: Mon Dec 7 16:27:19 2015
> New Revision: 254956
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254956&view=rev <http://llvm.org/viewvc/llvm-project?rev=254956&view=rev>
> Log:
> Remove useless hack that avoids calling LLVMLinkInInterpreter()
>
> This is supposed to force-link the Interpreter, by inserting a dead
> call to LLVMLinkInInterpreter().
> Since it is actually an empty function, there is no reason for the
> call to be dead.
>
> From: Mehdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>>
>
> Modified:
> llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h
>
> Modified: llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h?rev=254956&r1=254955&r2=254956&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h?rev=254956&r1=254955&r2=254956&view=diff>
> ==============================================================================
> --- llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h (original)
> +++ llvm/trunk/include/llvm/ExecutionEngine/Interpreter.h Mon Dec 7 16:27:19 2015
> @@ -16,22 +16,12 @@
> #define LLVM_EXECUTIONENGINE_INTERPRETER_H
>
> #include "llvm/ExecutionEngine/ExecutionEngine.h"
> -#include <cstdlib>
>
> extern "C" void LLVMLinkInInterpreter();
>
> namespace {
> struct ForceInterpreterLinking {
> - ForceInterpreterLinking() {
> - // We must reference the interpreter in such a way that compilers will not
> - // delete it all as dead code, even with whole program optimization,
> - // yet is effectively a NO-OP. As the compiler isn't smart enough
> - // to know that getenv() never returns -1, this will do the job.
> - if (std::getenv("bar") != (char*) -1)
> - return;
> -
> - LLVMLinkInInterpreter();
> - }
> + ForceInterpreterLinking() { LLVMLinkInInterpreter(); }
> } ForceInterpreterLinking;
>
> Not sure if you want to, but could possibly simplify this further with something like:
>
> int i = (LLVMLinkInInterpreter(), 1);
>
> Maybe? Not sure if that's any better, stylistically, etc.
>
> Personally, I'd find that more surprising than a global ctor.
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.
The “client" of the header being responsible to choose how to call it (global ctor or other).
—
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151207/5c98cac6/attachment.html>
More information about the llvm-commits
mailing list