1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/include/llvm
Hal Finkel 88d49a9216 [BasicAA] Support arbitrary pointer sizes (and fix an overflow bug)
Motivated by the discussion in D38499, this patch updates BasicAA to support
arbitrary pointer sizes by switching most remaining non-APInt calculations to
use APInt. The size of these APInts is set to the maximum pointer size (maximum
over all address spaces described by the data layout string).

Most of this translation is straightforward, but this patch contains a fix for
a bug that revealed itself during this translation process. In order for
test/Analysis/BasicAA/gep-and-alias.ll to pass, which is run with 32-bit
pointers, the intermediate calculations must be performed using 64-bit
integers. This is because, as noted in the patch, when GetLinearExpression
decomposes an expression into C1*V+C2, and we then multiply this by Scale, and
distribute, to get (C1*Scale)*V + C2*Scale, it can be the case that, even
through C1*V+C2 does not overflow for relevant values of V, (C2*Scale) can
overflow. If this happens, later logic will draw invalid conclusions from the
(base) offset value. Thus, when initially applying the APInt conversion,
because the maximum pointer size in this test is 32 bits, it started failing.
Suspicious, I created a 64-bit version of this test (included here), and that
failed (miscompiled) on trunk for a similar reason (the multiplication can
overflow).

After fixing this overflow bug, the first test case (at least) in
Analysis/BasicAA/q.bad.ll started failing. This is also a 32-bit test, and was
relying on having 64-bit intermediate values to have BasicAA return an accurate
result. In order to fix this problem, and because I believe that it is not
uncommon to use i64 indexing expressions in 32-bit code (especially portable
code using int64_t), it seems reasonable to always use at least 64-bit
integers. In this way, we won't regress our analysis capabilities (and there's
a command-line option added, so experimenting with this should be easy).

As pointed out by Eli during the review, there are other potential overflow
conditions that this patch does not address. Fixing those is left to follow-up
work.

Patch by me with contributions from Michael Ferguson (mferguson@cray.com).

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

llvm-svn: 350220
2019-01-02 16:28:09 +00:00
..
ADT [ADT] IntervalMap: add overlaps(a, b) method 2018-12-21 13:04:34 +00:00
Analysis [BasicAA] Support arbitrary pointer sizes (and fix an overflow bug) 2019-01-02 16:28:09 +00:00
AsmParser
BinaryFormat Add PLATFORM constants for iOS, tvOS, and watchOS simulators 2018-12-20 17:51:17 +00:00
Bitcode [IR] Add a dedicated FNeg IR Instruction 2018-11-13 18:15:47 +00:00
CodeGen Add vtable anchor to classes. 2018-12-29 02:02:13 +00:00
Config [Support/FileSystem] Add sub-second precision for atime/mtime of sys::fs::file_status on unix platforms 2018-11-26 00:03:39 +00:00
DebugInfo [CodeView] Extend the MemberAttributes interface with the isStatic method 2018-12-28 17:03:24 +00:00
Demangle [MS Demangler] Add a helper function to print a Node as a string. 2018-12-17 16:14:50 +00:00
ExecutionEngine [ORC] Remove redundant instruction from MIPS resolver code. NFC 2018-12-23 12:04:55 +00:00
FuzzMutate
IR [BasicAA] Support arbitrary pointer sizes (and fix an overflow bug) 2019-01-02 16:28:09 +00:00
IRReader
LineEditor
Linker
LTO [ThinLTO] Compute synthetic function entry count 2018-12-13 19:54:27 +00:00
MC [WebAssembly] Make assembler check for proper nesting of control flow. 2018-12-26 22:46:18 +00:00
MCA [MCA] Add support for BeginGroup/EndGroup. 2018-12-17 14:27:33 +00:00
Object Add vtable anchor to classes. 2018-12-29 02:02:13 +00:00
ObjectYAML [yaml2obj/obj2yaml] - Support dumping/parsing ABI version. 2018-12-20 10:43:49 +00:00
Option [opt] Change the parameter of OptTable::PrintHelp from Name to Usage and don't append "[options] <inputs>" 2018-10-10 00:15:31 +00:00
Passes [NewPM] -print-module-scope -print-after now prints module even after invalidated Loop/SCC 2018-12-21 11:49:05 +00:00
ProfileData Fix use-after-free with profile remapping. 2018-12-19 03:24:03 +00:00
Support Add vtable anchor to classes. 2018-12-29 02:02:13 +00:00
TableGen Fix and modernize StringMatcher comment; NFC 2018-09-28 13:31:55 +00:00
Target [GlobalISel][AArch64] Add support for @llvm.ceil 2018-12-19 19:01:36 +00:00
Testing/Support Add missing #include for Testing/Support/SupportHelpers.h 2018-09-06 20:01:06 +00:00
TextAPI/ELF [TextAPI][elfabi] Make SoName optional 2018-12-11 01:00:16 +00:00
ToolDrivers
Transforms Introduce llvm.loop.parallel_accesses and llvm.access.group metadata. 2018-12-20 04:58:07 +00:00
WindowsManifest
WindowsResource
XRay [XRay] Improve FDR trace handling and error messaging 2018-11-09 06:26:48 +00:00
CMakeLists.txt
InitializePasses.h [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes. 2018-12-12 17:32:52 +00:00
LinkAllIR.h Remove trailing space 2018-07-30 19:41:25 +00:00
LinkAllPasses.h [Analysis] s/uint64_t/LocationSize; NFC 2018-12-22 17:42:08 +00:00
module.extern.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.install.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.modulemap [LLVM] Allow modulemap installation 2018-11-21 20:46:50 +00:00
module.modulemap.build
Pass.h [New PM][PassInstrumentation] IR printing support for New Pass Manager 2018-09-24 16:08:15 +00:00
PassAnalysisSupport.h Remove trailing space 2018-07-30 19:41:25 +00:00
PassInfo.h
PassRegistry.h Remove trailing space 2018-07-30 19:41:25 +00:00
PassSupport.h