[PATCH] D64592: [OpenMP] Fix target link implementation

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 09:26:28 PDT 2019


ABataev added inline comments.


================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2589
                HasRequiresUnifiedSharedMemory))) {
+    llvm::GlobalValue::LinkageTypes GlobalVarLinkage =
+          CGM.getLLVMLinkageVarDefinition(VD, false);
----------------
Currently, I think, it would better to use `isExternallyVisible()` member function of `VD` variable.


================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2612-2614
       if (!CGM.getLangOpts().OpenMPIsDevice) {
-        auto *GV = cast<llvm::GlobalVariable>(Ptr);
-        GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
         GV->setInitializer(CGM.GetAddrOfGlobal(VD));
       }
----------------
Remove braces


================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2615
       }
       CGM.addUsedGlobal(cast<llvm::GlobalValue>(Ptr));
       registerTargetGlobalVariable(VD, cast<llvm::Constant>(Ptr));
----------------
Remove this, it is not required anymore since the pointers have weakany linkage


================
Comment at: test/OpenMP/declare_target_codegen.cpp:23
 // CHECK-DAG: @ddd ={{ dso_local | }}global i32 0,
-// CHECK-DAG: @hhh_decl_tgt_ref_ptr = common global i32* null
-// CHECK-DAG: @ggg_decl_tgt_ref_ptr = common global i32* null
-// CHECK-DAG: @fff_decl_tgt_ref_ptr = common global i32* null
-// CHECK-DAG: @eee_decl_tgt_ref_ptr = common global i32* null
+// CHECK-DAG: @hhh_0_decl_tgt_ref_ptr = weak global i32* null
+// CHECK-DAG: @ggg_0_decl_tgt_ref_ptr = weak global i32* null
----------------
I would not rely on the fact that the `FileId` is always `0`


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592





More information about the cfe-commits mailing list