llvm.org GIT mirror llvm / afa582f
Merging r182298: ------------------------------------------------------------------------ r182298 | jholewinski | 2013-05-20 09:42:18 -0700 (Mon, 20 May 2013) | 1 line [NVPTX] Fix mis-use of CurrentFnSym in NVPTXAsmPrinter. This was causing a symbol name error in the output PTX. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_33@182828 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
2 changed file(s) with 44 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
701701 else
702702 O << ".func ";
703703 printReturnValStr(F, O);
704 O << *CurrentFnSym << "\n";
704 O << *Mang->getSymbol(F) << "\n";
705705 emitFunctionParamList(F, O);
706706 O << ";\n";
707707 }
811811 continue;
812812 if (F->getIntrinsicID())
813813 continue;
814 CurrentFnSym = Mang->getSymbol(F);
815814 emitDeclaration(F, O);
816815 continue;
817816 }
823822 // The use is in the initialization of a global variable
824823 // that is a function pointer, so print a declaration
825824 // for the original function
826 CurrentFnSym = Mang->getSymbol(F);
827825 emitDeclaration(F, O);
828826 break;
829827 }
830828 // Emit a declaration of this function if the function that
831829 // uses this constant expr has already been seen.
832830 if (useFuncSeen(C, seenMap)) {
833 CurrentFnSym = Mang->getSymbol(F);
834831 emitDeclaration(F, O);
835832 break;
836833 }
850847 // appearing in the module before the callee. so print out
851848 // a declaration for the callee.
852849 if (seenMap.find(caller) != seenMap.end()) {
853 CurrentFnSym = Mang->getSymbol(F);
854850 emitDeclaration(F, O);
855851 break;
856852 }
14721468 int paramIndex, raw_ostream &O) {
14731469 if ((nvptxSubtarget.getDrvInterface() == NVPTX::NVCL) ||
14741470 (nvptxSubtarget.getDrvInterface() == NVPTX::CUDA))
1475 O << *CurrentFnSym << "_param_" << paramIndex;
1471 O << *Mang->getSymbol(I->getParent()) << "_param_" << paramIndex;
14761472 else {
14771473 std::string argName = I->getName();
14781474 const char *p = argName.c_str();
15311527 if (llvm::isImage(*I)) {
15321528 std::string sname = I->getName();
15331529 if (llvm::isImageWriteOnly(*I))
1534 O << "\t.param .surfref " << *CurrentFnSym << "_param_" << paramIndex;
1530 O << "\t.param .surfref " << *Mang->getSymbol(F) << "_param_"
1531 << paramIndex;
15351532 else // Default image is read_only
1536 O << "\t.param .texref " << *CurrentFnSym << "_param_" << paramIndex;
1533 O << "\t.param .texref " << *Mang->getSymbol(F) << "_param_"
1534 << paramIndex;
15371535 } else // Should be llvm::isSampler(*I)
1538 O << "\t.param .samplerref " << *CurrentFnSym << "_param_"
1536 O << "\t.param .samplerref " << *Mang->getSymbol(F) << "_param_"
15391537 << paramIndex;
15401538 continue;
15411539 }
0 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 -drvcuda | FileCheck %s
1
2 ; Function Attrs: nounwind
3 ; CHECK: .entry foo
4 define void @foo(float* nocapture %a) #0 {
5 %val = load float* %a
6 %tan = tail call fastcc float @__nv_fast_tanf(float %val)
7 store float %tan, float* %a
8 ret void
9 }
10
11 ; Function Attrs: nounwind readnone
12 declare float @llvm.nvvm.sin.approx.ftz.f(float) #1
13
14 ; Function Attrs: nounwind readnone
15 declare float @llvm.nvvm.cos.approx.ftz.f(float) #1
16
17 ; Function Attrs: nounwind readnone
18 declare float @llvm.nvvm.div.approx.ftz.f(float, float) #1
19
20 ; Function Attrs: alwaysinline inlinehint nounwind readnone
21 ; CHECK: .func (.param .b32 func_retval0) __nv_fast_tanf
22 define internal fastcc float @__nv_fast_tanf(float %a) #2 {
23 entry:
24 %0 = tail call float @llvm.nvvm.sin.approx.ftz.f(float %a)
25 %1 = tail call float @llvm.nvvm.cos.approx.ftz.f(float %a)
26 %2 = tail call float @llvm.nvvm.div.approx.ftz.f(float %0, float %1)
27 ret float %2
28 }
29
30 attributes #0 = { nounwind }
31 attributes #1 = { nounwind readnone }
32 attributes #2 = { alwaysinline inlinehint nounwind readnone }
33
34 !nvvm.annotations = !{!0}
35
36 !0 = metadata !{void (float*)* @foo, metadata !"kernel", i32 1}