{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/485","repository_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd","labels_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/485/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/485/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/485/events","html_url":"https://github.com/rust-lang-nursery/stdsimd/issues/485","id":334701750,"node_id":"MDU6SXNzdWUzMzQ3MDE3NTA=","number":485,"title":"__{read,write}eflags are fishy","user":{"login":"rkruppe","id":2311707,"node_id":"MDQ6VXNlcjIzMTE3MDc=","avatar_url":"https://avatars2.githubusercontent.com/u/2311707?v=4","gravatar_id":"","url":"https://api.github.com/users/rkruppe","html_url":"https://github.com/rkruppe","followers_url":"https://api.github.com/users/rkruppe/followers","following_url":"https://api.github.com/users/rkruppe/following{/other_user}","gists_url":"https://api.github.com/users/rkruppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rkruppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkruppe/subscriptions","organizations_url":"https://api.github.com/users/rkruppe/orgs","repos_url":"https://api.github.com/users/rkruppe/repos","events_url":"https://api.github.com/users/rkruppe/events{/privacy}","received_events_url":"https://api.github.com/users/rkruppe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-22T00:11:57Z","updated_at":"2018-06-23T15:04:18Z","closed_at":null,"author_association":"NONE","body":"https://github.com/rust-lang/rust/issues/51691 has brought these two intrinsics to my attention, and I believe they should not have been included in stdsimd for two reasons:\r\n\r\n- as far as I can tell, they are not officially provided by Intel -- I can't find them in https://software.intel.com/sites/landingpage/IntrinsicsGuide/ -- they're apparently just slipped in sneakily by some compilers (admittedly including icc)\r\n- they are gigantic footguns, I would even go as far as saying they cannot possibly used correctly\r\n\r\nTo elaborate on the second point: as the OP of the linked rust issue already pointed out, usage of these intrinsics is problematic if compiler-generated code uses the eflags register in between `__{read,write}eflags` calls. LLVM does not (and indeed can't really, they way it's architected) provide any way to get anything resembling a guarantee it won't do that. Not for eflags, and not for any other register (except reserved ones which no compiler-generated code touches at all). So these intrinsics are simply impossible to use reliably.\r\n\r\nThe supported way to manually mess with a register that the compiler wants to use is to have *one* big inline asm block that does *all* the manipulation in one go (and declares it as clobbered, if appropriate). https://github.com/rust-lang/rust/issues/51691 mentioned doing that for `x86::has_cpuid`, but I'm pretty sure *any* eflags manipulation would need to ditch the intrinsics in favor of inline asm to be completely correct.\r\n\r\nI realize the possibility of miscompiles caused by this is a bit remote, and there's precedent in C compilers, but could we consider at least deprecating these intrinsics seeing as they're not even documented in the intel intrinsics guide? (Of course, I'd be even happier if they were removed entirely -- luckily they aren't stabilized yet.)"},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/comments/399684966","html_url":"https://github.com/rust-lang-nursery/stdsimd/issues/485#issuecomment-399684966","issue_url":"https://api.github.com/repos/rust-lang-nursery/stdsimd/issues/485","id":399684966,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTY4NDk2Ng==","user":{"login":"gnzlbg","id":904614,"node_id":"MDQ6VXNlcjkwNDYxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/904614?v=4","gravatar_id":"","url":"https://api.github.com/users/gnzlbg","html_url":"https://github.com/gnzlbg","followers_url":"https://api.github.com/users/gnzlbg/followers","following_url":"https://api.github.com/users/gnzlbg/following{/other_user}","gists_url":"https://api.github.com/users/gnzlbg/gists{/gist_id}","starred_url":"https://api.github.com/users/gnzlbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnzlbg/subscriptions","organizations_url":"https://api.github.com/users/gnzlbg/orgs","repos_url":"https://api.github.com/users/gnzlbg/repos","events_url":"https://api.github.com/users/gnzlbg/events{/privacy}","received_events_url":"https://api.github.com/users/gnzlbg/received_events","type":"User","site_admin":false},"created_at":"2018-06-23T15:04:18Z","updated_at":"2018-06-23T15:04:18Z","author_association":"COLLABORATOR","body":"> Okay fair, but if they're not in the guide it seems easier to justify not providing them at all.\r\n\r\nSure, the argument raised back then is that all compilers provided these, but if they cannot work as intended it makes sense to deprecate these and eventually remove them since they are not stable. "}}
{"actor":{"display_login":"gnzlbg"}}