Skip to content

InstCombine swaps inbounds geps originating OOB pointer #55722

Description

@nunoplopes

InstCombine transforms this:

%struct.A = type { [123 x i8], i32 }

define ptr @struct2(ptr %p) {
  %1 = getelementptr inbounds %struct.A, ptr %p, i64 0, i32 1
  %2 = getelementptr inbounds i8, ptr %1, i64 -128
  ret ptr %2
}

into:

define nonnull ptr @struct2(ptr readnone %p) {
  %1 = getelementptr inbounds %struct.A, ptr %p, i64 -1, i32 1
  ret ptr %1
}

The transformation seems to have been introduced in LLVM 14.
https://alive2.llvm.org/ce/z/8KGF2j

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmiscompilation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions