gcc / C++ Disable generation of vex instructions

岁酱吖の 提交于 2019-12-14 03:21:35

问题


We are debugging memory issues with our large legacy app and would like to use Valgrind to track it down. The app uses the ACE/TAO CORBA library however, Valgrind complains of illegal "vex" instructions in the library.

==29992== Memcheck, a memory error detector
==29992== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==29992== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==29992== Command: DvMain
==29992==
DvMain. Version 6.0  Build 38B16
vex x86->IR: unhandled instruction bytes: 0xC4 0xE2 0x7B 0xF7
==29992== valgrind: Unrecognised instruction at address 0x5f37a4b.
==29992==    at 0x5F37A4B: ACE_Select_Reactor_Impl::bit_ops(int, unsigned long, ACE_Select_Reactor_Handle_Set&, int) (in /usr/local/dvstation/lib3p/ACE/libACE.so.6.2.7)

In another SO question, VTT suggested disabling AVX instructions with -mno-avx, which worked on some things. However, still have problems.

I've tried -mno-sse2avx -mno-avx -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a but Valgrind still complains of vex instructions in ::bit_ops() (If you are interested, bit_ops is defined on line 956 of this file)

How do I disable completely the generation of VEX instructions so I can use Valgrind to debug?

Platform is 32-bit Centos 6, g++ 4.9.4

(please don't suggest moving to 64-bit. That's not an option with this product)

Reference:

Compile line for offending file:

/usr/local/gcc-4.9.4/bin/c++4.9  -mno-sse2avx -fvisibility=hidden 
-fvisibility-inlines-hidden -fdiagnostics-color=auto 
-mno-avx -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a 
-O3 -march=native -pthread -fno-strict-aliasing 
-Wall -W -Wpointer-arith -pipe -D_GNU_SOURCE  
-c -fPIC -o .shobj/Select_Reactor_Base.o Select_Reactor_Base.cpp

回答1:


VEX is pretty new. Using an old architecture, e.g. -march=pentium4 will disallow VEX instruction coding, but you keep SSE2.




回答2:


Perhaps you can use valgrind 3.12 from DTS instead, in the form of the devtoolset-6-valgrind package?

  • devtoolset-6

Support for AVX2 instructions was added in valgrind 3.9, so you might avoid recompiling your software.




回答3:


VEX is the Valgrind abstract machine representation. It is a fundamental part of Valgrind and you cannot turn it off. You either need to tell the compiler to emit machine code that your version of Valgrind understands or else upgrade to a more recent version of Valgrind that understands AVX.

AVX dates from about 2011 whilst the version of Valgrind that you are using was released in September 2012 and it probably hadn't added AVX support. Confusingly, these extensions also use a "VEX" prefix. In this case the "vex x86->IR" message from Valgrind refers to Valgrind's VEX not the AVX VEX prefix.



来源:https://stackoverflow.com/questions/45992636/gcc-c-disable-generation-of-vex-instructions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!