DenseMap: Appease -fstrict-aliasing on g++-4.4.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 5 Jan 2013 05:14:23 +0000 (05:14 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sat, 5 Jan 2013 05:14:23 +0000 (05:14 +0000)
With DenseMapInfo<Enum>, it is miscompiled on g++-4.4.

    static inline Enum getEmptyKey() { return Enum(<arbitrary int/unsigned value>); }

    isEauql(getEmptyKey(), ...)

The compiler mis-assumes the return value is not aliased to Enum.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171600 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/DenseMap.h

index 8607fb7e9ccb754c14bac7caa3ce8ab4fdff6af7..4a2d13786f220aaefbe9ac940056026f7a18db57 100644 (file)
@@ -430,7 +430,8 @@ private:
     incrementNumEntries();
 
     // If we are writing over a tombstone, remember this.
-    if (!KeyInfoT::isEqual(TheBucket->first, getEmptyKey()))
+    const KeyT EmptyKey = getEmptyKey();
+    if (!KeyInfoT::isEqual(TheBucket->first, EmptyKey))
       decrementNumTombstones();
 
     return TheBucket;