[llvm] r222294 - Use a memcpy so that type based alias analysis sees the change.

Rafael Espindola rafael.espindola at gmail.com
Tue Nov 18 17:02:23 PST 2014


Author: rafael
Date: Tue Nov 18 19:02:22 2014
New Revision: 222294

URL: http://llvm.org/viewvc/llvm-project?rev=222294&view=rev
Log:
Use a memcpy so that type based alias analysis sees the change.

The other option would be to do something like

if (that.isSingleWord())
  VAL = that.VAL;
else
  pVal = that.pVal

This bug was causing 86TTI::getIntImmCost to be miscompiled in a LTO
bootstrap in stage2, causing the build of stage3 to fail.

LLVM is getting quiet good at exploiting this. Not sure if there is anything
a sanitizer could do to help

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=222294&r1=222293&r2=222294&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Tue Nov 18 19:02:22 2014
@@ -665,7 +665,9 @@ public:
       delete[] pVal;
     }
 
-    VAL = that.VAL;
+    // Use memcpy so that type based alias analysis sees both VAL and pVal
+    // as modified.
+    memcpy(&VAL, &that.VAL, sizeof(uint64_t));
 
     // If 'this == &that', avoid zeroing our own bitwidth by storing to 'that'
     // first.





More information about the llvm-commits mailing list