aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-05-06 11:46:36 -0700
committerPirama Arumuga Nainar <pirama@google.com>2015-05-18 10:52:30 -0700
commit2c3e0051c31c3f5b2328b447eadf1cf9c4427442 (patch)
treec0104029af14e9f47c2ef58ca60e6137691f3c9b /examples
parente1bc145815f4334641be19f1c45ecf85d25b6e5a (diff)
downloadexternal_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.zip
external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.gz
external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.bz2
Update aosp/master LLVM for rebase to r235153
Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7 (cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987)
Diffstat (limited to 'examples')
-rw-r--r--examples/BrainF/BrainF.cpp2
-rw-r--r--examples/ExceptionDemo/CMakeLists.txt3
-rw-r--r--examples/ExceptionDemo/ExceptionDemo.cpp2
-rw-r--r--examples/Kaleidoscope/Chapter3/toy.cpp8
-rw-r--r--examples/Kaleidoscope/Chapter4/toy.cpp12
-rw-r--r--examples/Kaleidoscope/Chapter5/CMakeLists.txt1
-rw-r--r--examples/Kaleidoscope/Chapter5/toy.cpp12
-rw-r--r--examples/Kaleidoscope/Chapter6/CMakeLists.txt1
-rw-r--r--examples/Kaleidoscope/Chapter6/toy.cpp14
-rw-r--r--examples/Kaleidoscope/Chapter7/CMakeLists.txt3
-rw-r--r--examples/Kaleidoscope/Chapter7/toy.cpp16
-rw-r--r--examples/Kaleidoscope/Chapter8/CMakeLists.txt3
-rw-r--r--examples/Kaleidoscope/Chapter8/toy.cpp62
-rw-r--r--examples/Kaleidoscope/Orc/fully_lazy/toy.cpp43
-rw-r--r--examples/Kaleidoscope/Orc/initial/toy.cpp20
-rw-r--r--examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp17
-rw-r--r--examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp32
17 files changed, 141 insertions, 110 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index f8129b8..81c48b9 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -163,7 +163,7 @@ void BrainF::header(LLVMContext& C) {
};
Constant *msgptr = ConstantExpr::
- getGetElementPtr(aberrormsg, gep_params);
+ getGetElementPtr(aberrormsg->getValueType(), aberrormsg, gep_params);
Value *puts_params[] = {
msgptr
diff --git a/examples/ExceptionDemo/CMakeLists.txt b/examples/ExceptionDemo/CMakeLists.txt
index 2a7667d..b4354f6 100644
--- a/examples/ExceptionDemo/CMakeLists.txt
+++ b/examples/ExceptionDemo/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
ExecutionEngine
MC
MCJIT
+ RuntimeDyld
Support
nativecodegen
)
@@ -11,6 +12,8 @@ set(LLVM_LINK_COMPONENTS
set(LLVM_REQUIRES_EH 1)
set(LLVM_REQUIRES_RTTI 1)
+set(LLVM_BUILD_EXAMPLES OFF)
+
add_llvm_example(ExceptionDemo
ExceptionDemo.cpp
)
diff --git a/examples/ExceptionDemo/ExceptionDemo.cpp b/examples/ExceptionDemo/ExceptionDemo.cpp
index d68c05f..fed42b7 100644
--- a/examples/ExceptionDemo/ExceptionDemo.cpp
+++ b/examples/ExceptionDemo/ExceptionDemo.cpp
@@ -1573,7 +1573,7 @@ public:
std::runtime_error::operator=(toCopy)));
}
- virtual ~OurCppRunException (void) throw () {}
+ ~OurCppRunException(void) throw() override {}
};
} // end anonymous namespace
diff --git a/examples/Kaleidoscope/Chapter3/toy.cpp b/examples/Kaleidoscope/Chapter3/toy.cpp
index 04a1e1a..c60f767 100644
--- a/examples/Kaleidoscope/Chapter3/toy.cpp
+++ b/examples/Kaleidoscope/Chapter3/toy.cpp
@@ -93,7 +93,7 @@ class NumberExprAST : public ExprAST {
double Val;
public:
NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -101,7 +101,7 @@ class VariableExprAST : public ExprAST {
std::string Name;
public:
VariableExprAST(const std::string &name) : Name(name) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -111,7 +111,7 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs)
: Op(op), LHS(lhs), RHS(rhs) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -121,7 +121,7 @@ class CallExprAST : public ExprAST {
public:
CallExprAST(const std::string &callee, std::vector<ExprAST*> &args)
: Callee(callee), Args(args) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp
index 329c3be..ad091e4 100644
--- a/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -107,7 +107,7 @@ class NumberExprAST : public ExprAST {
public:
NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -116,7 +116,7 @@ class VariableExprAST : public ExprAST {
public:
VariableExprAST(const std::string &name) : Name(name) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -127,7 +127,7 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs)
: Op(op), LHS(lhs), RHS(rhs) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -138,7 +138,7 @@ class CallExprAST : public ExprAST {
public:
CallExprAST(const std::string &callee, std::vector<ExprAST *> &args)
: Callee(callee), Args(args) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
@@ -452,13 +452,13 @@ class HelpingMemoryManager : public SectionMemoryManager {
public:
HelpingMemoryManager(MCJITHelper *Helper) : MasterHelper(Helper) {}
- virtual ~HelpingMemoryManager() {}
+ ~HelpingMemoryManager() override {}
/// This method returns the address of the specified symbol.
/// Our implementation will attempt to find symbols in other
/// modules associated with the MCJITHelper to cross link symbols
/// from one generated module to another.
- virtual uint64_t getSymbolAddress(const std::string &Name) override;
+ uint64_t getSymbolAddress(const std::string &Name) override;
private:
MCJITHelper *MasterHelper;
diff --git a/examples/Kaleidoscope/Chapter5/CMakeLists.txt b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
index aac9949..a938d97 100644
--- a/examples/Kaleidoscope/Chapter5/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
ExecutionEngine
InstCombine
MCJIT
+ RuntimeDyld
ScalarOpts
Support
native
diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp
index 8ebc2bc..db99048 100644
--- a/examples/Kaleidoscope/Chapter5/toy.cpp
+++ b/examples/Kaleidoscope/Chapter5/toy.cpp
@@ -125,7 +125,7 @@ class NumberExprAST : public ExprAST {
public:
NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -134,7 +134,7 @@ class VariableExprAST : public ExprAST {
public:
VariableExprAST(const std::string &name) : Name(name) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -145,7 +145,7 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs)
: Op(op), LHS(lhs), RHS(rhs) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -156,7 +156,7 @@ class CallExprAST : public ExprAST {
public:
CallExprAST(const std::string &callee, std::vector<ExprAST *> &args)
: Callee(callee), Args(args) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// IfExprAST - Expression class for if/then/else.
@@ -166,7 +166,7 @@ class IfExprAST : public ExprAST {
public:
IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else)
: Cond(cond), Then(then), Else(_else) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// ForExprAST - Expression class for for/in.
@@ -178,7 +178,7 @@ public:
ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end,
ExprAST *step, ExprAST *body)
: VarName(varname), Start(start), End(end), Step(step), Body(body) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
diff --git a/examples/Kaleidoscope/Chapter6/CMakeLists.txt b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
index 55b9a78..7ac1ca4 100644
--- a/examples/Kaleidoscope/Chapter6/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
ExecutionEngine
InstCombine
MCJIT
+ RuntimeDyld
ScalarOpts
Support
native
diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp
index eb7e8e1..e978a3e 100644
--- a/examples/Kaleidoscope/Chapter6/toy.cpp
+++ b/examples/Kaleidoscope/Chapter6/toy.cpp
@@ -133,7 +133,7 @@ class NumberExprAST : public ExprAST {
public:
NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -142,7 +142,7 @@ class VariableExprAST : public ExprAST {
public:
VariableExprAST(const std::string &name) : Name(name) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// UnaryExprAST - Expression class for a unary operator.
@@ -153,7 +153,7 @@ class UnaryExprAST : public ExprAST {
public:
UnaryExprAST(char opcode, ExprAST *operand)
: Opcode(opcode), Operand(operand) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -164,7 +164,7 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs)
: Op(op), LHS(lhs), RHS(rhs) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -175,7 +175,7 @@ class CallExprAST : public ExprAST {
public:
CallExprAST(const std::string &callee, std::vector<ExprAST *> &args)
: Callee(callee), Args(args) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// IfExprAST - Expression class for if/then/else.
@@ -185,7 +185,7 @@ class IfExprAST : public ExprAST {
public:
IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else)
: Cond(cond), Then(then), Else(_else) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// ForExprAST - Expression class for for/in.
@@ -197,7 +197,7 @@ public:
ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end,
ExprAST *step, ExprAST *body)
: VarName(varname), Start(start), End(end), Step(step), Body(body) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
diff --git a/examples/Kaleidoscope/Chapter7/CMakeLists.txt b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
index 4bc1b2c..23aba65 100644
--- a/examples/Kaleidoscope/Chapter7/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
ExecutionEngine
InstCombine
MCJIT
+ RuntimeDyld
ScalarOpts
Support
TransformUtils
@@ -12,6 +13,8 @@ set(LLVM_LINK_COMPONENTS
set(LLVM_REQUIRES_RTTI 1)
+set(LLVM_BUILD_EXAMPLES OFF)
+
add_kaleidoscope_chapter(Kaleidoscope-Ch7
toy.cpp
)
diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp
index ce5e1dd..53ea51c 100644
--- a/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -138,7 +138,7 @@ class NumberExprAST : public ExprAST {
public:
NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -148,7 +148,7 @@ class VariableExprAST : public ExprAST {
public:
VariableExprAST(const std::string &name) : Name(name) {}
const std::string &getName() const { return Name; }
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// UnaryExprAST - Expression class for a unary operator.
@@ -159,7 +159,7 @@ class UnaryExprAST : public ExprAST {
public:
UnaryExprAST(char opcode, ExprAST *operand)
: Opcode(opcode), Operand(operand) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -170,7 +170,7 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(char op, ExprAST *lhs, ExprAST *rhs)
: Op(op), LHS(lhs), RHS(rhs) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -181,7 +181,7 @@ class CallExprAST : public ExprAST {
public:
CallExprAST(const std::string &callee, std::vector<ExprAST *> &args)
: Callee(callee), Args(args) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// IfExprAST - Expression class for if/then/else.
@@ -191,7 +191,7 @@ class IfExprAST : public ExprAST {
public:
IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else)
: Cond(cond), Then(then), Else(_else) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// ForExprAST - Expression class for for/in.
@@ -203,7 +203,7 @@ public:
ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end,
ExprAST *step, ExprAST *body)
: VarName(varname), Start(start), End(end), Step(step), Body(body) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VarExprAST - Expression class for var/in
@@ -216,7 +216,7 @@ public:
ExprAST *body)
: VarNames(varnames), Body(body) {}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
diff --git a/examples/Kaleidoscope/Chapter8/CMakeLists.txt b/examples/Kaleidoscope/Chapter8/CMakeLists.txt
index 42882e9..90c79c0 100644
--- a/examples/Kaleidoscope/Chapter8/CMakeLists.txt
+++ b/examples/Kaleidoscope/Chapter8/CMakeLists.txt
@@ -2,12 +2,15 @@ set(LLVM_LINK_COMPONENTS
Core
ExecutionEngine
MCJIT
+ RuntimeDyld
Support
native
)
set(LLVM_REQUIRES_RTTI 1)
+set(LLVM_BUILD_EXAMPLES OFF)
+
add_kaleidoscope_chapter(Kaleidoscope-Ch8
toy.cpp
)
diff --git a/examples/Kaleidoscope/Chapter8/toy.cpp b/examples/Kaleidoscope/Chapter8/toy.cpp
index 39b6a65..c7e096c 100644
--- a/examples/Kaleidoscope/Chapter8/toy.cpp
+++ b/examples/Kaleidoscope/Chapter8/toy.cpp
@@ -221,10 +221,10 @@ class NumberExprAST : public ExprAST {
public:
NumberExprAST(double val) : Val(val) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
return ExprAST::dump(out << Val, ind);
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VariableExprAST - Expression class for referencing a variable, like "a".
@@ -235,10 +235,10 @@ public:
VariableExprAST(SourceLocation Loc, const std::string &name)
: ExprAST(Loc), Name(name) {}
const std::string &getName() const { return Name; }
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
return ExprAST::dump(out << Name, ind);
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// UnaryExprAST - Expression class for a unary operator.
@@ -249,12 +249,12 @@ class UnaryExprAST : public ExprAST {
public:
UnaryExprAST(char opcode, ExprAST *operand)
: Opcode(opcode), Operand(operand) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "unary" << Opcode, ind);
Operand->dump(out, ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// BinaryExprAST - Expression class for a binary operator.
@@ -265,13 +265,13 @@ class BinaryExprAST : public ExprAST {
public:
BinaryExprAST(SourceLocation Loc, char op, ExprAST *lhs, ExprAST *rhs)
: ExprAST(Loc), Op(op), LHS(lhs), RHS(rhs) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "binary" << Op, ind);
LHS->dump(indent(out, ind) << "LHS:", ind + 1);
RHS->dump(indent(out, ind) << "RHS:", ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// CallExprAST - Expression class for function calls.
@@ -283,13 +283,13 @@ public:
CallExprAST(SourceLocation Loc, const std::string &callee,
std::vector<ExprAST *> &args)
: ExprAST(Loc), Callee(callee), Args(args) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "call " << Callee, ind);
for (ExprAST *Arg : Args)
Arg->dump(indent(out, ind + 1), ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// IfExprAST - Expression class for if/then/else.
@@ -299,14 +299,14 @@ class IfExprAST : public ExprAST {
public:
IfExprAST(SourceLocation Loc, ExprAST *cond, ExprAST *then, ExprAST *_else)
: ExprAST(Loc), Cond(cond), Then(then), Else(_else) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "if", ind);
Cond->dump(indent(out, ind) << "Cond:", ind + 1);
Then->dump(indent(out, ind) << "Then:", ind + 1);
Else->dump(indent(out, ind) << "Else:", ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// ForExprAST - Expression class for for/in.
@@ -318,7 +318,7 @@ public:
ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end,
ExprAST *step, ExprAST *body)
: VarName(varname), Start(start), End(end), Step(step), Body(body) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "for", ind);
Start->dump(indent(out, ind) << "Cond:", ind + 1);
End->dump(indent(out, ind) << "End:", ind + 1);
@@ -326,7 +326,7 @@ public:
Body->dump(indent(out, ind) << "Body:", ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// VarExprAST - Expression class for var/in
@@ -339,14 +339,14 @@ public:
ExprAST *body)
: VarNames(varnames), Body(body) {}
- virtual std::ostream &dump(std::ostream &out, int ind) {
+ std::ostream &dump(std::ostream &out, int ind) override {
ExprAST::dump(out << "var", ind);
for (const auto &NamedVar : VarNames)
NamedVar.second->dump(indent(out, ind) << NamedVar.first << ':', ind + 1);
Body->dump(indent(out, ind) << "Body:", ind + 1);
return out;
}
- virtual Value *Codegen();
+ Value *Codegen() override;
};
/// PrototypeAST - This class represents the "prototype" for a function,
@@ -817,7 +817,7 @@ static PrototypeAST *ParseExtern() {
static DIBuilder *DBuilder;
DIType DebugInfo::getDoubleTy() {
- if (DblTy.isValid())
+ if (DblTy)
return DblTy;
DblTy = DBuilder->createBasicType("double", 64, 64, dwarf::DW_ATE_float);
@@ -827,16 +827,16 @@ DIType DebugInfo::getDoubleTy() {
void DebugInfo::emitLocation(ExprAST *AST) {
if (!AST)
return Builder.SetCurrentDebugLocation(DebugLoc());
- DIScope *Scope;
+ MDScope *Scope;
if (LexicalBlocks.empty())
- Scope = &TheCU;
+ Scope = TheCU;
else
- Scope = LexicalBlocks.back();
+ Scope = *LexicalBlocks.back();
Builder.SetCurrentDebugLocation(
- DebugLoc::get(AST->getLine(), AST->getCol(), DIScope(*Scope)));
+ DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
}
-static DICompositeType CreateFunctionType(unsigned NumArgs, DIFile Unit) {
+static MDSubroutineType *CreateFunctionType(unsigned NumArgs, DIFile Unit) {
SmallVector<Metadata *, 8> EltTys;
DIType DblTy = KSDbgInfo.getDoubleTy();
@@ -1224,15 +1224,15 @@ Function *PrototypeAST::Codegen() {
AI->setName(Args[Idx]);
// Create a subprogram DIE for this function.
- DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
- KSDbgInfo.TheCU.getDirectory());
- DIDescriptor FContext(Unit);
+ DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(),
+ KSDbgInfo.TheCU->getDirectory());
+ MDScope *FContext = Unit;
unsigned LineNo = Line;
unsigned ScopeLine = Line;
DISubprogram SP = DBuilder->createFunction(
FContext, Name, StringRef(), Unit, LineNo,
CreateFunctionType(Args.size(), Unit), false /* internal linkage */,
- true /* definition */, ScopeLine, DIDescriptor::FlagPrototyped, false, F);
+ true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F);
KSDbgInfo.FnScopeMap[this] = SP;
return F;
@@ -1248,15 +1248,15 @@ void PrototypeAST::CreateArgumentAllocas(Function *F) {
// Create a debug descriptor for the variable.
DIScope *Scope = KSDbgInfo.LexicalBlocks.back();
- DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),
- KSDbgInfo.TheCU.getDirectory());
+ DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(),
+ KSDbgInfo.TheCU->getDirectory());
DIVariable D = DBuilder->createLocalVariable(dwarf::DW_TAG_arg_variable,
*Scope, Args[Idx], Unit, Line,
KSDbgInfo.getDoubleTy(), Idx);
- Instruction *Call = DBuilder->insertDeclare(
- Alloca, D, DBuilder->createExpression(), Builder.GetInsertBlock());
- Call->setDebugLoc(DebugLoc::get(Line, 0, *Scope));
+ DBuilder->insertDeclare(Alloca, D, DBuilder->createExpression(),
+ DebugLoc::get(Line, 0, *Scope),
+ Builder.GetInsertBlock());
// Store the initial value into the alloca.
Builder.CreateStore(AI, Alloca);
diff --git a/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp b/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
index 3b5dcd0..b582292 100644
--- a/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
+++ b/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
@@ -1,6 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
@@ -1168,11 +1169,9 @@ public:
KaleidoscopeJIT(SessionContext &Session)
: Session(Session),
Mang(Session.getTarget().getDataLayout()),
- ObjectLayer(
- [](){ return llvm::make_unique<SectionMemoryManager>(); }),
CompileLayer(ObjectLayer, SimpleCompiler(Session.getTarget())),
LazyEmitLayer(CompileLayer),
- CompileCallbacks(LazyEmitLayer, Session.getLLVMContext(),
+ CompileCallbacks(LazyEmitLayer, CCMgrMemMgr, Session.getLLVMContext(),
reinterpret_cast<uintptr_t>(EarthShatteringKaboom),
64) {}
@@ -1194,20 +1193,22 @@ public:
// We need a memory manager to allocate memory and resolve symbols for this
// new module. Create one that resolves symbols by looking back into the
// JIT.
- auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
- [&](const std::string &Name) {
- // First try to find 'Name' within the JIT.
- if (auto Symbol = findSymbol(Name))
- return Symbol.getAddress();
-
- // If we don't already have a definition of 'Name' then search
- // the ASTs.
- return searchFunctionASTs(Name);
- },
- [](const std::string &S) { return 0; } );
+ auto Resolver = createLambdaResolver(
+ [&](const std::string &Name) {
+ // First try to find 'Name' within the JIT.
+ if (auto Symbol = findSymbol(Name))
+ return RuntimeDyld::SymbolInfo(Symbol.getAddress(),
+ Symbol.getFlags());
+
+ // If we don't already have a definition of 'Name' then search
+ // the ASTs.
+ return searchFunctionASTs(Name);
+ },
+ [](const std::string &S) { return nullptr; } );
return LazyEmitLayer.addModuleSet(singletonSet(std::move(M)),
- std::move(MM));
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); }
@@ -1232,7 +1233,7 @@ private:
// This method searches the FunctionDefs map for a definition of 'Name'. If it
// finds one it generates a stub for it and returns the address of the stub.
- TargetAddress searchFunctionASTs(const std::string &Name) {
+ RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
auto DefI = FunctionDefs.find(Name);
if (DefI == FunctionDefs.end())
return 0;
@@ -1244,7 +1245,8 @@ private:
// IRGen the AST, add it to the JIT, and return the address for it.
auto H = irGenStub(std::move(FnAST));
- return findSymbolIn(H, Name).getAddress();
+ auto Sym = findSymbolIn(H, Name);
+ return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags());
}
// This method will take the AST for a function definition and IR-gen a stub
@@ -1261,14 +1263,16 @@ private:
// compile and update actions for the callback, and get a pointer to
// the jit trampoline that we need to call to trigger those actions.
auto CallbackInfo =
- CompileCallbacks.getCompileCallback(*F->getFunctionType());
+ CompileCallbacks.getCompileCallback(F->getContext());
// Step 3) Create a stub that will indirectly call the body of this
// function once it is compiled. Initially, set the function
// pointer for the indirection to point at the trampoline.
std::string BodyPtrName = (F->getName() + "$address").str();
GlobalVariable *FunctionBodyPointer =
- createImplPointer(*F, BodyPtrName, CallbackInfo.getAddress());
+ createImplPointer(*F->getType(), *F->getParent(), BodyPtrName,
+ createIRTypedAddress(*F->getFunctionType(),
+ CallbackInfo.getAddress()));
makeStub(*F, *FunctionBodyPointer);
// Step 4) Add the module containing the stub to the JIT.
@@ -1297,6 +1301,7 @@ private:
SessionContext &Session;
Mangler Mang;
+ SectionMemoryManager CCMgrMemMgr;
ObjLayerT ObjectLayer;
CompileLayerT CompileLayer;
LazyEmitLayerT LazyEmitLayer;
diff --git a/examples/Kaleidoscope/Orc/initial/toy.cpp b/examples/Kaleidoscope/Orc/initial/toy.cpp
index cc6fb8e..bf43f29 100644
--- a/examples/Kaleidoscope/Orc/initial/toy.cpp
+++ b/examples/Kaleidoscope/Orc/initial/toy.cpp
@@ -1,6 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/IR/DataLayout.h"
@@ -1175,13 +1176,18 @@ public:
// We need a memory manager to allocate memory and resolve symbols for this
// new module. Create one that resolves symbols by looking back into the
// JIT.
- auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
- [&](const std::string &Name) {
- return findSymbol(Name).getAddress();
- },
- [](const std::string &S) { return 0; } );
-
- return CompileLayer.addModuleSet(singletonSet(std::move(M)), std::move(MM));
+ auto Resolver = createLambdaResolver(
+ [&](const std::string &Name) {
+ if (auto Sym = findSymbol(Name))
+ return RuntimeDyld::SymbolInfo(Sym.getAddress(),
+ Sym.getFlags());
+ return RuntimeDyld::SymbolInfo(nullptr);
+ },
+ [](const std::string &S) { return nullptr; }
+ );
+ return CompileLayer.addModuleSet(singletonSet(std::move(M)),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
void removeModule(ModuleHandleT H) { CompileLayer.removeModuleSet(H); }
diff --git a/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp b/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
index 6e2ec27..1369ba6 100644
--- a/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
+++ b/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
@@ -1,6 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/IR/DataLayout.h"
@@ -1178,14 +1179,18 @@ public:
// We need a memory manager to allocate memory and resolve symbols for this
// new module. Create one that resolves symbols by looking back into the
// JIT.
- auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
- [&](const std::string &Name) {
- return findSymbol(Name).getAddress();
- },
- [](const std::string &S) { return 0; } );
+ auto Resolver = createLambdaResolver(
+ [&](const std::string &Name) {
+ if (auto Sym = findSymbol(Name))
+ return RuntimeDyld::SymbolInfo(Sym.getAddress(),
+ Sym.getFlags());
+ return RuntimeDyld::SymbolInfo(nullptr);
+ },
+ [](const std::string &S) { return nullptr; } );
return LazyEmitLayer.addModuleSet(singletonSet(std::move(M)),
- std::move(MM));
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); }
diff --git a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
index 19801e1..c489a45 100644
--- a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
+++ b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
@@ -1,6 +1,7 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
+#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/IR/DataLayout.h"
@@ -1183,20 +1184,22 @@ public:
// We need a memory manager to allocate memory and resolve symbols for this
// new module. Create one that resolves symbols by looking back into the
// JIT.
- auto MM = createLookasideRTDyldMM<SectionMemoryManager>(
- [&](const std::string &Name) {
- // First try to find 'Name' within the JIT.
- if (auto Symbol = findSymbol(Name))
- return Symbol.getAddress();
-
- // If we don't already have a definition of 'Name' then search
- // the ASTs.
- return searchFunctionASTs(Name);
- },
- [](const std::string &S) { return 0; } );
+ auto Resolver = createLambdaResolver(
+ [&](const std::string &Name) {
+ // First try to find 'Name' within the JIT.
+ if (auto Symbol = findSymbol(Name))
+ return RuntimeDyld::SymbolInfo(Symbol.getAddress(),
+ Symbol.getFlags());
+
+ // If we don't already have a definition of 'Name' then search
+ // the ASTs.
+ return searchFunctionASTs(Name);
+ },
+ [](const std::string &S) { return nullptr; } );
return LazyEmitLayer.addModuleSet(singletonSet(std::move(M)),
- std::move(MM));
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); }
@@ -1217,7 +1220,7 @@ private:
// This method searches the FunctionDefs map for a definition of 'Name'. If it
// finds one it generates a stub for it and returns the address of the stub.
- TargetAddress searchFunctionASTs(const std::string &Name) {
+ RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
auto DefI = FunctionDefs.find(Name);
if (DefI == FunctionDefs.end())
return 0;
@@ -1228,7 +1231,8 @@ private:
// IRGen the AST, add it to the JIT, and return the address for it.
auto H = addModule(IRGen(Session, *FnAST));
- return findSymbolIn(H, Name).getAddress();
+ auto Sym = findSymbolIn(H, Name);
+ return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags());
}
SessionContext &Session;