[clang] [llvm] [PowerPC] Fix codegen for transparent_union function params (PR #101738)
Lei Huang via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 6 08:04:35 PDT 2024
lei137 wrote:
> Would it do any harm to just unconditionally compute the type and pass it into getExtend()?
This seem to cause issues for type `_Bool`, where it changes the function param from `i1 noundef zeroext %b1` to `i8 noundef zeroext %b1.coerce`.
```
$cat a.c
void fcall(_Bool);
_Bool test_wc_i1(_Bool b1, _Bool b2) {
_Bool o=b1+b2;
fcall(o);
return o;
}
```
IR changes from:
```
target datalayout = "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64-unknown-linux-gnu"
; Function Attrs: nounwind
define dso_local zeroext i1 @test_wc_i1(i1 noundef zeroext %b1, i1 noundef zeroext %b2) local_unnamed_addr #0 {
entry:
%0 = or i1 %b1, %b2
tail call void @fcall(i1 noundef zeroext %0) #3
ret i1 %0
}
declare void @fcall(i1 noundef zeroext) local_unnamed_addr #1
```
to:
```
target datalayout = "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64-unknown-linux-gnu"
; Function Attrs: nounwind
define dso_local noundef zeroext i1 @test_wc_i1(i8 noundef zeroext %b1.coerce, i8 noundef zeroext %b2.coerce) local_unnamed_addr #0 {
entry:
%0 = or i8 %b2.coerce, %b1.coerce
%1 = and i8 %0, 1
%tobool = icmp ne i8 %1, 0
tail call void @fcall(i8 noundef zeroext %1) #3
ret i1 %tobool
}
declare void @fcall(i8 noundef zeroext) local_unnamed_addr #1
```
This is probably due to the fact I am getting the coerce type via:
```
llvm::Type *CoerceTy = llvm::IntegerType::get(getVMContext(), getContext().getTypeSize(Ty));
```
Not sure if there is a more general way to do this?
https://github.com/llvm/llvm-project/pull/101738
More information about the cfe-commits
mailing list