[Attributor] Replace noundef value with undef
| Bugzilla Link | 49104 |
| Resolution | FIXED |
| Resolved on | Feb 09, 2021 11:13 |
| Version | trunk |
| OS | All |
| CC | @fhahn,@jdoerfert |
| Fixed by commit(s) | 81429abd83362f4c3eecbed41ebc917ddf26b13f |
Extended Description
Here is the reduced IR: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu"
%struct.hash_table = type { %struct.hash_node*, i64, i64, i64 } %struct.hash_node = type { i64, i8*, i64, i8* } %union.label = type { %struct.anon } %struct.anon = type { i32, i32, i64, i64, i64, i64, i8*, i8*, i8*, i8*, i32, i32, i32 }
@ltab = external dso_local global %struct.hash_table, align 8
define hidden i32 @lookup_label() { entry: br label %if.end
if.end: ; preds = %entry %call = call %union.label* @find_label(i1 false) ret i32 undef }
; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0
define internal %union.label* @find_label(i1 %create) { entry: %create.addr = alloca i8, align 1 %frombool = zext i1 %create to i8 store i8 %frombool, i8* %create.addr, align 1 br label %cond.true
cond.true: ; preds = %entry br label %cond.end
cond.end: ; preds = %cond.true br i1 undef, label %if.then, label %lor.lhs.false
lor.lhs.false: ; preds = %cond.end %0 = load i8, i8* %create.addr, align 1, !range !0 %tobool2 = trunc i8 %0 to i1 br i1 %tobool2, label %if.end, label %if.then
if.then: ; preds = %lor.lhs.false, %cond.end ret %union.label* undef
if.end: ; preds = %lor.lhs.false br label %if.then3
if.then3: ; preds = %if.end %call4 = call i8* @nasm_malloc(i64 11264) ret %union.label* undef }
; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #0
define hidden i1 @declare_label() { entry: %call = call %union.label* @find_label(i1 true) store %union.label* %call, %union.label** undef, align 8 ret i1 undef }
declare hidden i32 @init_labels()
declare i8* @nasm_malloc(i64)
declare dso_local void @init_block()
; Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #1
declare i8** @hash_find()
; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0
attributes #0 = { argmemonly nofree nosync nounwind willreturn } attributes #1 = { argmemonly nofree nosync nounwind willreturn writeonly }
!0 = !{i8 0, i8 2}
commands: opt -O2 --attributor-enable=cgscc reduced.ll
Debug dumpping shows: [Attributor] Delete at least 0 functions and 0 blocks and 0 instructions and 2 uses Use i1 undef in call fastcc void @find_label(i1 noundef true) instead of i1 true Use i1 true in br i1 %create, label %if.then3, label %if.then instead of i1 %create
Thanks for the quick fix.
Fixed by 81429abd83362f4c3eecbed41ebc917ddf26b13f
I looked at this. The problem is we don't really want to modify the callee signature during a SCC traversal when we look at the caller. If I allow function signature replacement all is good, except that the SCC traversal might break.
I have a fix but no reproducer. I will try again tomorrow and if not push the fix on it's own.