xref: /llvm-project/llvm/test/Transforms/InstSimplify/ConstProp/gep-alias.ll (revision 8e8d2595dafa230a3da7f410200d89f05b6e8d87)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s
3; Test that we don't replace an alias with its aliasee when simplifying GEPs.
4; In this test case the transformation is invalid because it replaces the
5; reference to the symbol "b" (which refers to whichever instance of "b"
6; was chosen by the linker) with a reference to "a" (which refers to the
7; specific instance of "b" in this module).
8
9target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10target triple = "x86_64-unknown-linux-gnu"
11
12@a = internal global [3 x ptr] zeroinitializer
13@b = linkonce_odr alias [3 x ptr], ptr @a
14
15define ptr @f() {
16; CHECK-LABEL: define ptr @f() {
17; CHECK-NEXT:    ret ptr getelementptr (i8, ptr @b, i64 8)
18;
19  ret ptr getelementptr ([3 x ptr], ptr @b, i64 0, i64 1)
20}
21