[llvm-bugs] [Bug 43818] New: UBSan error negating INT64_MIN in AArch64TargetLowering::LowerSELECT_CC
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Oct 26 06:15:53 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43818
Bug ID: 43818
Summary: UBSan error negating INT64_MIN in
AArch64TargetLowering::LowerSELECT_CC
Product: libraries
Version: 9.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: AArch64
Assignee: unassignedbugs at nondot.org
Reporter: andrew at scheidecker.net
CC: arnaud.degrandmaison at arm.com,
llvm-bugs at lists.llvm.org, peter.smith at linaro.org,
Ties.Stuij at arm.com
In a LLVM 9 build with -DLLVM_USE_SANITIZER=Undefined, run:
llc -march=aarch64 repro.ll
where repro.ll contains:
define i64 @0(i1) {
entry:
%1 = select i1 %0, i64 0, i64 -9223372036854775808
ret i64 %1
}
This produces the error:
<snip>/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:4867:29: runtime
error: negation of -9223372036854775808 cannot be represented in type 'int64_t'
(aka 'long'); cast to an unsigned type to negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
<snip>/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:4867:29 in
It looks like the bug is still present in the tip of tree code, though I
haven't tested it. Here's the code in question:
https://github.com/llvm/llvm-project/blob/073ab70b72fa0db7d9c591f77377ef3ce88cc222/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L5076
const int64_t TrueVal = CTVal->getSExtValue();
const int64_t FalseVal = CFVal->getSExtValue();
//<snip>
} else if (TrueVal == -FalseVal) {
^~~~~~~~~
FalseVal is INT64_MIN, and negating it is undefined behavior.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191026/53359c00/attachment.html>
More information about the llvm-bugs
mailing list