llvm.org GIT mirror llvm / add8f51
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226170 91177308-0d34-0410-b5e6-96231b3b80d8 Vasileios Kalintiris 5 years ago
1 changed file(s) with 8 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
358358 buildMCJITEngine();
359359 buildAndRunPasses();
360360
361 union {
362 uint64_t raw;
363 int32_t *usable;
364 } valuePointer;
365 valuePointer.raw = LLVMGetGlobalValueAddress(Engine, "simple_value");
366
367 EXPECT_EQ(42, *valuePointer.usable);
361 uint64_t raw = LLVMGetGlobalValueAddress(Engine, "simple_value");
362 int32_t *usable = (int32_t *) raw;
363
364 EXPECT_EQ(42, *usable);
368365 }
369366
370367 TEST_F(MCJITCAPITest, gfa) {
375372 buildMCJITEngine();
376373 buildAndRunPasses();
377374
378 union {
379 uint64_t raw;
380 int (*usable)();
381 } functionPointer;
382 functionPointer.raw = LLVMGetFunctionAddress(Engine, "simple_function");
383
384 EXPECT_EQ(42, functionPointer.usable());
375 uint64_t raw = LLVMGetFunctionAddress(Engine, "simple_function");
376 int (*usable)() = (int (*)()) raw;
377
378 EXPECT_EQ(42, usable());
385379 }
386380
387381 TEST_F(MCJITCAPITest, custom_memory_manager) {