If the memory object is scalable type, we do not know the exact size of
it at compile time. Set the size of lifetime marker to unknown if the
object is scalable one.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp | ||
---|---|---|
4 | Probably best to add -disable-llvm-passes so we don't run the optimizer. | |
9 | Are the templates needed? This was enough to fail for me vint32m1_t Baz(); vint32m1_t Test() { const vint32m1_t &a = Baz(); return a; } Or do the templates test additional code paths? |
clang/lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1327 | Instead of updating Size here, can you change line 1332 to be: llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue()) | |
1328 | Does ConstantInt take TypeSize Size as argument? | |
1554 | nit: Given you have to update this line, maybe also to capitalize size -> Size? |
clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp | ||
---|---|---|
4 | nit: Does -O1 still have any effect if -disable-llvm-passes is also set? | |
18 | nit: I'm not sure if there is any policy on this, but for this test you can just as well have 6 CHECK lines, instead of auto-generating all of them, which makes the test a bit easier to read. // CHECK-LABEL: @_Z4Testv // CHECK-NEXT: [[ALLOCA:%.*]] = alloca <vscale x 2 x i32>, align 4 // CHECK-NEXT: [[BC1:%.*]] = bitcast <vscale x 2 x i32>* [[ALLOCA]] to i8* // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 -1, i8* [[BC1]]) // CHECK-NEXT: [[BC2:%.*]] = bitcast <vscale x 2 x i32>* [[ALLOCA]] to i8* // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 -1, i8* [[BC2]]) |
clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp | ||
---|---|---|
4 | Lifetime markers aren't emitted with -O0. |
LGTM, thanks @HsiangKai
clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp | ||
---|---|---|
4 | I didn't know that, thanks! |
clang-format suggested style edits found: