authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-05 14:33:13+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-05 22:41:06+01:00
logbdca2d0f485682f78ea155df9f9f1cbb5f461ed8
tree688050d6907e1d5c8d82dddb25ff5ea5f0452c23
parente88501a09076e134675160c373bbfb5321038541
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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. #21833 proposes a more fine-grained way to apply nobuiltin.

1 files changed, 4 insertions(+), 0 deletions(-)

src/codegen/llvm.zig+4
...@@ -5576,6 +5576,10 @@ pub const FuncGen = struct {...@@ -5576,6 +5576,10 @@ pub const FuncGen = struct {
5576 var attributes: Builder.FunctionAttributes.Wip = .{};5576 var attributes: Builder.FunctionAttributes.Wip = .{};
5577 defer attributes.deinit(&o.builder);5577 defer attributes.deinit(&o.builder);
55785578
5579 if (self.ng.ownerModule().no_builtin) {
5580 try attributes.addFnAttr(.nobuiltin, &o.builder);
5581 }
5582
5579 switch (modifier) {5583 switch (modifier) {
5580 .auto, .never_tail, .always_tail => {},5584 .auto, .never_tail, .always_tail => {},
5581 .never_inline => try attributes.addFnAttr(.@"noinline", &o.builder),5585 .never_inline => try attributes.addFnAttr(.@"noinline", &o.builder),