Fix for issue #430
This commit is contained in:
@@ -597,8 +597,14 @@ lSetInternalFunctions(llvm::Module *module) {
|
||||
int count = sizeof(names) / sizeof(names[0]);
|
||||
for (int i = 0; i < count; ++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);
|
||||
#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>
|
||||
#else // LLVM 3.3+
|
||||
#include <llvm/IR/DataLayout.h>
|
||||
#include <llvm/IR/Attributes.h>
|
||||
#endif
|
||||
#include <llvm/Support/TargetRegistry.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();
|
||||
t->is32Bit = (dataLayout->getPointerSize(addressSpace) == 4);
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
10
ispc.h
10
ispc.h
@@ -68,6 +68,7 @@
|
||||
|
||||
// Forward declarations of a number of widely-used LLVM types
|
||||
namespace llvm {
|
||||
class AttributeSet;
|
||||
class BasicBlock;
|
||||
class Constant;
|
||||
class ConstantValue;
|
||||
@@ -224,9 +225,16 @@ struct Target {
|
||||
/** Target CPU. (e.g. "corei7", "corei7-avx", ..) */
|
||||
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;
|
||||
|
||||
#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
|
||||
value is directly derived from the ISA Being used (e.g. it's 4 for
|
||||
SSE, 8 for AVX, etc.) */
|
||||
|
||||
@@ -785,6 +785,10 @@ Module::AddFunctionDeclaration(const std::string &name,
|
||||
function->setDoesNotAlias(1);
|
||||
#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
|
||||
// the function is 'export'ed.
|
||||
if (functionType->isExported &&
|
||||
|
||||
Reference in New Issue
Block a user