[llvm] r243891 - [MCJIT] Fix a cast warning in the unit-test introduced in r243589.

David Blaikie dblaikie at gmail.com
Mon Aug 3 11:25:39 PDT 2015


On Mon, Aug 3, 2015 at 11:03 AM, Lang Hames <lhames at gmail.com> wrote:

> Author: lhames
> Date: Mon Aug  3 13:03:40 2015
> New Revision: 243891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=243891&view=rev
> Log:
> [MCJIT] Fix a cast warning in the unit-test introduced in r243589.
>
> Thanks to Aaron Ballman for spotting this.
>
> Modified:
>     llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
>
> Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp?rev=243891&r1=243890&r2=243891&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp (original)
> +++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp Mon Aug
> 3 13:03:40 2015
> @@ -514,7 +514,13 @@ TEST_F(MCJITCAPITest, addGlobalMapping)
>    buildMCJITOptions();
>    buildMCJITEngine();
>
> -  LLVMAddGlobalMapping(Engine, MappedFn,
> reinterpret_cast<void*>(&localTestFunc));
> +  union {
> +    int (*raw)();
> +    void *usable;
> +  } functionPointer;
> +  functionPointer.raw = &localTestFunc;
>

This is actually UB, but I think it's somewhere in the UB subset that LLVM
intentionally preserves the expected behavior of (& I'm not sure if we rely
on this in other parts of LLVM/assume that all compilers used to build LLVM
support this behavior).


> +
> +  LLVMAddGlobalMapping(Engine, MappedFn, functionPointer.usable);
>
>    buildAndRunPasses();
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150803/bfd5f30d/attachment.html>


More information about the llvm-commits mailing list