<div dir="ltr">It looks like the wrong patch got committed with the original description of <span class="" style="font-size:12.8px"><a href="http://reviews.llvm.org/D14954" rel="noreferrer" target="_blank" style="font-size:12.8px">D14954</a>. I reverted it in r254823.</span><div><span class="" style="font-size:12.8px"><br></span></div><div><span class="" style="font-size:12.8px">Feel free to commit the header change, it looks fine.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 27, 2015 at 5:57 AM, Hal Finkel via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Andrey,<br>
<br>
This commit does not seem to match the description. What is it doing?<br>
<br>
Thanks again,<br>
Hal<br>
<div class="HOEnZb"><div class="h5"><br>
----- Original Message -----<br>
> From: "Andrey Bokhanko via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>><br>
> To: <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> Sent: Friday, November 27, 2015 6:18:23 AM<br>
> Subject: r254195 - [x86] Exclusion of incorrect include headers paths for MCU target<br>
><br>
> Author: asbokhan<br>
> Date: Fri Nov 27 06:18:22 2015<br>
> New Revision: 254195<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=254195&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=254195&view=rev</a><br>
> Log:<br>
> [x86] Exclusion of incorrect include headers paths for MCU target<br>
><br>
> Exclusion of /usr/include and /usr/local/include headers paths for<br>
> MCU target.<br>
><br>
> Differential Revision: <a href="http://reviews.llvm.org/D14954" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14954</a><br>
><br>
> Modified:<br>
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=254195&r1=254194&r2=254195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=254195&r1=254194&r2=254195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov 27 06:18:22 2015<br>
> @@ -1178,12 +1178,7 @@ void CodeGenModule::EmitDeferred() {<br>
> // to get GlobalValue with exactly the type we need, not<br>
> something that<br>
> // might had been created for another decl with the same mangled<br>
> name but<br>
> // different type.<br>
> - // FIXME: Support for variables is not implemented yet.<br>
> - if (isa<FunctionDecl>(D.getDecl()))<br>
> - GV = cast<llvm::GlobalValue>(GetAddrOfGlobal(D,<br>
> /*IsForDefinition=*/true));<br>
> - else<br>
> - if (!GV)<br>
> - GV = GetGlobalValue(getMangledName(D));<br>
> + GV = cast<llvm::GlobalValue>(GetAddrOfGlobal(D,<br>
> /*IsForDefinition=*/true));<br>
><br>
> // Check to see if we've already emitted this. This is<br>
> necessary<br>
> // for a couple of reasons: first, decls can end up in the<br>
> @@ -1693,8 +1688,8 @@ CodeGenModule::GetOrCreateLLVMFunction(S<br>
> // error.<br>
> if (IsForDefinition && !Entry->isDeclaration()) {<br>
> GlobalDecl OtherGD;<br>
> - // Check that GD is not yet in ExplicitDefinitions is required<br>
> to make<br>
> - // sure that we issue an error only once.<br>
> + // Check that GD is not yet in DiagnosedConflictingDefinitions<br>
> is required<br>
> + // to make sure that we issue an error only once.<br>
> if (lookupRepresentativeDecl(MangledName, OtherGD) &&<br>
> (GD.getCanonicalDecl().getDecl() !=<br>
> OtherGD.getCanonicalDecl().getDecl()) &&<br>
> @@ -1904,7 +1899,8 @@ bool CodeGenModule::isTypeConstant(QualT<br>
> llvm::Constant *<br>
> CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,<br>
> llvm::PointerType *Ty,<br>
> - const VarDecl *D) {<br>
> + const VarDecl *D,<br>
> + bool IsForDefinition) {<br>
> // Lookup the entry, lazily creating it if necessary.<br>
> llvm::GlobalValue *Entry = GetGlobalValue(MangledName);<br>
> if (Entry) {<br>
> @@ -1920,11 +1916,31 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str<br>
> if (Entry->getType() == Ty)<br>
> return Entry;<br>
><br>
> + // If there are two attempts to define the same mangled name,<br>
> issue an<br>
> + // error.<br>
> + if (IsForDefinition && !Entry->isDeclaration()) {<br>
> + GlobalDecl OtherGD;<br>
> + // Check that D is not yet in DiagnosedConflictingDefinitions<br>
> is required<br>
> + // to make sure that we issue an error only once.<br>
> + if (lookupRepresentativeDecl(MangledName, OtherGD) &&<br>
> + (D->getCanonicalDecl() !=<br>
> OtherGD.getCanonicalDecl().getDecl()) &&<br>
> + DiagnosedConflictingDefinitions.insert(D).second) {<br>
> + getDiags().Report(D->getLocation(),<br>
> + diag::err_duplicate_mangled_name);<br>
> + getDiags().Report(OtherGD.getDecl()->getLocation(),<br>
> + diag::note_previous_definition);<br>
> + }<br>
> + }<br>
> +<br>
> // Make sure the result is of the correct type.<br>
> if (Entry->getType()->getAddressSpace() !=<br>
> Ty->getAddressSpace())<br>
> return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);<br>
><br>
> - return llvm::ConstantExpr::getBitCast(Entry, Ty);<br>
> + // Make sure the result is of the correct type.<br>
> + // (If global is requested for a definition, we always need to<br>
> create a new<br>
> + // global, not just return a bitcast.)<br>
> + if (!IsForDefinition)<br>
> + return llvm::ConstantExpr::getBitCast(Entry, Ty);<br>
> }<br>
><br>
> unsigned AddrSpace = GetGlobalVarAddressSpace(D,<br>
> Ty->getAddressSpace());<br>
> @@ -1933,6 +1949,20 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str<br>
> llvm::GlobalValue::ExternalLinkage, nullptr, MangledName,<br>
> nullptr,<br>
> llvm::GlobalVariable::NotThreadLocal, AddrSpace);<br>
><br>
> + // If we already created a global with the same mangled name (but<br>
> different<br>
> + // type) before, take its name and remove it from its parent.<br>
> + if (Entry) {<br>
> + GV->takeName(Entry);<br>
> +<br>
> + if (!Entry->use_empty()) {<br>
> + llvm::Constant *NewPtrForOldDecl =<br>
> + llvm::ConstantExpr::getBitCast(GV, Entry->getType());<br>
> + Entry->replaceAllUsesWith(NewPtrForOldDecl);<br>
> + }<br>
> +<br>
> + Entry->eraseFromParent();<br>
> + }<br>
> +<br>
> // This is the first use or definition of a mangled name. If<br>
> there is a<br>
> // deferred decl with this name, remember that we need to emit it<br>
> at the end<br>
> // of the file.<br>
> @@ -2005,7 +2035,8 @@ CodeGenModule::GetAddrOfGlobal(GlobalDec<br>
> return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false,<br>
> /*DontDefer=*/false,<br>
> IsForDefinition);<br>
> } else<br>
> - return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()));<br>
> + return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()),<br>
> /*Ty=*/nullptr,<br>
> + IsForDefinition);<br>
> }<br>
><br>
> llvm::GlobalVariable *<br>
> @@ -2055,7 +2086,8 @@ CodeGenModule::CreateOrReplaceCXXRuntime<br>
> /// then it will be created with the specified type instead of<br>
> whatever the<br>
> /// normal requested type would be.<br>
> llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,<br>
> - llvm::Type *Ty) {<br>
> + llvm::Type *Ty,<br>
> + bool<br>
> IsForDefinition) {<br>
> assert(D->hasGlobalStorage() && "Not a global variable");<br>
> QualType ASTTy = D->getType();<br>
> if (!Ty)<br>
> @@ -2065,7 +2097,7 @@ llvm::Constant *CodeGenModule::GetAddrOf<br>
> llvm::PointerType::get(Ty,<br>
> getContext().getTargetAddressSpace(ASTTy));<br>
><br>
> StringRef MangledName = getMangledName(D);<br>
> - return GetOrCreateLLVMGlobal(MangledName, PTy, D);<br>
> + return GetOrCreateLLVMGlobal(MangledName, PTy, D,<br>
> IsForDefinition);<br>
> }<br>
><br>
> /// CreateRuntimeVariable - Create a new runtime global variable<br>
> with the<br>
> @@ -2091,7 +2123,7 @@ void CodeGenModule::EmitTentativeDefinit<br>
> }<br>
><br>
> // The tentative definition is the only definition.<br>
> - EmitGlobalVarDefinition(D);<br>
> + EmitGlobalVarDefinition(D, true);<br>
> }<br>
><br>
> CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty)<br>
> const {<br>
> @@ -2178,7 +2210,8 @@ void CodeGenModule::maybeSetTrivialComda<br>
> GO.setComdat(TheModule.getOrInsertComdat(GO.getName()));<br>
> }<br>
><br>
> -void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {<br>
> +void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,<br>
> + bool IsTentative) {<br>
> llvm::Constant *Init = nullptr;<br>
> QualType ASTTy = D->getType();<br>
> CXXRecordDecl *RD =<br>
> ASTTy->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();<br>
> @@ -2237,7 +2270,8 @@ void CodeGenModule::EmitGlobalVarDefinit<br>
> }<br>
><br>
> llvm::Type* InitType = Init->getType();<br>
> - llvm::Constant *Entry = GetAddrOfGlobalVar(D, InitType);<br>
> + llvm::Constant *Entry =<br>
> + GetAddrOfGlobalVar(D, InitType,<br>
> /*IsForDefinition=*/!IsTentative);<br>
><br>
> // Strip off a bitcast if we got one back.<br>
> if (auto *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {<br>
> @@ -2269,7 +2303,8 @@ void CodeGenModule::EmitGlobalVarDefinit<br>
> Entry->setName(StringRef());<br>
><br>
> // Make a new global with the correct type, this is now<br>
> guaranteed to work.<br>
> - GV = cast<llvm::GlobalVariable>(GetAddrOfGlobalVar(D,<br>
> InitType));<br>
> + GV = cast<llvm::GlobalVariable>(<br>
> + GetAddrOfGlobalVar(D, InitType,<br>
> /*IsForDefinition=*/!IsTentative));<br>
><br>
> // Replace all uses of the old global with the new global<br>
> llvm::Constant *NewPtrForOldDecl =<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=254195&r1=254194&r2=254195&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=254195&r1=254194&r2=254195&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Nov 27 06:18:22 2015<br>
> @@ -701,7 +701,8 @@ public:<br>
> /// with the specified type instead of whatever the normal<br>
> requested type<br>
> /// would be.<br>
> llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,<br>
> - llvm::Type *Ty = nullptr);<br>
> + llvm::Type *Ty = nullptr,<br>
> + bool IsForDefinition = false);<br>
><br>
> /// Return the address of the given function. If Ty is non-null,<br>
> then this<br>
> /// function will use the specified type if it has to create it.<br>
> @@ -1130,7 +1131,8 @@ private:<br>
><br>
> llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,<br>
> llvm::PointerType *PTy,<br>
> - const VarDecl *D);<br>
> + const VarDecl *D,<br>
> + bool IsForDefinition =<br>
> false);<br>
><br>
> void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);<br>
><br>
> @@ -1141,7 +1143,7 @@ private:<br>
> void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV =<br>
> nullptr);<br>
><br>
> void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue<br>
> *GV);<br>
> - void EmitGlobalVarDefinition(const VarDecl *D);<br>
> + void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative =<br>
> false);<br>
> void EmitAliasDefinition(GlobalDecl GD);<br>
> void EmitObjCPropertyImplementations(const ObjCImplementationDecl<br>
> *D);<br>
> void EmitObjCIvarInitializations(ObjCImplementationDecl *D);<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>