From 22df0eb2e81015afa9d74e04ab83e6dc9f21f551 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 19 Nov 2014 01:02:22 +0000 Subject: [PATCH] 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 llvm-svn: 222294 --- llvm/include/llvm/ADT/APInt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 4d19bab..f4e7e3c 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -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. -- 2.7.4