[clang] 6713670 - [OpenCL] Fix mangling of single-overload builtins

Sven van Haastregt via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 3 03:11:17 PST 2019


Author: Sven van Haastregt
Date: 2019-12-03T11:09:16Z
New Revision: 6713670b17324b81cc457f3a37dbc8c1ee229b88

URL: https://github.com/llvm/llvm-project/commit/6713670b17324b81cc457f3a37dbc8c1ee229b88
DIFF: https://github.com/llvm/llvm-project/commit/6713670b17324b81cc457f3a37dbc8c1ee229b88.diff

LOG: [OpenCL] Fix mangling of single-overload builtins

Commit 9a8d477a0e0 ("[OpenCL] Add builtin function attribute
handling", 2019-11-05) stopped Clang from mangling single-overload
builtins, which is incorrect.

Added: 
    

Modified: 
    clang/lib/Sema/SemaLookup.cpp
    clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index df817e6bcef1..d9b6cb6a9215 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -823,7 +823,8 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
         NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(Context));
       if (OpenCLBuiltin.IsConv)
         NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(Context));
-      if ((GenTypeMaxCnt > 1 || Len > 1) && !S.getLangOpts().OpenCLCPlusPlus)
+
+      if (!S.getLangOpts().OpenCLCPlusPlus)
         NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
 
       LR.addDecl(NewOpenCLBuiltin);

diff  --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
index 7e3186b18615..64f2d89c5818 100644
--- a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
@@ -16,6 +16,13 @@ kernel void test_pure_attr(read_only image1d_t img) {
   float4 resf = read_imagef(img, 42);
 }
 
+// Test that builtins with only one prototype are mangled.
+// CHECK-LABEL: @test_mangling
+// CHECK: call i32 @_Z12get_local_idj
+kernel void test_mangling() {
+  size_t lid = get_local_id(0);
+}
+
 // CHECK: attributes [[ATTR_CONST]] =
 // CHECK-SAME: readnone
 // CHECK: attributes [[ATTR_PURE]] =


        


More information about the cfe-commits mailing list