Skip to content

Commit 5d09cf0

Browse files
necipfazilPrabhuk
authored andcommitted
Address review comments. Break llvm and clang patches.
Created using spr 1.3.6-beta.1
2 parents 086baf0 + 746e03c commit 5d09cf0

File tree

15 files changed

+33
-435
lines changed

15 files changed

+33
-435
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "clang/AST/Decl.h"
2626
#include "clang/AST/DeclCXX.h"
2727
#include "clang/AST/DeclObjC.h"
28-
#include "clang/AST/Type.h"
2928
#include "clang/Basic/CodeGenOptions.h"
3029
#include "clang/Basic/TargetInfo.h"
3130
#include "clang/CodeGen/CGFunctionInfo.h"
@@ -5078,11 +5077,6 @@ static unsigned getMaxVectorWidth(const llvm::Type *Ty) {
50785077
return MaxVectorWidth;
50795078
}
50805079

5081-
static bool isCXXDeclType(const FunctionDecl *FD) {
5082-
return isa<CXXConstructorDecl>(FD) || isa<CXXMethodDecl>(FD) ||
5083-
isa<CXXDestructorDecl>(FD);
5084-
}
5085-
50865080
RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
50875081
const CGCallee &Callee,
50885082
ReturnValueSlot ReturnValue,
@@ -5771,38 +5765,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
57715765
AllocAlignAttrEmitter AllocAlignAttrEmitter(*this, TargetDecl, CallArgs);
57725766
Attrs = AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
57735767

5774-
if (CGM.getCodeGenOpts().CallGraphSection) {
5775-
// Create operand bundle only for indirect calls, not for all
5776-
if (callOrInvoke && *callOrInvoke && (*callOrInvoke)->isIndirectCall()) {
5777-
5778-
assert((TargetDecl && TargetDecl->getFunctionType() ||
5779-
Callee.getAbstractInfo().getCalleeFunctionProtoType()) &&
5780-
"cannot find callsite type");
5781-
5782-
QualType CST;
5783-
if (TargetDecl && TargetDecl->getFunctionType())
5784-
CST = QualType(TargetDecl->getFunctionType(), 0);
5785-
else if (const auto *FPT =
5786-
Callee.getAbstractInfo().getCalleeFunctionProtoType())
5787-
CST = QualType(FPT, 0);
5788-
5789-
if (!CST.isNull()) {
5790-
auto *TypeIdMD = CGM.CreateMetadataIdentifierGeneralized(CST);
5791-
auto *TypeIdMDVal =
5792-
llvm::MetadataAsValue::get(getLLVMContext(), TypeIdMD);
5793-
BundleList.emplace_back("type", TypeIdMDVal);
5794-
}
5795-
5796-
// Set type identifier metadata of indirect calls for call graph section.
5797-
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
5798-
// Type id metadata is set only for C/C++ contexts.
5799-
if (isCXXDeclType(FD)) {
5800-
CGM.CreateFunctionTypeMetadataForIcall(FD->getType(), *callOrInvoke);
5801-
}
5802-
}
5803-
}
5804-
}
5805-
58065768
// Emit the actual call/invoke instruction.
58075769
llvm::CallBase *CI;
58085770
if (!InvokeDest) {

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6173,12 +6173,6 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
61736173
if (CallOrInvoke)
61746174
*CallOrInvoke = LocalCallOrInvoke;
61756175

6176-
// Set type identifier metadata of indirect calls for call graph section.
6177-
if (CGM.getCodeGenOpts().CallGraphSection && LocalCallOrInvoke &&
6178-
LocalCallOrInvoke->isIndirectCall())
6179-
CGM.CreateFunctionTypeMetadataForIcall(QualType(FnType, 0),
6180-
LocalCallOrInvoke);
6181-
61826176
return Call;
61836177
}
61846178

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,8 +2214,9 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
22142214

22152215
llvm::CallBase *CallSite;
22162216
CGCallee Callee = CGCallee::forDirect(BitcastFn);
2217-
RValue rvalue =
2218-
CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs, &CallSite);
2217+
RValue rvalue = CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs,
2218+
&CallSite);
2219+
22192220
// Mark the call as noreturn if the method is marked noreturn and the
22202221
// receiver cannot be null.
22212222
if (Method && Method->hasAttr<NoReturnAttr>() && !ReceiverCanBeNull) {

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,9 +2622,8 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
26222622

26232623
// In the cross-dso CFI mode with canonical jump tables, we want !type
26242624
// attributes on definitions only.
2625-
if ((CodeGenOpts.SanitizeCfiCrossDso &&
2626-
CodeGenOpts.SanitizeCfiCanonicalJumpTables) ||
2627-
CodeGenOpts.CallGraphSection) {
2625+
if (CodeGenOpts.SanitizeCfiCrossDso &&
2626+
CodeGenOpts.SanitizeCfiCanonicalJumpTables) {
26282627
if (auto *FD = dyn_cast<FunctionDecl>(D)) {
26292628
// Skip available_externally functions. They won't be codegen'ed in the
26302629
// current module anyway.
@@ -2814,17 +2813,7 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const NamedDecl *ND) {
28142813

28152814
void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
28162815
llvm::Function *F) {
2817-
bool EmittedMDIdGeneralized = false;
2818-
if (CodeGenOpts.CallGraphSection &&
2819-
(!F->hasLocalLinkage() ||
2820-
F->getFunction().hasAddressTaken(nullptr, /*IgnoreCallbackUses=*/true,
2821-
/*IgnoreAssumeLikeCalls=*/true,
2822-
/*IgnoreLLVMUsed=*/false))) {
2823-
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
2824-
EmittedMDIdGeneralized = true;
2825-
}
2826-
2827-
// Add additional metadata only if we are checking indirect calls with CFI.
2816+
// Only if we are checking indirect calls.
28282817
if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
28292818
return;
28302819

@@ -2835,27 +2824,14 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
28352824

28362825
llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
28372826
F->addTypeMetadata(0, MD);
2838-
// Add the generalized identifier if not added already.
2839-
if (!EmittedMDIdGeneralized)
2840-
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
2827+
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
28412828

28422829
// Emit a hash-based bit set entry for cross-DSO calls.
28432830
if (CodeGenOpts.SanitizeCfiCrossDso)
28442831
if (auto CrossDsoTypeId = CreateCrossDsoCfiTypeId(MD))
28452832
F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId));
28462833
}
28472834

2848-
void CodeGenModule::CreateFunctionTypeMetadataForIcall(const QualType &QT,
2849-
llvm::CallBase *CB) {
2850-
// Only if needed for call graph section and only for indirect calls.
2851-
if (!CodeGenOpts.CallGraphSection || !CB || !CB->isIndirectCall())
2852-
return;
2853-
2854-
auto *MD = CreateMetadataIdentifierGeneralized(QT);
2855-
auto *MDN = llvm::MDNode::get(getLLVMContext(), MD);
2856-
CB->setMetadata(llvm::LLVMContext::MD_type, MDN);
2857-
}
2858-
28592835
void CodeGenModule::setKCFIType(const FunctionDecl *FD, llvm::Function *F) {
28602836
llvm::LLVMContext &Ctx = F->getContext();
28612837
llvm::MDBuilder MDB(Ctx);
@@ -2983,8 +2959,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
29832959
// are non-canonical then we need type metadata in order to produce the local
29842960
// jump table.
29852961
if (!CodeGenOpts.SanitizeCfiCrossDso ||
2986-
!CodeGenOpts.SanitizeCfiCanonicalJumpTables ||
2987-
CodeGenOpts.CallGraphSection)
2962+
!CodeGenOpts.SanitizeCfiCanonicalJumpTables)
29882963
CreateFunctionTypeMetadataForIcall(FD, F);
29892964

29902965
if (LangOpts.Sanitize.has(SanitizerKind::KCFI))

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,10 +1572,6 @@ class CodeGenModule : public CodeGenTypeCache {
15721572
void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
15731573
llvm::Function *F);
15741574

1575-
/// Create and attach type metadata to the given call.
1576-
void CreateFunctionTypeMetadataForIcall(const QualType &QT,
1577-
llvm::CallBase *CB);
1578-
15791575
/// Set type metadata to the given function.
15801576
void setKCFIType(const FunctionDecl *FD, llvm::Function *F);
15811577

clang/test/CodeGen/call-graph-section-1.cpp

Lines changed: 0 additions & 110 deletions
This file was deleted.

clang/test/CodeGen/call-graph-section-2.cpp

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)