[llvm-branch-commits] [cfe-branch] r348684 - Merging r345838:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 7 20:54:25 PST 2018


Author: tstellar
Date: Fri Dec  7 20:54:24 2018
New Revision: 348684

URL: http://llvm.org/viewvc/llvm-project?rev=348684&view=rev
Log:
Merging r345838:

------------------------------------------------------------------------
r345838 | erichkeane | 2018-11-01 08:11:41 -0700 (Thu, 01 Nov 2018) | 8 lines

CPU-Dispatch- Fix type of a member function, prevent deferrals

The member type creation for a cpu-dispatch function was not correctly
including the 'this' parameter, so ensure that the type is properly
determined. Also, disable defer in the cases of emitting the functoins,
as it can end up resulting in the wrong version being emitted.

Change-Id: I0b8fc5e0b0d1ae1a9d98fd54f35f27f6e5d5d083
------------------------------------------------------------------------

Added:
    cfe/branches/release_70/test/CodeGenCXX/attr-cpuspecific.cpp
Modified:
    cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp?rev=348684&r1=348683&r2=348684&view=diff
==============================================================================
--- cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp Fri Dec  7 20:54:24 2018
@@ -2467,7 +2467,13 @@ void CodeGenModule::emitCPUDispatchDefin
   assert(FD && "Not a FunctionDecl?");
   const auto *DD = FD->getAttr<CPUDispatchAttr>();
   assert(DD && "Not a cpu_dispatch Function?");
-  llvm::Type *DeclTy = getTypes().ConvertTypeForMem(FD->getType());
+  QualType CanonTy = Context.getCanonicalType(FD->getType());
+  llvm::Type *DeclTy = getTypes().ConvertFunctionType(CanonTy, FD);
+
+  if (const auto *CXXFD = dyn_cast<CXXMethodDecl>(FD)) {
+    const CGFunctionInfo &FInfo = getTypes().arrangeCXXMethodDeclaration(CXXFD);
+    DeclTy = getTypes().GetFunctionType(FInfo);
+  }
 
   StringRef ResolverName = getMangledName(GD);
   llvm::Type *ResolverType = llvm::FunctionType::get(
@@ -2485,7 +2491,7 @@ void CodeGenModule::emitCPUDispatchDefin
     std::string MangledName = getMangledNameImpl(*this, GD, FD, true) +
                               getCPUSpecificMangling(*this, II->getName());
     llvm::Constant *Func = GetOrCreateLLVMFunction(
-        MangledName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/false,
+        MangledName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,
         /*IsThunk=*/false, llvm::AttributeList(), ForDefinition);
     llvm::SmallVector<StringRef, 32> Features;
     Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features);

Added: cfe/branches/release_70/test/CodeGenCXX/attr-cpuspecific.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/test/CodeGenCXX/attr-cpuspecific.cpp?rev=348684&view=auto
==============================================================================
--- cfe/branches/release_70/test/CodeGenCXX/attr-cpuspecific.cpp (added)
+++ cfe/branches/release_70/test/CodeGenCXX/attr-cpuspecific.cpp Fri Dec  7 20:54:24 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LINUX
+
+struct S {
+  __attribute__((cpu_specific(atom)))
+  void Func(){}
+  __attribute__((cpu_dispatch(ivybridge,atom)))
+  void Func(){}
+};
+
+void foo() {
+  S s;
+  s.Func();
+}
+
+// LINUX: define void (%struct.S*)* @_ZN1S4FuncEv.resolver
+// LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.S
+// LINUX: ret void (%struct.S*)* @_ZN1S4FuncEv.O




More information about the llvm-branch-commits mailing list