[cfe-commits] r153723 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/ItaniumCXXABI.cpp test/CodeGenCXX/static-init.cpp

NAKAMURA Takumi geek4civic at gmail.com
Thu Mar 29 22:47:21 PDT 2012


2012/3/30 John McCall <rjmccall at apple.com>:
> Author: rjmccall
> Date: Thu Mar 29 23:25:14 2012
> New Revision: 153723
>
> URL: http://llvm.org/viewvc/llvm-project?rev=153723&view=rev

> ==============================================================================
> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Mar 29 23:25:14 2012
> @@ -1051,7 +1051,7 @@
>  namespace {
>   struct CallGuardAbort : EHScopeStack::Cleanup {
>     llvm::GlobalVariable *Guard;
> -    CallGuardAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {}
> +    CallGuardAbort(llvm::GlobalVariable *guard) : Guard(guard) {}
>
>     void Emit(CodeGenFunction &CGF, Flags flags) {
>       CGF.Builder.CreateCall(getGuardAbortFn(CGF.CGM, Guard->getType()), Guard)
> @@ -1073,35 +1073,54 @@
>   bool threadsafe =
>     (getContext().getLangOpts().ThreadsafeStatics && D.isLocalVarDecl());
>
> -  llvm::IntegerType *GuardTy;
> +  llvm::IntegerType *guardTy;
>
>   // If we have a global variable with internal linkage and thread-safe statics
>   // are disabled, we can just let the guard variable be of type i8.
>   bool useInt8GuardVariable = !threadsafe && GV->hasInternalLinkage();
>   if (useInt8GuardVariable) {
> -    GuardTy = CGF.Int8Ty;
> +    guardTy = CGF.Int8Ty;
>   } else {
>     // Guard variables are 64 bits in the generic ABI and 32 bits on ARM.
> -    GuardTy = (IsARM ? CGF.Int32Ty : CGF.Int64Ty);
> +    guardTy = (IsARM ? CGF.Int32Ty : CGF.Int64Ty);
>   }
> -  llvm::PointerType *GuardPtrTy = GuardTy->getPointerTo();
> +  llvm::PointerType *guardPtrTy = guardTy->getPointerTo();
>
>   // Create the guard variable.
> -  SmallString<256> GuardVName;
> -  llvm::raw_svector_ostream Out(GuardVName);
> -  getMangleContext().mangleItaniumGuardVariable(&D, Out);
> -  Out.flush();
> -
> -  // Just absorb linkage and visibility from the variable.
> -  llvm::GlobalVariable *GuardVariable =
> -    new llvm::GlobalVariable(CGM.getModule(), GuardTy,
> -                             false, GV->getLinkage(),
> -                             llvm::ConstantInt::get(GuardTy, 0),
> -                             GuardVName.str());
> -  GuardVariable->setVisibility(GV->getVisibility());
> +  SmallString<256> guardName;
> +  {
> +    llvm::raw_svector_ostream out(guardName);
> +    getMangleContext().mangleItaniumGuardVariable(&D, out);
> +    out.flush();
> +  }
> +
> +  // There are strange possibilities here involving the
> +  // double-emission of constructors and destructors.
> +  llvm::GlobalVariable *guard = nullptr;

I think we should not use nullptr for now. Fixed in r153728.

...Takumi




More information about the cfe-commits mailing list