[llvm-dev] RFC: We need to explicitly state that some functions are reserved by LLVM

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 27 17:51:35 PDT 2017


2017-10-27 20:31 GMT+02:00 Hal Finkel via llvm-dev <llvm-dev at lists.llvm.org>:
> I agree. Marking external functions from system headers seems like a
> reasonable heuristic. We'd need some heuristic because it's not reasonable
> for the frontend to know about every function the optimizer knows about.
> Over-marking seems okay, however.

Sorry for the naive question, why is it unreasonable for the frontend
to know about special functions? It is the frontend who defines a
source language function's semantics. Clang also has access (or can be
made to can get access) to TargetLibraryInfo, no?

The most straightforward solution seems to have an intrinsic for every
function that has compiler magic, meaning every other function is
ordinary without worrying about hitting a special case (e.g. when
concatenating strings to create new function names when outlining).
Recognizing functions names and assuming they represent the semantics
from libs seems "unclean", tying LLVM IR more closely to C and a
specific platform's libc/libm than necessary.

"malloc" once had an intrinsic. Why was it removed, and recognized by
name instead?

Michael


More information about the llvm-dev mailing list