summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 23:29:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 23:29:28 +0000
commit228e6d4cf347820fce53e57c24b266f67a413d85 (patch)
treed2b63a5d9cee710515d33361e84ad0988d2c31fa /llvm/lib/CodeGen/SelectionDAG
parent3d91b43ad22b69408af224a8d67561038705ec55 (diff)
downloadbcm5719-llvm-228e6d4cf347820fce53e57c24b266f67a413d85.tar.gz
bcm5719-llvm-228e6d4cf347820fce53e57c24b266f67a413d85.zip
Fix integer undefined behavior due to signed left shift overflow in LLVM.
Reviewed offline by chandlerc. llvm-svn: 162623
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index f4fe8927f69..3ab0b46def8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1097,10 +1097,9 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV, DebugLoc DL,
"Cannot set target flags on target-independent globals");
// Truncate (with sign-extension) the offset value to the pointer size.
- EVT PTy = TLI.getPointerTy();
- unsigned BitWidth = PTy.getSizeInBits();
+ unsigned BitWidth = TLI.getPointerTy().getSizeInBits();
if (BitWidth < 64)
- Offset = (Offset << (64 - BitWidth) >> (64 - BitWidth));
+ Offset = SignExtend64(Offset, BitWidth);
const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
if (!GVar) {
OpenPOWER on IntegriCloud