Issue |
140452
|
Summary |
Invalid assert failure in optimization
|
Labels |
new issue
|
Assignees |
|
Reporter |
pvmoore
|
When creating a small module using the C API the following assertion is triggered when running the optimizer:
(I am using the llvmorg-20.1.5 branch)
Assertion failed: From->getType() == To->getType(), file C:\Temp\llvm-project\llvm\lib\Transforms\Utils\Local.cpp, line 3536
The assertion is NOT triggered when creating the program using the CPP API or when loading from source.
My assumption is that From.getType() and To.getType() should be equal if they are the same Type regardless of whether they have the same pointer address. There is no operator== for Type so this assertion fails even though the types are both i1 in this example. When building the code in a different way the Type addresses are actually the same so the assertion is not triggered but when I use the C API the addresses of the Types are different.
This is the example IR:
```
declare i32 @putchar(i32)
define void @fakeAssert(i32 %0) {
entry:
%"==" = icmp eq i32 %0, 0
br i1 %"==", label %then, label %else
then: ; preds = %entry
%putchar = call i32 @putchar(i32 109)
br label %endif
endif: ; preds = %then, %else
ret void
else: ; preds = %entry
br label %endif
}
define i32 @main() {
entry:
call void @fakeAssert(i32 1)
ret i32 0
}
```
The assertion is triggered if anything is put in the 'then' block. I am just calling putchar but anything else in here will trigger the bug.
I can supply the C API code to generate this if required.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs