@@ -1037,7 +1037,8 @@ class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
1037
1037
const llvm::Triple &Triple, const CodeGenOptions &Opts);
1038
1038
1039
1039
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
1040
- CodeGen::CodeGenModule &CGM) const override ;
1040
+ CodeGen::CodeGenModule &CGM,
1041
+ ForDefinition_t IsForDefinition) const override ;
1041
1042
1042
1043
int getDwarfEHStackPointer (CodeGen::CodeGenModule &CGM) const override {
1043
1044
// Darwin uses different dwarf register numbers for EH.
@@ -1904,9 +1905,11 @@ bool X86_32TargetCodeGenInfo::isStructReturnInRegABI(
1904
1905
}
1905
1906
}
1906
1907
1907
- void X86_32TargetCodeGenInfo::setTargetAttributes (const Decl *D,
1908
- llvm::GlobalValue *GV,
1909
- CodeGen::CodeGenModule &CGM) const {
1908
+ void X86_32TargetCodeGenInfo::setTargetAttributes (
1909
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM,
1910
+ ForDefinition_t IsForDefinition) const {
1911
+ if (!IsForDefinition)
1912
+ return ;
1910
1913
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
1911
1914
if (FD->hasAttr <X86ForceAlignArgPointerAttr>()) {
1912
1915
// Get the LLVM function.
@@ -2266,7 +2269,10 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo {
2266
2269
}
2267
2270
2268
2271
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
2269
- CodeGen::CodeGenModule &CGM) const override {
2272
+ CodeGen::CodeGenModule &CGM,
2273
+ ForDefinition_t IsForDefinition) const override {
2274
+ if (!IsForDefinition)
2275
+ return ;
2270
2276
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
2271
2277
if (FD->hasAttr <AnyX86InterruptAttr>()) {
2272
2278
llvm::Function *Fn = cast<llvm::Function>(GV);
@@ -2314,7 +2320,8 @@ class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
2314
2320
Win32StructABI, NumRegisterParameters, false ) {}
2315
2321
2316
2322
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
2317
- CodeGen::CodeGenModule &CGM) const override ;
2323
+ CodeGen::CodeGenModule &CGM,
2324
+ ForDefinition_t IsForDefinition) const override ;
2318
2325
2319
2326
void getDependentLibraryOption (llvm::StringRef Lib,
2320
2327
llvm::SmallString<24 > &Opt) const override {
@@ -2342,11 +2349,12 @@ static void addStackProbeSizeTargetAttribute(const Decl *D,
2342
2349
}
2343
2350
}
2344
2351
2345
- void WinX86_32TargetCodeGenInfo::setTargetAttributes (const Decl *D,
2346
- llvm::GlobalValue *GV,
2347
- CodeGen::CodeGenModule &CGM) const {
2348
- X86_32TargetCodeGenInfo::setTargetAttributes (D, GV, CGM);
2349
-
2352
+ void WinX86_32TargetCodeGenInfo::setTargetAttributes (
2353
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM,
2354
+ ForDefinition_t IsForDefinition) const {
2355
+ X86_32TargetCodeGenInfo::setTargetAttributes (D, GV, CGM, IsForDefinition);
2356
+ if (!IsForDefinition)
2357
+ return ;
2350
2358
addStackProbeSizeTargetAttribute (D, GV, CGM);
2351
2359
}
2352
2360
@@ -2357,7 +2365,8 @@ class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
2357
2365
: TargetCodeGenInfo(new WinX86_64ABIInfo(CGT)) {}
2358
2366
2359
2367
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
2360
- CodeGen::CodeGenModule &CGM) const override ;
2368
+ CodeGen::CodeGenModule &CGM,
2369
+ ForDefinition_t IsForDefinition) const override ;
2361
2370
2362
2371
int getDwarfEHStackPointer (CodeGen::CodeGenModule &CGM) const override {
2363
2372
return 7 ;
@@ -2386,11 +2395,12 @@ class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
2386
2395
}
2387
2396
};
2388
2397
2389
- void WinX86_64TargetCodeGenInfo::setTargetAttributes (const Decl *D,
2390
- llvm::GlobalValue *GV,
2391
- CodeGen::CodeGenModule &CGM) const {
2392
- TargetCodeGenInfo::setTargetAttributes (D, GV, CGM);
2393
-
2398
+ void WinX86_64TargetCodeGenInfo::setTargetAttributes (
2399
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM,
2400
+ ForDefinition_t IsForDefinition) const {
2401
+ TargetCodeGenInfo::setTargetAttributes (D, GV, CGM, IsForDefinition);
2402
+ if (!IsForDefinition)
2403
+ return ;
2394
2404
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
2395
2405
if (FD->hasAttr <AnyX86InterruptAttr>()) {
2396
2406
llvm::Function *Fn = cast<llvm::Function>(GV);
@@ -5475,7 +5485,10 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
5475
5485
}
5476
5486
5477
5487
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
5478
- CodeGen::CodeGenModule &CGM) const override {
5488
+ CodeGen::CodeGenModule &CGM,
5489
+ ForDefinition_t IsForDefinition) const override {
5490
+ if (!IsForDefinition)
5491
+ return ;
5479
5492
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
5480
5493
if (!FD)
5481
5494
return ;
@@ -5517,7 +5530,8 @@ class WindowsARMTargetCodeGenInfo : public ARMTargetCodeGenInfo {
5517
5530
: ARMTargetCodeGenInfo(CGT, K) {}
5518
5531
5519
5532
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
5520
- CodeGen::CodeGenModule &CGM) const override ;
5533
+ CodeGen::CodeGenModule &CGM,
5534
+ ForDefinition_t IsForDefinition) const override ;
5521
5535
5522
5536
void getDependentLibraryOption (llvm::StringRef Lib,
5523
5537
llvm::SmallString<24 > &Opt) const override {
@@ -5531,8 +5545,11 @@ class WindowsARMTargetCodeGenInfo : public ARMTargetCodeGenInfo {
5531
5545
};
5532
5546
5533
5547
void WindowsARMTargetCodeGenInfo::setTargetAttributes (
5534
- const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
5535
- ARMTargetCodeGenInfo::setTargetAttributes (D, GV, CGM);
5548
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM,
5549
+ ForDefinition_t IsForDefinition) const {
5550
+ ARMTargetCodeGenInfo::setTargetAttributes (D, GV, CGM, IsForDefinition);
5551
+ if (!IsForDefinition)
5552
+ return ;
5536
5553
addStackProbeSizeTargetAttribute (D, GV, CGM);
5537
5554
}
5538
5555
}
@@ -6061,7 +6078,9 @@ class NVPTXTargetCodeGenInfo : public TargetCodeGenInfo {
6061
6078
: TargetCodeGenInfo(new NVPTXABIInfo(CGT)) {}
6062
6079
6063
6080
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
6064
- CodeGen::CodeGenModule &M) const override ;
6081
+ CodeGen::CodeGenModule &M,
6082
+ ForDefinition_t IsForDefinition) const override ;
6083
+
6065
6084
private:
6066
6085
// Adds a NamedMDNode with F, Name, and Operand as operands, and adds the
6067
6086
// resulting MDNode to the nvvm.annotations MDNode.
@@ -6115,9 +6134,11 @@ Address NVPTXABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
6115
6134
llvm_unreachable (" NVPTX does not support varargs" );
6116
6135
}
6117
6136
6118
- void NVPTXTargetCodeGenInfo::
6119
- setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
6120
- CodeGen::CodeGenModule &M) const {
6137
+ void NVPTXTargetCodeGenInfo::setTargetAttributes (
6138
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M,
6139
+ ForDefinition_t IsForDefinition) const {
6140
+ if (!IsForDefinition)
6141
+ return ;
6121
6142
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
6122
6143
if (!FD) return ;
6123
6144
@@ -6553,14 +6574,17 @@ class MSP430TargetCodeGenInfo : public TargetCodeGenInfo {
6553
6574
MSP430TargetCodeGenInfo (CodeGenTypes &CGT)
6554
6575
: TargetCodeGenInfo(new DefaultABIInfo(CGT)) {}
6555
6576
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
6556
- CodeGen::CodeGenModule &M) const override ;
6577
+ CodeGen::CodeGenModule &M,
6578
+ ForDefinition_t IsForDefinition) const override ;
6557
6579
};
6558
6580
6559
6581
}
6560
6582
6561
- void MSP430TargetCodeGenInfo::setTargetAttributes (const Decl *D,
6562
- llvm::GlobalValue *GV,
6563
- CodeGen::CodeGenModule &M) const {
6583
+ void MSP430TargetCodeGenInfo::setTargetAttributes (
6584
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M,
6585
+ ForDefinition_t IsForDefinition) const {
6586
+ if (!IsForDefinition)
6587
+ return ;
6564
6588
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
6565
6589
if (const MSP430InterruptAttr *attr = FD->getAttr <MSP430InterruptAttr>()) {
6566
6590
// Handle 'interrupt' attribute:
@@ -6619,10 +6643,21 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
6619
6643
}
6620
6644
6621
6645
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
6622
- CodeGen::CodeGenModule &CGM) const override {
6646
+ CodeGen::CodeGenModule &CGM,
6647
+ ForDefinition_t IsForDefinition) const override {
6623
6648
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
6624
6649
if (!FD) return ;
6625
6650
llvm::Function *Fn = cast<llvm::Function>(GV);
6651
+
6652
+ if (FD->hasAttr <MipsLongCallAttr>())
6653
+ Fn->addFnAttr (" long-call" );
6654
+ else if (FD->hasAttr <MipsShortCallAttr>())
6655
+ Fn->addFnAttr (" short-call" );
6656
+
6657
+ // Other attributes do not have a meaning for declarations.
6658
+ if (!IsForDefinition)
6659
+ return ;
6660
+
6626
6661
if (FD->hasAttr <Mips16Attr>()) {
6627
6662
Fn->addFnAttr (" mips16" );
6628
6663
}
@@ -6992,7 +7027,10 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo {
6992
7027
: TargetCodeGenInfo(new DefaultABIInfo(CGT)) { }
6993
7028
6994
7029
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
6995
- CodeGen::CodeGenModule &CGM) const override {
7030
+ CodeGen::CodeGenModule &CGM,
7031
+ ForDefinition_t IsForDefinition) const override {
7032
+ if (!IsForDefinition)
7033
+ return ;
6996
7034
const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
6997
7035
if (!FD) return ;
6998
7036
auto *Fn = cast<llvm::Function>(GV);
@@ -7020,11 +7058,15 @@ class TCETargetCodeGenInfo : public DefaultTargetCodeGenInfo {
7020
7058
: DefaultTargetCodeGenInfo(CGT) {}
7021
7059
7022
7060
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
7023
- CodeGen::CodeGenModule &M) const override ;
7061
+ CodeGen::CodeGenModule &M,
7062
+ ForDefinition_t IsForDefinition) const override ;
7024
7063
};
7025
7064
7026
7065
void TCETargetCodeGenInfo::setTargetAttributes (
7027
- const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const {
7066
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M,
7067
+ ForDefinition_t IsForDefinition) const {
7068
+ if (!IsForDefinition)
7069
+ return ;
7028
7070
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
7029
7071
if (!FD) return ;
7030
7072
@@ -7364,7 +7406,8 @@ class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo {
7364
7406
AMDGPUTargetCodeGenInfo (CodeGenTypes &CGT)
7365
7407
: TargetCodeGenInfo(new AMDGPUABIInfo(CGT)) {}
7366
7408
void setTargetAttributes (const Decl *D, llvm::GlobalValue *GV,
7367
- CodeGen::CodeGenModule &M) const override ;
7409
+ CodeGen::CodeGenModule &M,
7410
+ ForDefinition_t IsForDefinition) const override ;
7368
7411
unsigned getOpenCLKernelCallingConv () const override ;
7369
7412
7370
7413
llvm::Constant *getNullPointer (const CodeGen::CodeGenModule &CGM,
@@ -7380,9 +7423,10 @@ class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo {
7380
7423
}
7381
7424
7382
7425
void AMDGPUTargetCodeGenInfo::setTargetAttributes (
7383
- const Decl *D,
7384
- llvm::GlobalValue *GV,
7385
- CodeGen::CodeGenModule &M) const {
7426
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M,
7427
+ ForDefinition_t IsForDefinition) const {
7428
+ if (!IsForDefinition)
7429
+ return ;
7386
7430
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
7387
7431
if (!FD)
7388
7432
return ;
0 commit comments