|
@@ -520,6 +520,13 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
|
|
else if (Features.getStackProtector() == LangOptions::SSPReq)
|
|
else if (Features.getStackProtector() == LangOptions::SSPReq)
|
|
F->addFnAttr(llvm::Attribute::StackProtectReq);
|
|
F->addFnAttr(llvm::Attribute::StackProtectReq);
|
|
|
|
|
|
|
|
+ if (Features.AddressSanitizer) {
|
|
|
|
+ // When AddressSanitizer is enabled, set AddressSafety attribute
|
|
|
|
+ // unless __attribute__((no_address_safety_analysis)) is used.
|
|
|
|
+ if (!D->hasAttr<NoAddressSafetyAnalysisAttr>())
|
|
|
|
+ F->addFnAttr(llvm::Attribute::AddressSafety);
|
|
|
|
+ }
|
|
|
|
+
|
|
unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
|
|
unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
|
|
if (alignment)
|
|
if (alignment)
|
|
F->setAlignment(alignment);
|
|
F->setAlignment(alignment);
|
|
@@ -1019,14 +1026,6 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
|
|
if (ExtraAttrs != llvm::Attribute::None)
|
|
if (ExtraAttrs != llvm::Attribute::None)
|
|
F->addFnAttr(ExtraAttrs);
|
|
F->addFnAttr(ExtraAttrs);
|
|
|
|
|
|
- if (Features.AddressSanitizer) {
|
|
|
|
- // When AddressSanitizer is enabled, set AddressSafety attribute
|
|
|
|
- // unless __attribute__((no_address_safety_analysis)) is used.
|
|
|
|
- const FunctionDecl *FD = cast_or_null<FunctionDecl>(D.getDecl());
|
|
|
|
- if (!FD || !FD->hasAttr<NoAddressSafetyAnalysisAttr>())
|
|
|
|
- F->addFnAttr(llvm::Attribute::AddressSafety);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// This is the first use or definition of a mangled name. If there is a
|
|
// This is the first use or definition of a mangled name. If there is a
|
|
// deferred decl with this name, remember that we need to emit it at the end
|
|
// deferred decl with this name, remember that we need to emit it at the end
|
|
// of the file.
|
|
// of the file.
|