1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/lib
hyeongyukim 73cd3d2fbf [InstCombine] Fix miscompile on GEP+load to icmp fold (PR45210)
As noted in PR45210: https://bugs.llvm.org/show_bug.cgi?id=45210
...the bug is triggered as Eli say when sext(idx) * ElementSize overflows.

```
   // assume that GV is an array of 4-byte elements
   GEP = gep GV, 0, Idx // this is accessing Idx * 4
   L = load GEP
   ICI = icmp eq L, value
 =>
   ICI = icmp eq Idx, NewIdx
```

The foldCmpLoadFromIndexedGlobal function simplifies GEP+load operation to icmp.
And there is a problem because Idx * ElementSize can overflow.

Let's assume that the wanted value is at offset 0.
Then, there are actually four possible values for Idx to match offset 0: 0x00..00, 0x40..00, 0x80..00, 0xC0..00.
We should return true for all these values, but currently, the new icmp only returns true for 0x00..00.

This problem can be solved by masking off (trailing zeros of ElementSize) bits from Idx.

```
   ...
 =>
   Idx' = and Idx, 0x3F..FF
   ICI = icmp eq Idx', NewIdx
```

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D99481
2021-06-17 19:46:17 +09:00
..
Analysis Update @llvm.powi to handle different int sizes for the exponent 2021-06-17 09:38:28 +02:00
AsmParser [LLParser] Remove outdated deplibs 2021-06-14 12:46:12 +08:00
BinaryFormat [AIX][XCOFF] emit vector info of traceback table. 2021-06-14 11:15:22 -04:00
Bitcode Move some code under NDEBUG from D103135 2021-06-14 11:39:12 -07:00
Bitstream
CodeGen [InterleaveAccess] Copy fast math flags when adjusting binary operators in interleave access pass 2021-06-17 09:53:33 +01:00
DebugInfo [Debug-Info][CodeView] Fix GUID string generation for MSVC generated objects. 2021-06-15 06:53:21 +01:00
Demangle [Demangle] Support Rust v0 mangling scheme in llvm::demangle 2021-06-17 10:37:26 +02:00
DWARFLinker [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
ExecutionEngine [ORC] Switch from uint8_t to char buffers for TargetProcessControl::runWrapper. 2021-06-17 13:27:09 +10:00
Extensions
FileCheck Fix PR46880: Fail CHECK-NOT with undefined variable 2021-04-20 14:42:46 +01:00
Frontend [OPENMP]Fix PR50129: omp cancel parallel not working as expected. 2021-06-04 08:24:55 -07:00
Fuzzer
FuzzMutate [FuzzMutate] Fix getWeight of InstDeleterIRStrategy 2021-06-08 11:14:33 -07:00
InterfaceStub
IR [AMDGPU] Fixed constexpr expansion to handle multiple uses 2021-06-16 16:57:41 -07:00
IRReader [NFC] Reordering parameters in getFile and getFileOrSTDIN 2021-03-25 09:47:49 -04:00
LineEditor
Linker Linker: Avoid scheduling the link of a global value twice due to an alias 2021-04-28 13:22:10 -07:00
LTO [LTO] Support new PM in ThinLTOCodeGenerator. 2021-06-09 10:05:14 +01:00
MC Implement DW_CFA_LLVM_* for Heterogeneous Debugging 2021-06-14 08:51:50 +05:30
MCA [MCA] Anchoring the vtable of CustomBehaviour 2021-06-16 12:43:58 -07:00
Object [AIX][XCOFF] emit vector info of traceback table. 2021-06-14 11:15:22 -04:00
ObjectYAML [obj2yaml] Address D104035 review comments 2021-06-16 15:01:54 +01:00
Option
Passes [NewPM] Remove SpeculateAroundPHIs pass 2021-06-15 20:35:55 +03:00
ProfileData [CSSPGO] Report zero-count probe in profile instead of dangling probes. 2021-06-16 11:45:29 -07:00
Remarks [Support] Don't include VirtualFileSystem.h in CommandLine.h 2021-04-21 10:19:01 -04:00
Support Move the definition of LLVM_SUPPORT_XCODE_SIGNPOSTS into llvm-config.h 2021-06-16 14:40:37 -07:00
TableGen DetailedRecordsBackend.cpp - printSectionHeading - avoid std::string creation/copies. 2021-06-13 16:49:40 +01:00
Target [RISCV][VP] Lower FP VP ISD nodes to RVV instructions 2021-06-17 10:04:00 +01:00
Testing Fix for error "'Run' overrides a member function but is not marked 2021-06-11 06:56:00 -07:00
TextAPI Reland "[llvm] llvm-tapi-diff" 2021-06-09 21:17:34 -07:00
ToolDrivers [llvm-dlltool] Imply the target arch from a tool triple prefix 2021-06-17 13:02:35 +03:00
Transforms [InstCombine] Fix miscompile on GEP+load to icmp fold (PR45210) 2021-06-17 19:46:17 +09:00
WindowsManifest
XRay
CMakeLists.txt