[llvm] r254956 - Remove useless hack that avoids calling LLVMLinkInInterpreter()

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 7 14:32:00 PST 2015


On Mon, Dec 7, 2015 at 2:27 PM, Mehdi Amini via llvm-commits <
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
> 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>
>
> 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
>
> ==============================================================================
> --- 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.


>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151207/e7b3a038/attachment.html>


More information about the llvm-commits mailing list