]> granicus.if.org Git - llvm/commit
Check for overflows when calculating the offset in GetGEPCost.
authorJustin Lebar <jlebar@google.com>
Wed, 27 Sep 2017 23:16:56 +0000 (23:16 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 27 Sep 2017 23:16:56 +0000 (23:16 +0000)
commit2036b38fe191696f5d1b20571512feb725b49932
treec63353174ceafaa79097eb0af0fbd20f6d11c2f5
parent4e27573cfe29b71da8bc7fdf8d16e1dd0d9dd828
Check for overflows when calculating the offset in GetGEPCost.

Summary:
This avoids C++ UB if the GEP is weird and the calculation overflows
int64_t, and it's also observable in the cost model's results.

Such GEPs are almost surely not valid pointers, but LLVM nonetheless
generates them sometimes.

Reviewers: sanjoy

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D38337

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314362 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/TargetTransformInfoImpl.h
test/Analysis/CostModel/X86/gep.ll