Skip to content
Closed
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
10 changes: 8 additions & 2 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5793,8 +5793,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
}

// Apply the attributes and calling convention.
CI->setAttributes(Attrs);
CI->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));

// If this is a call to an intrinsic, ignore the attributes that would
// normally be deduced from the AST function declaration + the default
// attributes imposed by the language and/or target.
if (!isa<llvm::IntrinsicInst>(CI)) {
CI->setAttributes(Attrs);
CI->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
}

// Apply various metadata.

Expand Down
13 changes: 13 additions & 0 deletions clang/test/CodeGen/llvm-intrinsic-call.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s

float llvm_sin_f32(float) asm("llvm.sin.f32");

float test(float a) {
return llvm_sin_f32(a);
}

// CHECK: call float @llvm.sin.f32(float {{%.+}}){{$}}

// CHECK: declare float @llvm.sin.f32(float) [[ATTRS:#[0-9]+]]

// CHECK: attributes [[ATTRS]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
2 changes: 1 addition & 1 deletion clang/test/CodeGenCUDA/surface.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __attribute__((device)) int suld_2d_zero(surface<void, 2>, int, int) asm("llvm.n

// DEVICE-LABEL: i32 @_Z3fooii(i32 noundef %x, i32 noundef %y)
// DEVICE: call i64 @llvm.nvvm.texsurf.handle.internal.p1(ptr addrspace(1) @surf)
// DEVICE: call noundef i32 @llvm.nvvm.suld.2d.i32.zero(i64 %{{.*}}, i32 noundef %{{.*}}, i32 noundef %{{.*}})
// DEVICE: call i32 @llvm.nvvm.suld.2d.i32.zero(i64 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
__attribute__((device)) int foo(int x, int y) {
return suld_2d_zero(surf, x, y);
}
Expand Down
Loading