Revert "[x86] Exclusion of incorrect include headers paths for MCU target"
This reverts commit r254195. From the description, I suspect that the wrong patch was committed here, and this is causing assertion failures in EmitDeferred() when the global value ends up being a bitcast of a global. llvm-svn: 254823
This commit is contained in:
parent
da7ffc25dd
commit
953fe0367b
|
@ -1178,7 +1178,12 @@ void CodeGenModule::EmitDeferred() {
|
|||
// to get GlobalValue with exactly the type we need, not something that
|
||||
// might had been created for another decl with the same mangled name but
|
||||
// different type.
|
||||
GV = cast<llvm::GlobalValue>(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
|
||||
// FIXME: Support for variables is not implemented yet.
|
||||
if (isa<FunctionDecl>(D.getDecl()))
|
||||
GV = cast<llvm::GlobalValue>(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
|
||||
else
|
||||
if (!GV)
|
||||
GV = GetGlobalValue(getMangledName(D));
|
||||
|
||||
// Check to see if we've already emitted this. This is necessary
|
||||
// for a couple of reasons: first, decls can end up in the
|
||||
|
@ -1688,8 +1693,8 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
|
|||
// error.
|
||||
if (IsForDefinition && !Entry->isDeclaration()) {
|
||||
GlobalDecl OtherGD;
|
||||
// Check that GD is not yet in DiagnosedConflictingDefinitions is required
|
||||
// to make sure that we issue an error only once.
|
||||
// Check that GD is not yet in ExplicitDefinitions is required to make
|
||||
// sure that we issue an error only once.
|
||||
if (lookupRepresentativeDecl(MangledName, OtherGD) &&
|
||||
(GD.getCanonicalDecl().getDecl() !=
|
||||
OtherGD.getCanonicalDecl().getDecl()) &&
|
||||
|
@ -1902,8 +1907,7 @@ bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) {
|
|||
llvm::Constant *
|
||||
CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
||||
llvm::PointerType *Ty,
|
||||
const VarDecl *D,
|
||||
bool IsForDefinition) {
|
||||
const VarDecl *D) {
|
||||
// Lookup the entry, lazily creating it if necessary.
|
||||
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
|
||||
if (Entry) {
|
||||
|
@ -1919,31 +1923,11 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
|||
if (Entry->getType() == Ty)
|
||||
return Entry;
|
||||
|
||||
// If there are two attempts to define the same mangled name, issue an
|
||||
// error.
|
||||
if (IsForDefinition && !Entry->isDeclaration()) {
|
||||
GlobalDecl OtherGD;
|
||||
// Check that D is not yet in DiagnosedConflictingDefinitions is required
|
||||
// to make sure that we issue an error only once.
|
||||
if (lookupRepresentativeDecl(MangledName, OtherGD) &&
|
||||
(D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
|
||||
DiagnosedConflictingDefinitions.insert(D).second) {
|
||||
getDiags().Report(D->getLocation(),
|
||||
diag::err_duplicate_mangled_name);
|
||||
getDiags().Report(OtherGD.getDecl()->getLocation(),
|
||||
diag::note_previous_definition);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the result is of the correct type.
|
||||
if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
|
||||
return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
|
||||
|
||||
// Make sure the result is of the correct type.
|
||||
// (If global is requested for a definition, we always need to create a new
|
||||
// global, not just return a bitcast.)
|
||||
if (!IsForDefinition)
|
||||
return llvm::ConstantExpr::getBitCast(Entry, Ty);
|
||||
return llvm::ConstantExpr::getBitCast(Entry, Ty);
|
||||
}
|
||||
|
||||
unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
|
||||
|
@ -1952,20 +1936,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
|||
llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
|
||||
llvm::GlobalVariable::NotThreadLocal, AddrSpace);
|
||||
|
||||
// If we already created a global with the same mangled name (but different
|
||||
// type) before, take its name and remove it from its parent.
|
||||
if (Entry) {
|
||||
GV->takeName(Entry);
|
||||
|
||||
if (!Entry->use_empty()) {
|
||||
llvm::Constant *NewPtrForOldDecl =
|
||||
llvm::ConstantExpr::getBitCast(GV, Entry->getType());
|
||||
Entry->replaceAllUsesWith(NewPtrForOldDecl);
|
||||
}
|
||||
|
||||
Entry->eraseFromParent();
|
||||
}
|
||||
|
||||
// This is the first use or definition of a mangled name. If there is a
|
||||
// deferred decl with this name, remember that we need to emit it at the end
|
||||
// of the file.
|
||||
|
@ -2038,8 +2008,7 @@ CodeGenModule::GetAddrOfGlobal(GlobalDecl GD,
|
|||
return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false,
|
||||
IsForDefinition);
|
||||
} else
|
||||
return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()), /*Ty=*/nullptr,
|
||||
IsForDefinition);
|
||||
return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()));
|
||||
}
|
||||
|
||||
llvm::GlobalVariable *
|
||||
|
@ -2089,8 +2058,7 @@ CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name,
|
|||
/// then it will be created with the specified type instead of whatever the
|
||||
/// normal requested type would be.
|
||||
llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
|
||||
llvm::Type *Ty,
|
||||
bool IsForDefinition) {
|
||||
llvm::Type *Ty) {
|
||||
assert(D->hasGlobalStorage() && "Not a global variable");
|
||||
QualType ASTTy = D->getType();
|
||||
if (!Ty)
|
||||
|
@ -2100,7 +2068,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
|
|||
llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy));
|
||||
|
||||
StringRef MangledName = getMangledName(D);
|
||||
return GetOrCreateLLVMGlobal(MangledName, PTy, D, IsForDefinition);
|
||||
return GetOrCreateLLVMGlobal(MangledName, PTy, D);
|
||||
}
|
||||
|
||||
/// CreateRuntimeVariable - Create a new runtime global variable with the
|
||||
|
@ -2126,7 +2094,7 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
|
|||
}
|
||||
|
||||
// The tentative definition is the only definition.
|
||||
EmitGlobalVarDefinition(D, true);
|
||||
EmitGlobalVarDefinition(D);
|
||||
}
|
||||
|
||||
CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {
|
||||
|
@ -2213,8 +2181,7 @@ void CodeGenModule::maybeSetTrivialComdat(const Decl &D,
|
|||
GO.setComdat(TheModule.getOrInsertComdat(GO.getName()));
|
||||
}
|
||||
|
||||
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
||||
bool IsTentative) {
|
||||
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
|
||||
llvm::Constant *Init = nullptr;
|
||||
QualType ASTTy = D->getType();
|
||||
CXXRecordDecl *RD = ASTTy->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
|
||||
|
@ -2273,8 +2240,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
|||
}
|
||||
|
||||
llvm::Type* InitType = Init->getType();
|
||||
llvm::Constant *Entry =
|
||||
GetAddrOfGlobalVar(D, InitType, /*IsForDefinition=*/!IsTentative);
|
||||
llvm::Constant *Entry = GetAddrOfGlobalVar(D, InitType);
|
||||
|
||||
// Strip off a bitcast if we got one back.
|
||||
if (auto *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
|
||||
|
@ -2306,8 +2272,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
|||
Entry->setName(StringRef());
|
||||
|
||||
// Make a new global with the correct type, this is now guaranteed to work.
|
||||
GV = cast<llvm::GlobalVariable>(
|
||||
GetAddrOfGlobalVar(D, InitType, /*IsForDefinition=*/!IsTentative));
|
||||
GV = cast<llvm::GlobalVariable>(GetAddrOfGlobalVar(D, InitType));
|
||||
|
||||
// Replace all uses of the old global with the new global
|
||||
llvm::Constant *NewPtrForOldDecl =
|
||||
|
|
|
@ -700,8 +700,7 @@ public:
|
|||
/// with the specified type instead of whatever the normal requested type
|
||||
/// would be.
|
||||
llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
|
||||
llvm::Type *Ty = nullptr,
|
||||
bool IsForDefinition = false);
|
||||
llvm::Type *Ty = nullptr);
|
||||
|
||||
/// Return the address of the given function. If Ty is non-null, then this
|
||||
/// function will use the specified type if it has to create it.
|
||||
|
@ -1130,8 +1129,7 @@ private:
|
|||
|
||||
llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
|
||||
llvm::PointerType *PTy,
|
||||
const VarDecl *D,
|
||||
bool IsForDefinition = false);
|
||||
const VarDecl *D);
|
||||
|
||||
void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
|
||||
|
||||
|
@ -1142,7 +1140,7 @@ private:
|
|||
void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
|
||||
|
||||
void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
|
||||
void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
|
||||
void EmitGlobalVarDefinition(const VarDecl *D);
|
||||
void EmitAliasDefinition(GlobalDecl GD);
|
||||
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
|
||||
void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
|
||||
|
|
Loading…
Reference in New Issue