forked from llvm/clangir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR] Incorrect global view index and offset when neg index (llvm#795)
mixed signed and unsigned integer operator cause difference result when index of array is negative
- Loading branch information
1 parent
66ba348
commit 5758cef
Showing
2 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
// XFAIL: * | ||
|
||
struct __attribute__((packed)) PackedStruct { | ||
char a1; | ||
char a2; | ||
char a3; | ||
}; | ||
struct PackedStruct packed[10]; | ||
char *packed_element = &(packed[-2].a3); | ||
// CHECK: cir.global external @packed = #cir.zero : !cir.array<!ty_22PackedStruct22 x 10> loc(#loc5) | ||
// CHECK: cir.global external @packed_element = #cir.global_view<@packed, [-2 : i32, 2 : i32]> | ||
// LLVM: @packed = global [10 x %struct.PackedStruct] zeroinitializer | ||
// LLVM: @packed_element = global ptr getelementptr inbounds ([10 x %struct.PackedStruct], ptr @packed, i32 -2, i32 2) |