Skip to content

Commit 95385ef

Browse files
committed
merge main into amd-stg-open
Change-Id: I12a3cd880fadbc1d9a86e29a6345afe694e89111
2 parents 7f8d562 + 42204c9 commit 95385ef

File tree

13 files changed

+219
-124
lines changed

13 files changed

+219
-124
lines changed

.github/workflows/scorecard.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
analysis:
2323
name: Scorecard analysis
2424
runs-on: ubuntu-latest
25+
if: github.repository == 'llvm/llvm-project'
2526
permissions:
2627
# Needed to upload the results to code-scanning dashboard.
2728
security-events: write

clang/include/clang/CodeGen/ConstantInitBuilder.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ class ConstantAggregateBuilderBase {
204204
add(llvm::ConstantPointerNull::get(ptrTy));
205205
}
206206

207-
/// Add a bitcast of a value to a specific type.
208-
void addBitCast(llvm::Constant *value, llvm::Type *type) {
209-
add(llvm::ConstantExpr::getBitCast(value, type));
210-
}
211-
212207
/// Add a bunch of new values to this initializer.
213208
void addAll(llvm::ArrayRef<llvm::Constant *> values) {
214209
assert(!Finished && "cannot add more values after finishing builder");

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
187187
Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
188188
Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
189189
DefineStd(Builder, "unix", Opts);
190+
if (this->HasFloat128)
191+
Builder.defineMacro("__FLOAT128__");
190192

191193
// On FreeBSD, wchar_t contains the number of the code point as
192194
// used by the character set of the locale. These character sets are
@@ -204,9 +206,11 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
204206
FreeBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
205207
: OSTargetInfo<Target>(Triple, Opts) {
206208
switch (Triple.getArch()) {
207-
default:
208209
case llvm::Triple::x86:
209210
case llvm::Triple::x86_64:
211+
this->HasFloat128 = true;
212+
[[fallthrough]];
213+
default:
210214
this->MCountName = ".mcount";
211215
break;
212216
case llvm::Triple::mips:
@@ -372,12 +376,22 @@ class LLVM_LIBRARY_VISIBILITY NetBSDTargetInfo : public OSTargetInfo<Target> {
372376
Builder.defineMacro("__unix__");
373377
if (Opts.POSIXThreads)
374378
Builder.defineMacro("_REENTRANT");
379+
if (this->HasFloat128)
380+
Builder.defineMacro("__FLOAT128__");
375381
}
376382

377383
public:
378384
NetBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
379385
: OSTargetInfo<Target>(Triple, Opts) {
380386
this->MCountName = "__mcount";
387+
switch (Triple.getArch()) {
388+
default:
389+
break;
390+
case llvm::Triple::x86:
391+
case llvm::Triple::x86_64:
392+
this->HasFloat128 = true;
393+
break;
394+
}
381395
}
382396
};
383397

clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,9 +1725,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
17251725
SmallVector<ObjCMethodDecl*, 16> ClassMethods;
17261726
ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
17271727
OID->classmeth_end());
1728-
metaclassFields.addBitCast(
1729-
GenerateMethodList(className, "", ClassMethods, true),
1730-
PtrTy);
1728+
metaclassFields.add(
1729+
GenerateMethodList(className, "", ClassMethods, true));
17311730
}
17321731
// void *dtable;
17331732
metaclassFields.addNullPointer(PtrTy);
@@ -1894,9 +1893,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
18941893
if (InstanceMethods.size() == 0)
18951894
classFields.addNullPointer(PtrTy);
18961895
else
1897-
classFields.addBitCast(
1898-
GenerateMethodList(className, "", InstanceMethods, false),
1899-
PtrTy);
1896+
classFields.add(
1897+
GenerateMethodList(className, "", InstanceMethods, false));
1898+
19001899
// void *dtable;
19011900
classFields.addNullPointer(PtrTy);
19021901
// IMP cxx_construct;
@@ -2887,14 +2886,14 @@ GenerateMethodList(StringRef ClassName,
28872886
assert(FnPtr && "Can't generate metadata for method that doesn't exist");
28882887
auto Method = MethodArray.beginStruct(ObjCMethodTy);
28892888
if (isV2ABI) {
2890-
Method.addBitCast(FnPtr, IMPTy);
2889+
Method.add(FnPtr);
28912890
Method.add(GetConstantSelector(OMD->getSelector(),
28922891
Context.getObjCEncodingForMethodDecl(OMD)));
28932892
Method.add(MakeConstantString(Context.getObjCEncodingForMethodDecl(OMD, true)));
28942893
} else {
28952894
Method.add(MakeConstantString(OMD->getSelector().getAsString()));
28962895
Method.add(MakeConstantString(Context.getObjCEncodingForMethodDecl(OMD)));
2897-
Method.addBitCast(FnPtr, IMPTy);
2896+
Method.add(FnPtr);
28982897
}
28992898
Method.finishAndAddTo(MethodArray);
29002899
}
@@ -2993,7 +2992,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
29932992
// Fill in the structure
29942993

29952994
// isa
2996-
Elements.addBitCast(MetaClass, PtrToInt8Ty);
2995+
Elements.add(MetaClass);
29972996
// super_class
29982997
Elements.add(SuperClass);
29992998
// name
@@ -3022,7 +3021,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
30223021
// sibling_class
30233022
Elements.add(NULLPtr);
30243023
// protocols
3025-
Elements.addBitCast(Protocols, PtrTy);
3024+
Elements.add(Protocols);
30263025
// gc_object_type
30273026
Elements.add(NULLPtr);
30283027
// abi_version
@@ -3094,7 +3093,7 @@ CGObjCGNU::GenerateProtocolList(ArrayRef<std::string> Protocols) {
30943093
} else {
30953094
protocol = value->getValue();
30963095
}
3097-
Elements.addBitCast(protocol, PtrToInt8Ty);
3096+
Elements.add(protocol);
30983097
}
30993098
Elements.finishAndAddTo(ProtocolList);
31003099
return ProtocolList.finishAndCreateGlobal(".objc_protocol_list",
@@ -3224,11 +3223,9 @@ void CGObjCGNU::GenerateProtocolHolderCategory() {
32243223
Elements.add(MakeConstantString(CategoryName));
32253224
Elements.add(MakeConstantString(ClassName));
32263225
// Instance method list
3227-
Elements.addBitCast(GenerateMethodList(
3228-
ClassName, CategoryName, {}, false), PtrTy);
3226+
Elements.add(GenerateMethodList(ClassName, CategoryName, {}, false));
32293227
// Class method list
3230-
Elements.addBitCast(GenerateMethodList(
3231-
ClassName, CategoryName, {}, true), PtrTy);
3228+
Elements.add(GenerateMethodList(ClassName, CategoryName, {}, true));
32323229

32333230
// Protocol list
32343231
ConstantInitBuilder ProtocolListBuilder(CGM);
@@ -3238,13 +3235,11 @@ void CGObjCGNU::GenerateProtocolHolderCategory() {
32383235
auto ProtocolElements = ProtocolList.beginArray(PtrTy);
32393236
for (auto iter = ExistingProtocols.begin(), endIter = ExistingProtocols.end();
32403237
iter != endIter ; iter++) {
3241-
ProtocolElements.addBitCast(iter->getValue(), PtrTy);
3238+
ProtocolElements.add(iter->getValue());
32423239
}
32433240
ProtocolElements.finishAndAddTo(ProtocolList);
3244-
Elements.addBitCast(
3245-
ProtocolList.finishAndCreateGlobal(".objc_protocol_list",
3246-
CGM.getPointerAlign()),
3247-
PtrTy);
3241+
Elements.add(ProtocolList.finishAndCreateGlobal(".objc_protocol_list",
3242+
CGM.getPointerAlign()));
32483243
Categories.push_back(
32493244
Elements.finishAndCreateGlobal("", CGM.getPointerAlign()));
32503245
}
@@ -3321,27 +3316,26 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
33213316
SmallVector<ObjCMethodDecl*, 16> InstanceMethods;
33223317
InstanceMethods.insert(InstanceMethods.begin(), OCD->instmeth_begin(),
33233318
OCD->instmeth_end());
3324-
Elements.addBitCast(
3325-
GenerateMethodList(ClassName, CategoryName, InstanceMethods, false),
3326-
PtrTy);
3319+
Elements.add(
3320+
GenerateMethodList(ClassName, CategoryName, InstanceMethods, false));
3321+
33273322
// Class method list
33283323

33293324
SmallVector<ObjCMethodDecl*, 16> ClassMethods;
33303325
ClassMethods.insert(ClassMethods.begin(), OCD->classmeth_begin(),
33313326
OCD->classmeth_end());
3332-
Elements.addBitCast(
3333-
GenerateMethodList(ClassName, CategoryName, ClassMethods, true),
3334-
PtrTy);
3327+
Elements.add(GenerateMethodList(ClassName, CategoryName, ClassMethods, true));
3328+
33353329
// Protocol list
3336-
Elements.addBitCast(GenerateCategoryProtocolList(CatDecl), PtrTy);
3330+
Elements.add(GenerateCategoryProtocolList(CatDecl));
33373331
if (isRuntime(ObjCRuntime::GNUstep, 2)) {
33383332
const ObjCCategoryDecl *Category =
33393333
Class->FindCategoryDeclaration(OCD->getIdentifier());
33403334
if (Category) {
33413335
// Instance properties
3342-
Elements.addBitCast(GeneratePropertyList(OCD, Category, false), PtrTy);
3336+
Elements.add(GeneratePropertyList(OCD, Category, false));
33433337
// Class properties
3344-
Elements.addBitCast(GeneratePropertyList(OCD, Category, true), PtrTy);
3338+
Elements.add(GeneratePropertyList(OCD, Category, true));
33453339
} else {
33463340
Elements.addNullPointer(PtrTy);
33473341
Elements.addNullPointer(PtrTy);
@@ -3677,11 +3671,9 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
36773671
GenerateProtocolHolderCategory();
36783672

36793673
llvm::StructType *selStructTy = dyn_cast<llvm::StructType>(SelectorElemTy);
3680-
llvm::Type *selStructPtrTy = SelectorTy;
36813674
if (!selStructTy) {
36823675
selStructTy = llvm::StructType::get(CGM.getLLVMContext(),
36833676
{ PtrToInt8Ty, PtrToInt8Ty });
3684-
selStructPtrTy = llvm::PointerType::getUnqual(selStructTy);
36853677
}
36863678

36873679
// Generate statics list:
@@ -3785,7 +3777,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
37853777
// Number of static selectors
37863778
symtab.addInt(LongTy, selectorCount);
37873779

3788-
symtab.addBitCast(selectorList, selStructPtrTy);
3780+
symtab.add(selectorList);
37893781

37903782
// Number of classes defined.
37913783
symtab.addInt(CGM.Int16Ty, Classes.size());

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,12 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
495495
if (CurFnInfo->getMaxVectorWidth() > LargestVectorWidth)
496496
LargestVectorWidth = CurFnInfo->getMaxVectorWidth();
497497

498-
// Add the required-vector-width attribute. This contains the max width from:
498+
// Add the min-legal-vector-width attribute. This contains the max width from:
499499
// 1. min-vector-width attribute used in the source program.
500500
// 2. Any builtins used that have a vector width specified.
501501
// 3. Values passed in and out of inline assembly.
502502
// 4. Width of vector arguments and return types for this function.
503-
// 5. Width of vector aguments and return types for functions called by this
503+
// 5. Width of vector arguments and return types for functions called by this
504504
// function.
505505
if (getContext().getTargetInfo().getTriple().isX86())
506506
CurFn->addFnAttr("min-legal-vector-width",

clang/test/CodeGenCXX/float128-declarations.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
77
// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++11 \
88
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
9-
// RUN: %clang_cc1 -emit-llvm -triple i686-pc-openbsd -std=c++11 \
9+
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-freebsd -std=c++11 \
1010
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
11-
// RUN: %clang_cc1 -emit-llvm -triple amd64-pc-openbsd -std=c++11 \
11+
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-freebsd -std=c++11 \
12+
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
13+
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-netbsd -std=c++11 \
14+
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
15+
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-netbsd -std=c++11 \
16+
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
17+
// RUN: %clang_cc1 -emit-llvm -triple i386-unknown-openbsd -std=c++11 \
18+
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
19+
// RUN: %clang_cc1 -emit-llvm -triple amd64-unknown-openbsd -std=c++11 \
1220
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86
1321
// RUN: %clang_cc1 -emit-llvm -triple i386-pc-solaris2.11 -std=c++11 \
1422
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,16 +2188,6 @@ class TargetInstrInfo : public MCInstrInfo {
21882188
// Get the call frame size just before MI.
21892189
unsigned getCallFrameSizeAt(MachineInstr &MI) const;
21902190

2191-
/// Fills in the necessary MachineOperands to refer to a frame index.
2192-
/// The best way to understand this is to print `asm(""::"m"(x));` after
2193-
/// finalize-isel. Example:
2194-
/// INLINEASM ... 262190 /* mem:m */, %stack.0.x.addr, 1, $noreg, 0, $noreg
2195-
/// we would add placeholders for: ^ ^ ^ ^
2196-
virtual void
2197-
getFrameIndexOperands(SmallVectorImpl<MachineOperand> &Ops) const {
2198-
llvm_unreachable("unknown number of operands necessary");
2199-
}
2200-
22012191
private:
22022192
mutable std::unique_ptr<MIRFormatter> Formatter;
22032193
unsigned CallFrameSetupOpcode, CallFrameDestroyOpcode;

llvm/include/llvm/IR/DebugInfo.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class DbgDeclareInst;
3535
class DbgValueInst;
3636
class DbgVariableIntrinsic;
3737
class DbgDefKillIntrinsic;
38+
class DPValue;
3839
class Instruction;
3940
class Module;
4041

@@ -43,10 +44,12 @@ class Module;
4344
TinyPtrVector<DbgDeclareInst *> FindDbgDeclareUses(Value *V);
4445

4546
/// Finds the llvm.dbg.value intrinsics describing a value.
46-
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V);
47+
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,
48+
Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
4749

4850
/// Finds the debug info intrinsics describing a value.
49-
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V);
51+
void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts,
52+
Value *V, SmallVectorImpl<DPValue *> *DPValues = nullptr);
5053

5154
/// Find subprogram that is enclosing this scope.
5255
DISubprogram *getDISubprogram(const MDNode *Scope);

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -565,64 +565,6 @@ static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
565565
return NewMI;
566566
}
567567

568-
static void foldInlineAsmMemOperand(MachineInstr *MI, unsigned OpNo, int FI,
569-
const TargetInstrInfo &TII) {
570-
MachineOperand &MO = MI->getOperand(OpNo);
571-
const VirtRegInfo &RI = AnalyzeVirtRegInBundle(*MI, MO.getReg());
572-
573-
// If the machine operand is tied, untie it first.
574-
if (MO.isTied()) {
575-
unsigned TiedTo = MI->findTiedOperandIdx(OpNo);
576-
MI->untieRegOperand(OpNo);
577-
// Intentional recursion!
578-
foldInlineAsmMemOperand(MI, TiedTo, FI, TII);
579-
}
580-
581-
// Change the operand from a register to a frame index.
582-
MO.ChangeToFrameIndex(FI, MO.getTargetFlags());
583-
584-
SmallVector<MachineOperand, 4> NewOps;
585-
TII.getFrameIndexOperands(NewOps);
586-
assert(!NewOps.empty() && "getFrameIndexOperands didn't create any operands");
587-
MI->insert(MI->operands_begin() + OpNo + 1, NewOps);
588-
589-
// Change the previous operand to a MemKind InlineAsm::Flag. The second param
590-
// is the per-target number of operands that represent the memory operand
591-
// excluding this one (MD). This includes MO.
592-
InlineAsm::Flag F(InlineAsm::Kind::Mem, NewOps.size() + 1);
593-
F.setMemConstraint(InlineAsm::ConstraintCode::m);
594-
MachineOperand &MD = MI->getOperand(OpNo - 1);
595-
MD.setImm(F);
596-
597-
// Update mayload/maystore metadata.
598-
MachineOperand &ExtraMO = MI->getOperand(InlineAsm::MIOp_ExtraInfo);
599-
if (RI.Reads)
600-
ExtraMO.setImm(ExtraMO.getImm() | InlineAsm::Extra_MayLoad);
601-
if (RI.Writes)
602-
ExtraMO.setImm(ExtraMO.getImm() | InlineAsm::Extra_MayStore);
603-
}
604-
605-
// Returns nullptr if not possible to fold.
606-
static MachineInstr *foldInlineAsmMemOperand(MachineInstr &MI,
607-
ArrayRef<unsigned> Ops, int FI,
608-
const TargetInstrInfo &TII) {
609-
assert(MI.isInlineAsm() && "wrong opcode");
610-
if (Ops.size() > 1)
611-
return nullptr;
612-
unsigned Op = Ops[0];
613-
assert(Op && "should never be first operand");
614-
assert(MI.getOperand(Op).isReg() && "shouldn't be folding non-reg operands");
615-
616-
if (!MI.mayFoldInlineAsmRegOp(Op))
617-
return nullptr;
618-
619-
MachineInstr &NewMI = TII.duplicate(*MI.getParent(), MI.getIterator(), MI);
620-
621-
foldInlineAsmMemOperand(&NewMI, Op, FI, TII);
622-
623-
return &NewMI;
624-
}
625-
626568
MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
627569
ArrayRef<unsigned> Ops, int FI,
628570
LiveIntervals *LIS,
@@ -670,8 +612,6 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
670612
NewMI = foldPatchpoint(MF, MI, Ops, FI, *this);
671613
if (NewMI)
672614
MBB->insert(MI, NewMI);
673-
} else if (MI.isInlineAsm()) {
674-
NewMI = foldInlineAsmMemOperand(MI, Ops, FI, *this);
675615
} else {
676616
// Ask the target to do the actual folding.
677617
NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, FI, LIS, VRM);
@@ -743,8 +683,6 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
743683
NewMI = foldPatchpoint(MF, MI, Ops, FrameIndex, *this);
744684
if (NewMI)
745685
NewMI = &*MBB.insert(MI, NewMI);
746-
} else if (MI.isInlineAsm() && isLoadFromStackSlot(LoadMI, FrameIndex)) {
747-
NewMI = foldInlineAsmMemOperand(MI, Ops, FrameIndex, *this);
748686
} else {
749687
// Ask the target to do the actual folding.
750688
NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, LoadMI, LIS);

0 commit comments

Comments
 (0)