当前位置: 首页>>代码示例>>C++>>正文


C++ LLGlobalVariable::isThreadLocal方法代码示例

本文整理汇总了C++中LLGlobalVariable::isThreadLocal方法的典型用法代码示例。如果您正苦于以下问题:C++ LLGlobalVariable::isThreadLocal方法的具体用法?C++ LLGlobalVariable::isThreadLocal怎么用?C++ LLGlobalVariable::isThreadLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LLGlobalVariable的用法示例。


在下文中一共展示了LLGlobalVariable::isThreadLocal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: visit

  void visit(VarDeclaration *decl) override {
    IF_LOG Logger::println("VarDeclaration::codegen(): '%s'",
                           decl->toPrettyChars());
    LOG_SCOPE;

    if (decl->ir->isDefined()) {
      return;
    }

    if (decl->type->ty == Terror) {
      error(decl->loc, "had semantic errors when compiling");
      decl->ir->setDefined();
      return;
    }

    DtoResolveVariable(decl);
    decl->ir->setDefined();

    // just forward aliases
    if (decl->aliassym) {
      Logger::println("alias sym");
      decl->toAlias()->accept(this);
      return;
    }

    // global variable
    if (decl->isDataseg()) {
      Logger::println("data segment");

      assert(!(decl->storage_class & STCmanifest) &&
             "manifest constant being codegen'd!");
      assert(!irs->dcomputetarget);

      IrGlobal *irGlobal = getIrGlobal(decl);
      LLGlobalVariable *gvar = llvm::cast<LLGlobalVariable>(irGlobal->value);
      assert(gvar && "DtoResolveVariable should have created value");

      if (global.params.vtls && gvar->isThreadLocal() &&
          !(decl->storage_class & STCtemp)) {
        const char *p = decl->loc.toChars();
        fprintf(global.stdmsg, "%s: %s is thread local\n", p, decl->toChars());
      }

      // Check if we are defining or just declaring the global in this module.
      // If we reach here during codegen of an available_externally function,
      // new variable declarations should stay external and therefore must not
      // have an initializer.
      if (!(decl->storage_class & STCextern) && !decl->inNonRoot()) {
        // Build the initializer. Might use irGlobal->value!
        LLConstant *initVal =
            DtoConstInitializer(decl->loc, decl->type, decl->_init);

        // Cache it.
        assert(!irGlobal->constInit);
        irGlobal->constInit = initVal;

        // Set the initializer, swapping out the variable if the types do not
        // match.
        irGlobal->value = irs->setGlobalVarInitializer(gvar, initVal);

        // Finalize linkage & DLL storage class.
        const auto lwc = DtoLinkage(decl);
        setLinkage(lwc, gvar);
        if (gvar->hasDLLImportStorageClass()) {
          gvar->setDLLStorageClass(LLGlobalValue::DLLExportStorageClass);
        }

        // Also set up the debug info.
        irs->DBuilder.EmitGlobalVariable(gvar, decl);
      }

      // If this global is used from a naked function, we need to create an
      // artificial "use" for it, or it could be removed by the optimizer if
      // the only reference to it is in inline asm.
      if (irGlobal->nakedUse) {
        irs->usedArray.push_back(gvar);
      }

      IF_LOG Logger::cout() << *gvar << '\n';
    }
  }
开发者ID:redstar,项目名称:ldc,代码行数:81,代码来源:declarations.cpp


注:本文中的LLGlobalVariable::isThreadLocal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。