Skip to content

Commit bdca2d0

Browse files
committed
llvm: Also apply the nobuiltin attribute for the no_builtin module option.
From `zig build-exe --help`: -fno-builtin Disable implicit builtin knowledge of functions It seems entirely reasonable and even expected that this option should imply both no-builtins on functions (which disables transformation of recognized code patterns to libcalls) and nobuiltin on call sites (which disables transformation of libcalls to intrinsics). We now match Clang's behavior for -fno-builtin. In both cases, we're painting with a fairly broad brush by applying this to an entire module, but it's better than nothing. ziglang#21833 proposes a more fine-grained way to apply nobuiltin.
1 parent e88501a commit bdca2d0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/codegen/llvm.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5576,6 +5576,10 @@ pub const FuncGen = struct {
55765576
var attributes: Builder.FunctionAttributes.Wip = .{};
55775577
defer attributes.deinit(&o.builder);
55785578

5579+
if (self.ng.ownerModule().no_builtin) {
5580+
try attributes.addFnAttr(.nobuiltin, &o.builder);
5581+
}
5582+
55795583
switch (modifier) {
55805584
.auto, .never_tail, .always_tail => {},
55815585
.never_inline => try attributes.addFnAttr(.@"noinline", &o.builder),

0 commit comments

Comments
 (0)