[PATCH] D11890: Fixed Visual Studio warnings.
James Touton via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 9 17:24:08 PDT 2015
jtouton created this revision.
jtouton added a subscriber: llvm-commits.
Simplified applyMask by consolidating common code for 32-bit and 64-bit builds.
Extend mask value to 64 bits before taking its complement.
Made 64-bit conversions explicit.
http://reviews.llvm.org/D11890
Files:
include/llvm/ADT/SmallBitVector.h
lib/Target/X86/X86ISelLowering.cpp
lib/Transforms/Instrumentation/ThreadSanitizer.cpp
Index: lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -142,7 +142,7 @@
M.getOrInsertFunction("__tsan_func_exit", IRB.getVoidTy(), nullptr));
OrdTy = IRB.getInt32Ty();
for (size_t i = 0; i < kNumberOfAccessSizes; ++i) {
- const size_t ByteSize = 1 << i;
+ const size_t ByteSize = size_t(1 << i);
const size_t BitSize = ByteSize * 8;
SmallString<32> ReadName("__tsan_read" + itostr(ByteSize));
TsanRead[i] = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
@@ -513,7 +513,7 @@
int Idx = getMemoryAccessFuncIndex(Addr, DL);
if (Idx < 0)
return false;
- const size_t ByteSize = 1 << Idx;
+ const size_t ByteSize = size_t(1 << Idx);
const size_t BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
@@ -527,7 +527,7 @@
int Idx = getMemoryAccessFuncIndex(Addr, DL);
if (Idx < 0)
return false;
- const size_t ByteSize = 1 << Idx;
+ const size_t ByteSize = size_t(1 << Idx);
const size_t BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
@@ -544,7 +544,7 @@
Function *F = TsanAtomicRMW[RMWI->getOperation()][Idx];
if (!F)
return false;
- const size_t ByteSize = 1 << Idx;
+ const size_t ByteSize = size_t(1 << Idx);
const size_t BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
@@ -558,7 +558,7 @@
int Idx = getMemoryAccessFuncIndex(Addr, DL);
if (Idx < 0)
return false;
- const size_t ByteSize = 1 << Idx;
+ const size_t ByteSize = size_t(1 << Idx);
const size_t BitSize = ByteSize * 8;
Type *Ty = Type::getIntNTy(IRB.getContext(), BitSize);
Type *PtrTy = Ty->getPointerTo();
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -4955,7 +4955,7 @@
return SDValue();
if ((Offset % RequiredAlign) & 3)
return SDValue();
- int64_t StartOffset = Offset & ~(RequiredAlign-1);
+ int64_t StartOffset = Offset & ~int64_t(RequiredAlign-1);
if (StartOffset) {
SDLoc DL(Ptr);
Ptr = DAG.getNode(ISD::ADD, DL, Ptr.getValueType(), Ptr,
Index: include/llvm/ADT/SmallBitVector.h
===================================================================
--- include/llvm/ADT/SmallBitVector.h
+++ include/llvm/ADT/SmallBitVector.h
@@ -553,17 +553,12 @@
private:
template<bool AddBits, bool InvertMask>
void applyMask(const uint32_t *Mask, unsigned MaskWords) {
- if (NumBaseBits == 64 && MaskWords >= 2) {
- uint64_t M = Mask[0] | (uint64_t(Mask[1]) << 32);
- if (InvertMask) M = ~M;
- if (AddBits) setSmallBits(getSmallBits() | M);
- else setSmallBits(getSmallBits() & ~M);
- } else {
- uint32_t M = Mask[0];
- if (InvertMask) M = ~M;
- if (AddBits) setSmallBits(getSmallBits() | M);
- else setSmallBits(getSmallBits() & ~M);
- }
+ uintptr_t M = Mask[0];
+ if (NumBaseBits == 64 && MaskWords >= 2)
+ M |= uintptr_t(Mask[1]) << 32;
+ if (InvertMask) M = ~M;
+ if (AddBits) setSmallBits(getSmallBits() | M);
+ else setSmallBits(getSmallBits() & ~M);
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11890.31626.patch
Type: text/x-patch
Size: 3575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150810/8a075ff1/attachment.bin>
More information about the llvm-commits
mailing list