From 205afe679855a4ce8149cdaa94d3f0868ce796dc Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 6 Feb 2015 21:38:51 +0000 Subject: Import LLDB as of upstream SVN r225923 (git 2b588ecd) This corresponds with the branchpoint for the 3.6 release. A number of files not required for the FreeBSD build have been removed. Sponsored by: DARPA, AFRL --- source/Expression/IRForTarget.cpp | 54 +++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'source/Expression/IRForTarget.cpp') diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp index b91e1b46f88e..8e75c32183ec 100644 --- a/source/Expression/IRForTarget.cpp +++ b/source/Expression/IRForTarget.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/Module.h" #include "llvm/PassManager.h" #include "llvm/Transforms/IPO.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/ValueSymbolTable.h" #include "clang/AST/ASTContext.h" @@ -403,18 +404,17 @@ IRForTarget::DeclForGlobal (const GlobalValue *global_val, Module *module) node_index < num_nodes; ++node_index) { - MDNode *metadata_node = named_metadata->getOperand(node_index); - + llvm::MDNode *metadata_node = dyn_cast(named_metadata->getOperand(node_index)); if (!metadata_node) return NULL; if (metadata_node->getNumOperands() != 2) continue; - if (metadata_node->getOperand(0) != global_val) + if (mdconst::dyn_extract_or_null(metadata_node->getOperand(0)) != global_val) continue; - ConstantInt *constant_int = dyn_cast(metadata_node->getOperand(1)); + ConstantInt *constant_int = mdconst::dyn_extract(metadata_node->getOperand(1)); if (!constant_int) return NULL; @@ -639,11 +639,11 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function) reinterpret_cast(result_decl), false); - llvm::Value* values[2]; - values[0] = new_result_global; - values[1] = new_constant_int; + llvm::Metadata *values[2]; + values[0] = ConstantAsMetadata::get(new_result_global); + values[1] = ConstantAsMetadata::get(new_constant_int); - ArrayRef value_ref(values, 2); + ArrayRef value_ref(values, 2); MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs"); @@ -1037,7 +1037,7 @@ static bool IsObjCSelectorRef (Value *value) { GlobalVariable *global_variable = dyn_cast(value); - if (!global_variable || !global_variable->hasName() || !global_variable->getName().startswith("\01L_OBJC_SELECTOR_REFERENCES_")) + if (!global_variable || !global_variable->hasName() || !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")) return false; return true; @@ -1056,12 +1056,12 @@ IRForTarget::RewriteObjCSelector (Instruction* selector_load) // Unpack the message name from the selector. In LLVM IR, an objc_msgSend gets represented as // - // %tmp = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_" ; + // %tmp = load i8** @"OBJC_SELECTOR_REFERENCES_" ; // %call = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) ; // // where %obj is the object pointer and %tmp is the selector. // - // @"\01L_OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_". + // @"OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_". // @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_" contains the string. // Find the pointer's initializer (a ConstantExpr with opcode GetElementPtr) and get the string from its target @@ -1215,7 +1215,7 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc) if (!alloc_md || !alloc_md->getNumOperands()) return false; - ConstantInt *constant_int = dyn_cast(alloc_md->getOperand(0)); + ConstantInt *constant_int = mdconst::dyn_extract(alloc_md->getOperand(0)); if (!constant_int) return false; @@ -1246,11 +1246,11 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc) NamedMDNode *named_metadata = m_module->getOrInsertNamedMetadata("clang.global.decl.ptrs"); - llvm::Value* values[2]; - values[0] = persistent_global; - values[1] = constant_int; + llvm::Metadata *values[2]; + values[0] = ConstantAsMetadata::get(persistent_global); + values[1] = ConstantAsMetadata::get(constant_int); - ArrayRef value_ref(values, 2); + ArrayRef value_ref(values, 2); MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); named_metadata->addOperand(persistent_global_md); @@ -2043,8 +2043,12 @@ static bool isGuardVariableRef(Value *V) GlobalVariable *GV = dyn_cast(Old); - if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV")) + if (!GV || !GV->hasName() || + (!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable + !GV->getName().endswith("@4IA"))) // Microsoft ABI guard variable + { return false; + } return true; } @@ -2052,20 +2056,8 @@ static bool isGuardVariableRef(Value *V) void IRForTarget::TurnGuardLoadIntoZero(llvm::Instruction* guard_load) { - Constant* zero(ConstantInt::get(Type::getInt8Ty(m_module->getContext()), 0, true)); - - for (llvm::User *u : guard_load->users()) - { - if (isa(u)) - { - // do nothing for the moment - } - else - { - u->replaceUsesOfWith(guard_load, zero); - } - } - + Constant *zero(Constant::getNullValue(guard_load->getType())); + guard_load->replaceAllUsesWith(zero); guard_load->eraseFromParent(); } -- cgit v1.3