From b49612b4669a029c78f22e7ea20b9b4e988e8342 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 27 Mar 2012 10:19:39 +0000 Subject: [PATCH] /* Do expensive interpretation for Iop_Add32 and Iop_Add64 on Darwin. 10.7 is mostly built with LLVM, which uses these for bitfield inserts, and we get a lot of false errors if the cheap interpretation is used, alas. Could solve this much better if we knew which of such adds came from x86/amd64 LEA instructions, since these are the only ones really needing the expensive interpretation, but that would require some way to tag them in the _toIR.c front ends, which is a lot of faffing around. So for now just use the slow and blunt-instrument solution. */ Pertains to, although does not completely solve, #242137. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12467 --- memcheck/mc_translate.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/memcheck/mc_translate.c b/memcheck/mc_translate.c index 6ea43ac9ca..345e46a175 100644 --- a/memcheck/mc_translate.c +++ b/memcheck/mc_translate.c @@ -188,7 +188,13 @@ typedef /* MODIFIED: indicates whether "bogus" literals have so far been found. Starts off False, and may change to True. */ - Bool bogusLiterals; + Bool bogusLiterals; + + /* READONLY: indicates whether we should use expensive + interpretations of integer adds, since unfortunately LLVM + uses them to do ORs in some circumstances. Defaulted to True + on MacOS and False everywhere else. */ + Bool useLLVMworkarounds; /* READONLY: the guest layout. This indicates which parts of the guest state should be regarded as 'always defined'. */ @@ -3130,7 +3136,7 @@ IRAtom* expr2vbits_Binop ( MCEnv* mce, return mkLazy2(mce, Ity_I64, vatom1, vatom2); case Iop_Add32: - if (mce->bogusLiterals) + if (mce->bogusLiterals || mce->useLLVMworkarounds) return expensiveAddSub(mce,True,Ity_I32, vatom1,vatom2, atom1,atom2); else @@ -3153,7 +3159,7 @@ IRAtom* expr2vbits_Binop ( MCEnv* mce, return doCmpORD(mce, op, vatom1,vatom2, atom1,atom2); case Iop_Add64: - if (mce->bogusLiterals) + if (mce->bogusLiterals || mce->useLLVMworkarounds) return expensiveAddSub(mce,True,Ity_I64, vatom1,vatom2, atom1,atom2); else @@ -4908,6 +4914,20 @@ IRSB* MC_(instrument) ( VgCallbackClosure* closure, mce.hWordTy = hWordTy; mce.bogusLiterals = False; + /* Do expensive interpretation for Iop_Add32 and Iop_Add64 on + Darwin. 10.7 is mostly built with LLVM, which uses these for + bitfield inserts, and we get a lot of false errors if the cheap + interpretation is used, alas. Could solve this much better if + we knew which of such adds came from x86/amd64 LEA instructions, + since these are the only ones really needing the expensive + interpretation, but that would require some way to tag them in + the _toIR.c front ends, which is a lot of faffing around. So + for now just use the slow and blunt-instrument solution. */ + mce.useLLVMworkarounds = False; +# if defined(VGO_darwin) + mce.useLLVMworkarounds = True; +# endif + mce.tmpMap = VG_(newXA)( VG_(malloc), "mc.MC_(instrument).1", VG_(free), sizeof(TempMapEnt)); for (i = 0; i < sb_in->tyenv->types_used; i++) { -- 2.47.2