Skip to content

Commit 31700c8

Browse files
authored
[CIR] Fix element type for lowering vtt.address_point (#1876)
While upstreaming vtt.address_point lowering, I noticed an important difference in the LLVM IR generated between the CIR path and the OGCG path. We were incorrectly using i8 as the element type for the GEP generated when vtt.address_point is lowered with a value argument. This patch fixes that.
1 parent 9e1dcc2 commit 31700c8

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,7 @@ mlir::LogicalResult CIRToLLVMVTTAddrPointOpLowering::matchAndRewrite(
11971197
}
11981198

11991199
offsets.push_back(adaptor.getOffset());
1200-
eltType = mlir::IntegerType::get(resultType.getContext(), 8,
1201-
mlir::IntegerType::Signless);
1200+
eltType = mlir::LLVM::LLVMPointerType::get(rewriter.getContext());
12021201
} else {
12031202
llvmAddr = getValueForVTableSymbol(op, rewriter, getTypeConverter(),
12041203
op.getNameAttr(), eltType);

clang/test/CIR/CodeGen/vtt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int f() {
7878
// LLVM: %[[VTT:.*]] = load ptr, ptr %[[VTT_ADDR]], align 8
7979
// LLVM: %[[V:.*]] = load ptr, ptr %[[VTT]], align 8
8080
// LLVM: store ptr %[[V]], ptr %[[THIS]], align 8
81-
// LLVM: getelementptr inbounds i8, ptr %[[VTT]], i32 1
81+
// LLVM: getelementptr inbounds ptr, ptr %[[VTT]], i32 1
8282
// LLVM: ret void
8383
// LLVM: }
8484

0 commit comments

Comments
 (0)