New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-simplifycfg -instcombine miscompiles bool, aka i8 !range[0,2) #15265
Comments
As I talked to Duncan, it can be a bug in simplifycfg. InstCombine does the right job as far as !range is valid. |
This causes dragonegg to miscompile DiagnoseLogicalAndInLogicalOrLHS in clang, causing the test clang/test/Sema/parentheses.c to fail. |
test if bugzilla is working |
comment |
I agree that simplifycfg must drop the metadata. |
Fixed in r200322. |
mentioned in issue llvm/llvm-bugzilla-archive#14945 |
Extended Description
target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-redhat-linux"
define zeroext i8 @_Z3BARv() unnamed_addr nounwind uwtable {
entry:
%r = alloca i8, align 1
%tmp = call zeroext i8 @_Z3FOORb(i8* %r) nounwind
%tmp9 = and i8 %tmp, 1
%tmp1 = icmp eq i8 %tmp9, 0
br i1 %tmp1, label %"5", label %"3"
"3": ; preds = %entry
%tmp3 = load i8* %r, align 1, !range !0
%tmp4 = icmp eq i8 %tmp3, 0
br i1 %tmp4, label %"5", label %"7"
"5": ; preds = %"3", %entry
br label %"7"
"7": ; preds = %"3", %"5"
%tmp6 = phi i8 [ 0, %"5" ], [ 1, %"3" ]
call void @llvm.lifetime.end(i64 1, i8* %r)
ret i8 %tmp6
}
declare zeroext i8 @_Z3FOORb(i8*)
declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
!0 = metadata !{i8 0, i8 2}
;========
With -simplifycfg -instcombine,
entry:
%r = alloca i8, align 1
%tmp = call zeroext i8 @_Z3FOORb(i8* %r) nounwind
%tmp9 = and i8 %tmp, 1
%tmp3 = load i8* %r, align 1, !range !0
%0 = xor i8 %tmp9, 1
%1 = xor i8 %tmp3, 1
%2 = or i8 %0, %1
%tmp6 = xor i8 %2, 1
call void @llvm.lifetime.end(i64 1, i8* %r)
ret i8 %tmp6
;====
FYI, this issue was found on gcc47 with dragonegg.
// r is not updated (undef) when return value is false.
// Simplified from clang/lib/Sema/SemaExpr.cpp EvaluatesAsTrue()
extern bool FOO(bool& r);
bool BAR() {
bool r;
return FOO(r) && r;
}
The text was updated successfully, but these errors were encountered: