{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/71252084","id":71252084,"diff_hunk":"@@ -0,0 +1,185 @@\n+// This file is a part of Julia. License is MIT: http://julialang.org/license\n+\n+#define DEBUG_TYPE \"lower_ptls\"\n+#undef DEBUG\n+\n+// This file defines two entry points:\n+//     global function annotateSimdLoop: mark a loop as a SIMD loop.\n+//     createLowerSimdLoopPass: construct LLVM for lowering a marked loop later.\n+\n+#include \"llvm-version.h\"\n+#include \"support/dtypes.h\"\n+\n+#include <llvm/Pass.h>\n+#include <llvm/IR/Module.h>\n+#include <llvm/IR/Function.h>\n+#include <llvm/IR/Instructions.h>\n+#include <llvm/IR/Constants.h>\n+#include <llvm/IR/LLVMContext.h>\n+\n+#include \"julia.h\"\n+#include \"julia_internal.h\"\n+\n+#if defined(LLVM37) && defined(JULIA_ENABLE_THREADING)\n+#  include <llvm/IR/InlineAsm.h>\n+#endif\n+\n+using namespace llvm;\n+\n+namespace {\n+\n+struct LowerPTLS: public ModulePass {\n+    static char ID;\n+    LowerPTLS(bool _imaging_mode=false, MDNode *_tbaa_const=nullptr)\n+        : ModulePass(ID),\n+          imaging_mode(_imaging_mode),\n+          tbaa_const(_tbaa_const)\n+    {}\n+\n+private:\n+    bool imaging_mode;\n+    MDNode *tbaa_const; // One `LLVMContext` only\n+    bool runOnModule(Module &M) override;\n+    void runOnFunction(LLVMContext &ctx, Module &M, Function *F,\n+                       Function *ptls_getter, Type *T_ppjlvalue);\n+};\n+\n+static void ensure_global(const char *name, Type *t, Module &M)\n+{\n+    if (M.getNamedValue(name))\n+        return;\n+    GlobalVariable *proto = new GlobalVariable(M, t, false,\n+                                               GlobalVariable::ExternalLinkage,\n+                                               NULL, name);\n+#ifdef LLVM35\n+    // DLLImport only needs to be set for the shadow module\n+    // it just gets annoying in the JIT\n+    proto->setDLLStorageClass(GlobalValue::DefaultStorageClass);\n+#endif","path":"src/llvm-ptls.cpp","position":null,"original_position":58,"commit_id":"265e9550b0730be4445f888610dbfe6d0070c143","original_commit_id":"36f23690ff544654fa68985e668ffe1052303faf","user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"body":"So what needs to be fixed here? I have no idea how DLLImport works on windows....","created_at":"2016-07-18T23:52:59Z","updated_at":"2016-07-18T23:52:59Z","html_url":"https://github.com/JuliaLang/julia/pull/17363#discussion_r71252084","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/17363","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/71252084"},"html":{"href":"https://github.com/JuliaLang/julia/pull/17363#discussion_r71252084"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/17363"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/17363","id":76885804,"html_url":"https://github.com/JuliaLang/julia/pull/17363","diff_url":"https://github.com/JuliaLang/julia/pull/17363.diff","patch_url":"https://github.com/JuliaLang/julia/pull/17363.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/17363","number":17363,"state":"open","locked":false,"title":"RFC/WIP: Try to run gcroot lowering after some LLVM optimizations","user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"body":"I believe some constant propagation (mostly store to load forwarding) would help some GC frame optimization to identify possible duplicate roots. Instead of making our own for special cases, it would be nice if we could let llvm do that. This requires running some LLVM passes before we do the GC frame lowering.\r\n\r\nThis PR solves the easy part of it, i.e. making the lowering a true LLVM pass and making sure we have enough information in the optimized IR for liveness analysis. (mostly to make sure that the `julia.gc_kill` won't be deleted due to dead branch).\r\n\r\nThe goal is to at least be able to run the lowering after mem2reg (and the instcombine after it). A lot of issues still need to be solve.\r\n\r\n1. We need to trace back bitcast and gep when identifying the address of gcframe stores/loads\r\n2. Need to make sure we can still identify the use of the value after llvm optimizes the IR (possibly by adding more explicit marks in the IR)\r\n\r\nIf this approach looks good and tests passes, we can probably merge this first and improve the algorithm later.\r\n\r\nBased on https://github.com/JuliaLang/julia/pull/17352 to reduce conflicts.\r\n\r\nc.c. @vtjnash \r\n","created_at":"2016-07-10T22:46:56Z","updated_at":"2016-07-18T23:52:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fca11c822a992583ea5f12aea6f3a53b5edaabc0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/17363/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/17363/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17363/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/265e9550b0730be4445f888610dbfe6d0070c143","head":{"label":"JuliaLang:yyc/codegen/gc-pass","ref":"yyc/codegen/gc-pass","sha":"265e9550b0730be4445f888610dbfe6d0070c143","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-07-18T20:01:57Z","pushed_at":"2016-07-18T23:31:44Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":409051,"stargazers_count":7264,"watchers_count":7264,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1686,"mirror_url":null,"open_issues_count":1871,"forks":1686,"open_issues":1871,"watchers":7264,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"c81710fd3ddb5415b3d946f97d33bb5b9dc81ce3","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-07-18T20:01:57Z","pushed_at":"2016-07-18T23:31:44Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":409051,"stargazers_count":7264,"watchers_count":7264,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1686,"mirror_url":null,"open_issues_count":1871,"forks":1686,"open_issues":1871,"watchers":7264,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/17363"},"html":{"href":"https://github.com/JuliaLang/julia/pull/17363"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/17363"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/17363/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/17363/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/17363/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/265e9550b0730be4445f888610dbfe6d0070c143"}}}}
{"actor":{"display_login":"yuyichao"}}