error in backend: Cannot select: crash compiling pmcstat.c
brooksdavis opened this issue · 2 comments
brooksdavis commented
/home/bed22/git/llvm-cheri/Build/bin/clang -g -integrated-as --target=cheri-unknown-freebsd -msoft-float --sysroot=/home/bed22/obj/mips.mips64/home/bed22/git/cheribsd/tmp -Wno-deprecated-declarations -mabi=purecap -mxgot -fpic -O -pipe -G0 -EB -msoft-float -O2 -ftls-model=local-exec -D__LP64__=1 -g -MD -MF.depend.pmcstat.o -MTpmcstat.o -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments -c pmcstat.c -o pmcstat.o
fatal error: error in backend: Cannot select: 0x80685cd00: f64 = fmul
0x8068b9208, 0x8068bf138
0x8068b9208: f64,ch = load<LD8[getelementptr inbounds (%struct.pmcstat_args, %struct.pmcstat_args addrspace(200)* @args, i64 0, i32 16)(addrspace=200)](tbaa=<0x805b771c8>)(dereferenceable)> 0x80683b430, 0x8068bf1a0, undef:iFATPTR
0x8068bf1a0: iFATPTR = PTRADD 0x80685cf70, Constant:i64<360>
0x80685cf70: iFATPTR = llvm.cheri.cap.bounds.set Constant:i64<10>, 0x8068b90d0, 0x8068bf8f0
0x8068bb4e0: i64 = Constant<10>
0x8068b90d0: iFATPTR = INTTOPTR 0x8068c1340
0x8068c1340: i64,ch = load<LD8[GOT]> 0x80683b430, 0x8068eb5b0, undef:i64
0x8068eb5b0: i64 = MipsISD::Wrapper 0x8068bf618, TargetGlobalAddress:i64<%struct.pmcstat_args addrspace(200)* @args> 0 [TF=21]
0x8068bf618: i64 = add 0x8068c8208, Register:i64 %vreg169
0x8068c8208: i64 = MipsISD::GotHi TargetGlobalAddress:i64<%struct.pmcstat_args addrspace(200)* @args> 0 [TF=20]
0x8068c82d8: i64 = TargetGlobalAddress<%struct.pmcstat_args addrspace(200)* @args> 0 [TF=20]
0x8068b9f70: i64 = Register %vreg169
0x8068bf068: i64 = TargetGlobalAddress<%struct.pmcstat_args addrspace(200)* @args> 0 [TF=21]
0x8068e7bc8: i64 = undef
0x8068bf8f0: i64,ch = load<LD8[@.size.args]> 0x80683b430, 0x8068c8000, undef:i64
0x8068c8000: i64,ch = load<LD8[GOT]> 0x80683b430, 0x8068c4af8, undef:i64
0x8068c4af8: i64 = MipsISD::Wrapper 0x8068bb068, TargetGlobalAddress:i64<i64* @.size.args> 0 [TF=21]
0x8068bb068: i64 = add 0x8068bbd68, Register:i64 %vreg169
0x8068bbd68: i64 = MipsISD::GotHi TargetGlobalAddress:i64<i64* @.size.args> 0 [TF=20]
0x8068c18f0: i64 = TargetGlobalAddress<i64* @.size.args> 0 [TF=20]
0x8068b9f70: i64 = Register %vreg169
0x8068c85b0: i64 = TargetGlobalAddress<i64* @.size.args> 0 [TF=21]
0x8068e7bc8: i64 = undef
0x8068e7bc8: i64 = undef
0x8068c1680: i64 = Constant<360>
0x80676a4e0: iFATPTR = undef
0x8068bf138: f64,ch = load<LD8[ConstantPool]> 0x80683b430, 0x80676abc8, undef:i64
0x80676abc8: i64 = add 0x8068c8068, 0x8068bb820
0x8068c8068: i64,ch = load<LD8[GOT]> 0x80683b430, 0x8068c8410, undef:i64
0x8068c8410: i64 = MipsISD::Wrapper Register:i64 %vreg169, TargetConstantPool:i64<double 1.000000e+03> 0 [TF=16]
0x8068b9f70: i64 = Register %vreg169
0x8068bf2d8: i64 = TargetConstantPool<double 1.000000e+03> 0 [TF=16]
0x8068e7bc8: i64 = undef
0x8068bb820: i64 = MipsISD::Lo TargetConstantPool:i64<double 1.000000e+03> 0 [TF=17]
0x8068e7000: i64 = TargetConstantPool<double 1.000000e+03> 0 [TF=17]
0x8068e7bc8: i64 = undef
In function: main
clang-3.8: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 5.0.0 (https://github.com/llvm-mirror/clang.git 208013d8b6b7ab8d3e40a31a084e643193ee6dbc) (https://github.com/llvm-mirror/llvm.git 569c8baef2eab52799a451a0410b3e66901b56f7)
Target: cheri-unknown-freebsd
Thread model: posix
InstalledDir: /home/bed22/git/llvm-cheri/Build/bin
clang-3.8: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.8: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.8: note: diagnostic msg: /tmp/pmcstat-5918e4.c
clang-3.8: note: diagnostic msg: /tmp/pmcstat-5918e4.sh
clang-3.8: note: diagnostic msg:
********************
*** Error code 70
reproducers:
https://gist.github.com/brooksdavis/0e7001008550022c047b2f6054c0ee6f
arichardson commented
Reduced test case using creduce (which for some reason ends up in an infinite size increasing loop after this stage):
typedef __intcap_t __intptr_t;
#define EV_SET(kevp_, a, b, c, d, e, f) { struct kevent *kevp = kevp_; kevp->data = e; } 0
struct kevent {
__intptr_t data;
};
int getopt(int, char *[], const char *);
struct {
double pa_duration;
}
args ;
struct kevent main_kev;
int main(int argc, char **argv) {
if (getopt(argc, argv, "CDEFGMNOPRSTWacdefgklmnopqrstvwz")) EV_SET(&main_kev, , , , , args.pa_duration , );
}
arichardson commented
This happens when assigning floating point values to __intcap_t. Minimal test case:
void test(void) {
double d = 1234.5678;
__intcap_t cap = d;
}
Maybe we should just make this an error? If we assign a double to a void* we get error: initializing 'void * __capability' with an expression of incompatible type 'double'
. However this might cause code that stores double values in uintptr_t break. If we agree that casting to uint64_t before storing doubles in a uintptr_t is required I'll make that change.