diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-05-14 15:06:43 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-05-14 15:06:43 -0700 |
commit | 8fe6f1f79c0d43752173a0aa8e752a3d21ea10f9 (patch) | |
tree | 1b2227dc647e47d27f3e8dfa532fb95db6605ba6 | |
parent | 1ab5bccd715ba92134a501ae1ebc5c0f11e8c16e (diff) |
The customary LLVM way of obtaining intrinsics is with
Intrinsic::getDeclaration and use the definition in
include/llvm/Intrinsics.td
This also makes the attribute on the intrinsic to be more
consistent with the back-end (code-gen), which automatically assumes
it's ReadNone (because this is what Intrinsics.td) defines.
Using ReadNone rather than ReadOnly may be not strictly correct because
the intrinsic depends on the value of the TP. However, this attribute is
not really used anywhere in IR optimizations, and in the backend the
intrinsic is ReadNone anyhow (the IR setting gets overridden).
If we run into any problems with this in the future, we may consider
handling the lowering of this intrinsic in
TargetLowering::LowerINTRINSIC_W_CHAIN rather than in
TargetLowering::LowerINTRINSIC_WO_CHAIN.
BUG=None
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/14643019
-rw-r--r-- | include/llvm/IR/Intrinsics.td | 3 | ||||
-rw-r--r-- | lib/Transforms/NaCl/ExpandTls.cpp | 13 |
2 files changed, 3 insertions, 13 deletions
diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index f9f662929b..b8f3997e9c 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -479,8 +479,7 @@ def int_nacl_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>; // Fast built-in version of NaCl's tls_get() IRT interface. -def int_nacl_read_tp : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>, - GCCBuiltin<"__builtin_nacl_read_tp">; +def int_nacl_read_tp : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; // The following intrinsics provide target-specific implementations of // the interface in native_client/src/untrusted/nacl/tls_params.h. diff --git a/lib/Transforms/NaCl/ExpandTls.cpp b/lib/Transforms/NaCl/ExpandTls.cpp index 53e1c92a96..19837f7448 100644 --- a/lib/Transforms/NaCl/ExpandTls.cpp +++ b/lib/Transforms/NaCl/ExpandTls.cpp @@ -29,6 +29,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Module.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/NaCl.h" @@ -233,17 +234,7 @@ static PointerType *buildTlsTemplate(Module &M, std::vector<VarInfo> *TlsVars) { static void rewriteTlsVars(Module &M, std::vector<VarInfo> *TlsVars, PointerType *TemplatePtrType) { // Set up the intrinsic that reads the thread pointer. - Type *i8 = Type::getInt8Ty(M.getContext()); - FunctionType *ReadTpType = FunctionType::get(PointerType::get(i8, 0), - /*isVarArg=*/false); - AttrBuilder B; - B.addAttribute(Attribute::ReadOnly); - B.addAttribute(Attribute::NoUnwind); - AttributeSet ReadTpAttrs = AttributeSet::get( - M.getContext(), AttributeSet::FunctionIndex, B); - Constant *ReadTpFunc = M.getOrInsertTargetIntrinsic("llvm.nacl.read.tp", - ReadTpType, - ReadTpAttrs); + Function *ReadTpFunc = Intrinsic::getDeclaration(&M, Intrinsic::nacl_read_tp); for (std::vector<VarInfo>::iterator VarInfo = TlsVars->begin(); VarInfo != TlsVars->end(); |