| Issue |
71704
|
| Summary |
Miscompile at -O1 and greater
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
meheff
|
Tested at trunk on x86-64. Does not repro at 16.0.6.
Example produces wrong result at -O1 and greater. Repro at -O2:
```
$ llc bad.ll -filetype=obj -o bad.o
$ clang bad.o main.c -o main
$ ./main
0x0
$ opt bad.ll -O2 -S > opt.bad.ll
$ llc opt.bad.ll -filetype=obj -o opt.bad.o
$ clang opt.bad.o main.c -o opt.main
$ ./opt.main
0x1
$ opt -version
LLVM (http://llvm.org/):
LLVM version 18.0.0git
DEBUG build with assertions.
Default target: x86_64-unknown-linux-gnu
Host CPU: skylake-avx512
```
bad.ll
```
; ModuleID = '/tmp/xls_fuzzer_debug.A5ZryC/test.ll'
source_filename = "__module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
define i64 @__sample__main(ptr %_input_ptrs, ptr %_output_ptrs, ptr %_tmp_buffer, ptr %_events, ptr %_user_data, ptr %_runtime, i64 %_continuation_point) {
entry:
%_2 = alloca i8, align 1
%_3 = load ptr, ptr %_input_ptrs, align 8
%_x4.i.i = load i8, ptr %_3, align 1
%_4 = xor i8 %_x4.i.i, -1
%_5 = and i8 %_4, 31
%_6 = and i8 %_5, 15
%_7 = lshr i8 %_5, 1
%_8 = and i8 %_7, 15
store i8 %_8, ptr %_2, align 1
%_9 = load ptr, ptr %_output_ptrs, align 8
%_10 = icmp ne i8 %_6, %_8
store i1 %_10, ptr %_9, align 1
ret i64 0
}
```
main.c
```
#include <stdio.h>
#include <stdint.h>
uint64_t __sample__main(void** input_ptrs, void** output_ptrs, void* tmp_buffer,
void* events, void* user_data,
int64_t continuation_point);
int main (int argc, char** argv) {
uint8_t input0 = 0x0;
void* inputs[1] = {&input0};
uint8_t output0;
void* outputs[1] = {&output0};
__sample__main(inputs, outputs, NULL, NULL, NULL, 0);
printf("0x%x\n", output0);
return 0;
}
```
Found via fuzzing in the XLS project (https://github.com/google/xls)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs