r209876 - [OPENMP] Improve debug location codegen for OpenMP runtime library.

Alexey Bataev a.bataev at hotmail.com
Thu May 29 22:48:40 PDT 2014


Author: abataev
Date: Fri May 30 00:48:40 2014
New Revision: 209876

URL: http://llvm.org/viewvc/llvm-project?rev=209876&view=rev
Log:
[OPENMP] Improve debug location codegen for OpenMP runtime library.

Modified:
    cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
    cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=209876&r1=209875&r2=209876&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri May 30 00:48:40 2014
@@ -57,9 +57,10 @@ CGOpenMPRuntime::GetOrCreateDefaultOpenM
     DefaultOpenMPLocation->setLinkage(llvm::GlobalValue::PrivateLinkage);
 
     llvm::Constant *Zero = llvm::ConstantInt::get(CGM.Int32Ty, 0, true);
-    llvm::Constant *Values[] = { Zero,
-                                 llvm::ConstantInt::get(CGM.Int32Ty, Flags),
-                                 Zero, Zero, DefaultOpenMPPSource };
+    llvm::Constant *Values[] = {
+      Zero, llvm::ConstantInt::get(CGM.Int32Ty, Flags), Zero,
+      Zero, DefaultOpenMPPSource
+    };
     llvm::Constant *Init = llvm::ConstantStruct::get(IdentTy, Values);
     DefaultOpenMPLocation->setInitializer(Init);
     return DefaultOpenMPLocation;
@@ -98,19 +99,24 @@ llvm::Value *CGOpenMPRuntime::EmitOpenMP
   llvm::Value *PSource =
       CGF.Builder.CreateConstInBoundsGEP2_32(LocValue, 0, IdentField_PSource);
 
-  SmallString<128> Buffer2;
-  llvm::raw_svector_ostream OS2(Buffer2);
-  // Build debug location
-  PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
-  OS2 << ";" << PLoc.getFilename() << ";";
-  if (const FunctionDecl *FD =
-          dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl)) {
-    OS2 << FD->getQualifiedNameAsString();
+  auto OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
+  if (OMPDebugLoc == nullptr) {
+    SmallString<128> Buffer2;
+    llvm::raw_svector_ostream OS2(Buffer2);
+    // Build debug location
+    PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
+    OS2 << ";" << PLoc.getFilename() << ";";
+    if (const FunctionDecl *FD =
+            dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl)) {
+      OS2 << FD->getQualifiedNameAsString();
+    }
+    OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
+    OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
+    OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
   }
-  OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
   // *psource = ";<File>;<Function>;<Line>;<Column>;;";
-  CGF.Builder.CreateStore(CGF.Builder.CreateGlobalStringPtr(OS2.str()),
-                          PSource);
+  CGF.Builder.CreateStore(OMPDebugLoc, PSource);
+
   return LocValue;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=209876&r1=209875&r2=209876&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Fri May 30 00:48:40 2014
@@ -121,6 +121,9 @@ private:
     IdentField_PSource
   };
   llvm::StructType *IdentTy;
+  /// \brief Map for Sourcelocation and OpenMP runtime library debug locations.
+  typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
+  OpenMPDebugLocMapTy OpenMPDebugLocMap;
   /// \brief The type for a microtask which gets passed to __kmpc_fork_call().
   /// Original representation is:
   /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...);





More information about the cfe-commits mailing list