Skip to content

Commit a4eefe4

Browse files
MrSidimsvmaksimo
authored andcommitted
[SYCL] Fix FPGA built-ins/mem attrs after https://reviews.llvm.org/D88645
Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent fd070d4 commit a4eefe4

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,14 @@ llvm::Value *CodeGenFunction::EmitAnnotationCall(llvm::Function *AnnotationFn,
23212321
};
23222322
if (Attr)
23232323
Args.push_back(CGM.EmitAnnotationArgs(Attr));
2324+
else {
2325+
assert(AnnotationFn->isIntrinsic() &&
2326+
"Annotation call must be an intrinsic");
2327+
const llvm::Intrinsic::ID ID = AnnotationFn->getIntrinsicID();
2328+
if (ID == llvm::Intrinsic::ptr_annotation ||
2329+
ID == llvm::Intrinsic::var_annotation)
2330+
Args.push_back(llvm::ConstantPointerNull::get(Int8PtrTy));
2331+
}
23242332
return Builder.CreateCall(AnnotationFn, Args);
23252333
}
23262334

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,10 +4286,11 @@ void CodeGenModule::addGlobalIntelFPGAAnnotation(const VarDecl *VD,
42864286
GV, GV->getValueType()->getPointerTo(0));
42874287

42884288
// Create the ConstantStruct for the global annotation.
4289-
llvm::Constant *Fields[4] = {
4289+
llvm::Constant *Fields[5] = {
42904290
llvm::ConstantExpr::getBitCast(ASZeroGV, Int8PtrTy),
42914291
llvm::ConstantExpr::getBitCast(AnnoGV, Int8PtrTy),
4292-
llvm::ConstantExpr::getBitCast(UnitGV, Int8PtrTy), LineNoCst};
4292+
llvm::ConstantExpr::getBitCast(UnitGV, Int8PtrTy), LineNoCst,
4293+
llvm::ConstantPointerNull::get(Int8PtrTy)};
42934294
Annotations.push_back(llvm::ConstantStruct::getAnon(Fields));
42944295
}
42954296
}

clang/test/CodeGenCXX/attr-annotate.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,13 @@ static B<int long, -1>::foo<unsigned, 9> gf;
5151
// CHECK-NEXT: store i8** [[ARGV:%.*]], i8*** [[ARGV_ADDR]], align 8
5252
// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARGC_ADDR]], align 4
5353
// CHECK-NEXT: [[V:%.*]] = getelementptr inbounds %"struct.B<int, 7>::foo", %"struct.B<int, 7>::foo"* [[F]], i32 0, i32 0
54-
// CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[V]] to i8*
55-
// CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* [[TMP1]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i8*, i32, i32 }* @.args to i8*))
56-
// CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32*
57-
// CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[TMP3]] to i8*
58-
// CHECK-NEXT: [[TMP5:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* [[TMP4]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i32 }* @.args.4 to i8*))
59-
// CHECK-NEXT: [[TMP6:%.*]] = bitcast i8* [[TMP5]] to i32*
60-
// CHECK-NEXT: store i32 [[TMP0]], i32* [[TMP6]], align 4
54+
// CHECK-NEXT: [[TMP2:%.*]] = call i32* @llvm.ptr.annotation.p0i32(i32* [[V]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i8*, i32, i32 }* @.args to i8*))
55+
// CHECK-NEXT: [[TMP5:%.*]] = call i32* @llvm.ptr.annotation.p0i32(i32* [[TMP2]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i32 }* @.args.4 to i8*))
56+
// CHECK-NEXT: store i32 [[TMP0]], i32* [[TMP5]], align 4
6157
// CHECK-NEXT: [[TMP7:%.*]] = load i32, i32* [[ARGC_ADDR]], align 4
62-
// CHECK-NEXT: [[TMP8:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* bitcast (%"struct.B<long, -1>::foo"* @_ZL2gf to i8*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i8*, i32, i64 }* @.args.5 to i8*))
63-
// CHECK-NEXT: [[TMP9:%.*]] = bitcast i8* [[TMP8]] to i32*
64-
// CHECK-NEXT: [[TMP10:%.*]] = bitcast i32* [[TMP9]] to i8*
65-
// CHECK-NEXT: [[TMP11:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* [[TMP10]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i32 }* @.args.4 to i8*))
66-
// CHECK-NEXT: [[TMP12:%.*]] = bitcast i8* [[TMP11]] to i32*
67-
// CHECK-NEXT: store i32 [[TMP7]], i32* [[TMP12]], align 4
58+
// CHECK-NEXT: [[TMP8:%.*]] = call i32* @llvm.ptr.annotation.p0i32(i32* getelementptr inbounds (%"struct.B<long, -1>::foo", %"struct.B<long, -1>::foo"* @_ZL2gf, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i8*, i32, i64 }* @.args.5 to i8*))
59+
// CHECK-NEXT: [[TMP11:%.*]] = call i32* @llvm.ptr.annotation.p0i32(i32* [[TMP8]], i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* @.str.1, i32 0, i32 0), i32 {{.*}}, i8* bitcast ({ i32 }* @.args.4 to i8*))
60+
// CHECK-NEXT: store i32 [[TMP7]], i32* [[TMP11]], align 4
6861
// CHECK-NEXT: ret i32 0
6962
//
7063
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)