Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions driver/cl_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace opts {
// This vector is filled by parseCommandLine in main.cpp.
llvm::SmallVector<const char *, 32> allArguments;

cl::opt<bool> noBuiltIn(
"fno-builtin",
cl::desc("Disable implicit builtin knowledge of functions"),
cl::ZeroOrMore
);

cl::OptionCategory linkingCategory("Linking options");

// Positional options first, in order:
Expand Down
1 change: 1 addition & 0 deletions driver/cl_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern cl::OptionCategory linkingCategory;
egrep -e '^(cl::|#if|#e)' gen/cl_options.cpp \
| sed -re 's/^(cl::.*)\(.*$/ extern \1;/'
*/
extern cl::opt<bool> noBuiltIn;
extern cl::list<std::string> fileList;
extern cl::list<std::string> runargs;
extern cl::opt<bool> invokedByLDMD;
Expand Down
4 changes: 3 additions & 1 deletion gen/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,9 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
if (opts::isUsingSampleBasedPGOProfile()) {
func->addFnAttr("use-sample-profile");
}

if (opts::noBuiltIn) {
func->addFnAttr("no-built-in");
}
if (fd->hasInlineAsm()) {
// disable frame-pointer-elimination for functions with DMD-style inline asm
func->addFnAttr("frame-pointer", "all");
Expand Down
6 changes: 6 additions & 0 deletions tests/codegen/attr_fno_builtin.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %ldc -c -output-ll -fno-builtin -of=%t.ll %s && FileCheck %s < %t.ll

// CHECK: define {{.*}} @builtin{{.*}} [[ATTR:#[0-9]+]]
extern(C) void builtin() {}

// CHECK: attributes [[ATTR]] = { {{.*}}"no-built-in"{{.*}} }
Loading