[llvm] r226170 - Fix the C-API MCJIT test for 32-bit big endian machines.

Daniel Sanders Daniel.Sanders at imgtec.com
Fri Jan 16 01:27:41 PST 2015


Hi Hans,

Are you happy for me to merge this to release_36? It fixes a faulty test.
________________________________________
From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] on behalf of Vasileios Kalintiris
Sent: 15 January 2015 15:36
To: llvm-commits at cs.uiuc.edu
Subject: [llvm] r226170 - Fix the C-API MCJIT test for 32-bit big endian        machines.

Author: vkalintiris
Date: Thu Jan 15 09:36:04 2015
New Revision: 226170

URL: http://llvm.org/viewvc/llvm-project?rev=226170&view=rev
Log:
Fix the C-API MCJIT test for 32-bit big endian machines.

Avoid using unions for storing the return value from
LLVMGetGlobalValueAddress() and LLVMGetFunctionAddress() and accessing it as
a pointer through another pointer member. This causes problems on 32-bit big
endian machines since the pointer gets the higher part of the return value of
the aforementioned functions.

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=226170&r1=226169&r2=226170&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp Thu Jan 15 09:36:04 2015
@@ -359,13 +359,10 @@ TEST_F(MCJITCAPITest, gva) {
   buildMCJITEngine();
   buildAndRunPasses();

-  union {
-    uint64_t raw;
-    int32_t *usable;
-  } valuePointer;
-  valuePointer.raw = LLVMGetGlobalValueAddress(Engine, "simple_value");
+  uint64_t raw = LLVMGetGlobalValueAddress(Engine, "simple_value");
+  int32_t *usable  = (int32_t *) raw;

-  EXPECT_EQ(42, *valuePointer.usable);
+  EXPECT_EQ(42, *usable);
 }

 TEST_F(MCJITCAPITest, gfa) {
@@ -376,13 +373,10 @@ TEST_F(MCJITCAPITest, gfa) {
   buildMCJITEngine();
   buildAndRunPasses();

-  union {
-    uint64_t raw;
-    int (*usable)();
-  } functionPointer;
-  functionPointer.raw = LLVMGetFunctionAddress(Engine, "simple_function");
+  uint64_t raw = LLVMGetFunctionAddress(Engine, "simple_function");
+  int (*usable)() = (int (*)()) raw;

-  EXPECT_EQ(42, functionPointer.usable());
+  EXPECT_EQ(42, usable());
 }

 TEST_F(MCJITCAPITest, custom_memory_manager) {


_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list