aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/InstCombine/InstructionCombining.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-01-23 17:52:29 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-01-23 17:52:29 +0000
commit028dba376ae90c82b44d72ddb3ed97849484aab4 (patch)
tree246dadac34a931c70c8df74e41171d9f5aeff88f /lib/Transforms/InstCombine/InstructionCombining.cpp
parent9381dd1ac9ac8a4020cd0dd03323a26f1ae5587f (diff)
downloadexternal_llvm-028dba376ae90c82b44d72ddb3ed97849484aab4.zip
external_llvm-028dba376ae90c82b44d72ddb3ed97849484aab4.tar.gz
external_llvm-028dba376ae90c82b44d72ddb3ed97849484aab4.tar.bz2
Revert "InstCombine: Clean up weird code that talks about a modulus that's long gone."
This causes crashes during the build of compiler-rt during selfhost. Add a testcase for coverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index e9e05ce..dc7fe5c 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -758,7 +758,12 @@ Type *InstCombiner::FindElementAtOffset(Type *Ty, int64_t Offset,
FirstIdx = Offset/TySize;
Offset -= FirstIdx*TySize;
- assert(Offset >= 0 && "Offset should never be negative!");
+ // Handle hosts where % returns negative instead of values [0..TySize).
+ if (Offset < 0) {
+ --FirstIdx;
+ Offset += TySize;
+ assert(Offset >= 0);
+ }
assert((uint64_t)Offset < (uint64_t)TySize && "Out of range offset");
}