Merge pull request #435 from dbabokin/master
Tracking ToT changes in DIBuilder interface
This commit is contained in:
@@ -597,8 +597,14 @@ lSetInternalFunctions(llvm::Module *module) {
|
|||||||
int count = sizeof(names) / sizeof(names[0]);
|
int count = sizeof(names) / sizeof(names[0]);
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
llvm::Function *f = module->getFunction(names[i]);
|
llvm::Function *f = module->getFunction(names[i]);
|
||||||
if (f != NULL && f->empty() == false)
|
if (f != NULL && f->empty() == false) {
|
||||||
f->setLinkage(llvm::GlobalValue::InternalLinkage);
|
f->setLinkage(llvm::GlobalValue::InternalLinkage);
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
f->addAttributes(
|
||||||
|
llvm::AttributeSet::FunctionIndex,
|
||||||
|
*g->target.tf_attributes);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
ispc.cpp
14
ispc.cpp
@@ -73,6 +73,7 @@
|
|||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
#else // LLVM 3.3+
|
#else // LLVM 3.3+
|
||||||
#include <llvm/IR/DataLayout.h>
|
#include <llvm/IR/DataLayout.h>
|
||||||
|
#include <llvm/IR/Attributes.h>
|
||||||
#endif
|
#endif
|
||||||
#include <llvm/Support/TargetRegistry.h>
|
#include <llvm/Support/TargetRegistry.h>
|
||||||
#include <llvm/Support/TargetSelect.h>
|
#include <llvm/Support/TargetSelect.h>
|
||||||
@@ -419,6 +420,19 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
|||||||
const llvm::DataLayout *dataLayout = targetMachine->getDataLayout();
|
const llvm::DataLayout *dataLayout = targetMachine->getDataLayout();
|
||||||
t->is32Bit = (dataLayout->getPointerSize(addressSpace) == 4);
|
t->is32Bit = (dataLayout->getPointerSize(addressSpace) == 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
// This is LLVM 3.3+ feature.
|
||||||
|
// Initialize target-specific "target-feature" attribute.
|
||||||
|
llvm::AttrBuilder attrBuilder;
|
||||||
|
attrBuilder.addAttribute("target-features", t->attributes);
|
||||||
|
t->tf_attributes = new llvm::AttributeSet(
|
||||||
|
llvm::AttributeSet::get(
|
||||||
|
*g->ctx,
|
||||||
|
llvm::AttributeSet::FunctionIndex,
|
||||||
|
attrBuilder));
|
||||||
|
#endif
|
||||||
|
|
||||||
Assert(t->vectorWidth <= ISPC_MAX_NVEC);
|
Assert(t->vectorWidth <= ISPC_MAX_NVEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
ispc.h
10
ispc.h
@@ -68,6 +68,7 @@
|
|||||||
|
|
||||||
// Forward declarations of a number of widely-used LLVM types
|
// Forward declarations of a number of widely-used LLVM types
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class AttributeSet;
|
||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
class Constant;
|
class Constant;
|
||||||
class ConstantValue;
|
class ConstantValue;
|
||||||
@@ -224,9 +225,16 @@ struct Target {
|
|||||||
/** Target CPU. (e.g. "corei7", "corei7-avx", ..) */
|
/** Target CPU. (e.g. "corei7", "corei7-avx", ..) */
|
||||||
std::string cpu;
|
std::string cpu;
|
||||||
|
|
||||||
/** Target-specific attributes to pass along to the LLVM backend */
|
/** Target-specific attribute string to pass along to the LLVM backend */
|
||||||
std::string attributes;
|
std::string attributes;
|
||||||
|
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
/** Target-specific LLVM attribute, which has to be attached to every
|
||||||
|
function to ensure that it is generated for correct target architecture.
|
||||||
|
This is requirement was introduced in LLVM 3.3 */
|
||||||
|
llvm::AttributeSet* tf_attributes;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Native vector width of the vector instruction set. Note that this
|
/** Native vector width of the vector instruction set. Note that this
|
||||||
value is directly derived from the ISA Being used (e.g. it's 4 for
|
value is directly derived from the ISA Being used (e.g. it's 4 for
|
||||||
SSE, 8 for AVX, etc.) */
|
SSE, 8 for AVX, etc.) */
|
||||||
|
|||||||
@@ -785,6 +785,10 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
function->setDoesNotAlias(1);
|
function->setDoesNotAlias(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
function->addAttributes(llvm::AttributeSet::FunctionIndex, *g->target.tf_attributes);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make sure that the return type isn't 'varying' or vector typed if
|
// Make sure that the return type isn't 'varying' or vector typed if
|
||||||
// the function is 'export'ed.
|
// the function is 'export'ed.
|
||||||
if (functionType->isExported &&
|
if (functionType->isExported &&
|
||||||
|
|||||||
29
type.cpp
29
type.cpp
@@ -2131,8 +2131,18 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
|
|
||||||
llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
|
llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
|
||||||
llvm::DIFile diFile = pos.GetDIFile();
|
llvm::DIFile diFile = pos.GetDIFile();
|
||||||
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line, currentSize,
|
return m->diBuilder->createStructType(
|
||||||
align, 0, elements);
|
scope,
|
||||||
|
name,
|
||||||
|
diFile,
|
||||||
|
pos.first_line, // Line number
|
||||||
|
currentSize, // Size in bits
|
||||||
|
align, // Alignment in bits
|
||||||
|
0, // Flags
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
llvm::DIType(), // DerivedFrom
|
||||||
|
#endif
|
||||||
|
elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2364,9 +2374,18 @@ llvm::DIType
|
|||||||
UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||||
llvm::DIFile diFile = pos.GetDIFile();
|
llvm::DIFile diFile = pos.GetDIFile();
|
||||||
llvm::DIArray elements;
|
llvm::DIArray elements;
|
||||||
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line,
|
return m->diBuilder->createStructType(
|
||||||
0 /* size */, 0 /* align */,
|
scope,
|
||||||
0 /* flags */, elements);
|
name,
|
||||||
|
diFile,
|
||||||
|
pos.first_line, // Line number
|
||||||
|
0, // Size
|
||||||
|
0, // Align
|
||||||
|
0, // Flags
|
||||||
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||||
|
llvm::DIType(), // DerivedFrom
|
||||||
|
#endif
|
||||||
|
elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user