Skip to content

Commit 6713670

Browse files
committed
[OpenCL] Fix mangling of single-overload builtins
Commit 9a8d477 ("[OpenCL] Add builtin function attribute handling", 2019-11-05) stopped Clang from mangling single-overload builtins, which is incorrect.
1 parent 4821d2a commit 6713670

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Sema/SemaLookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
823823
NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(Context));
824824
if (OpenCLBuiltin.IsConv)
825825
NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(Context));
826-
if ((GenTypeMaxCnt > 1 || Len > 1) && !S.getLangOpts().OpenCLCPlusPlus)
826+
827+
if (!S.getLangOpts().OpenCLCPlusPlus)
827828
NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
828829

829830
LR.addDecl(NewOpenCLBuiltin);

clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ kernel void test_pure_attr(read_only image1d_t img) {
1616
float4 resf = read_imagef(img, 42);
1717
}
1818

19+
// Test that builtins with only one prototype are mangled.
20+
// CHECK-LABEL: @test_mangling
21+
// CHECK: call i32 @_Z12get_local_idj
22+
kernel void test_mangling() {
23+
size_t lid = get_local_id(0);
24+
}
25+
1926
// CHECK: attributes [[ATTR_CONST]] =
2027
// CHECK-SAME: readnone
2128
// CHECK: attributes [[ATTR_PURE]] =

0 commit comments

Comments
 (0)