Skip to content

Commit ccd507c

Browse files
authored
Merge pull request #16 from schweitzpgi/release_60
Release 60 - merge latest branch changes from clang
2 parents 5da3ade + 9e0bc92 commit ccd507c

File tree

13 files changed

+153
-8
lines changed

13 files changed

+153
-8
lines changed

docs/UsersManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ Execute ``clang-cl /?`` to see a list of supported options:
27412741
/Gv Set __vectorcall as a default calling convention
27422742
/Gw- Don't put each data item in its own section
27432743
/Gw Put each data item in its own section
2744-
/GX- Enable exception handling
2744+
/GX- Disable exception handling
27452745
/GX Enable exception handling
27462746
/Gy- Don't put each function in its own section
27472747
/Gy Put each function in its own section

include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ def warn_drv_unsupported_abicalls : Warning<
330330
"ignoring '-mabicalls' option as it cannot be used with "
331331
"non position-independent code and the N64 ABI">,
332332
InGroup<OptionIgnored>;
333+
def err_drv_unsupported_indirect_jump_opt : Error<
334+
"'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
335+
def err_drv_unknown_indirect_jump_opt : Error<
336+
"unknown '-mindirect-jump=' option '%0'">;
333337

334338
def warn_drv_unable_to_find_directory_expected : Warning<
335339
"unable to find %0 directory, expected to be in '%1'">,

include/clang/Driver/CLCompatOptions.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _SLASH_Fo : CLCompileJoined<"Fo">,
238238
def _SLASH_GX : CLFlag<"GX">,
239239
HelpText<"Enable exception handling">;
240240
def _SLASH_GX_ : CLFlag<"GX-">,
241-
HelpText<"Enable exception handling">;
241+
HelpText<"Disable exception handling">;
242242
def _SLASH_imsvc : CLJoinedOrSeparate<"imsvc">,
243243
HelpText<"Add directory to system include search path, as if part of %INCLUDE%">,
244244
MetaVarName<"<dir>">;

include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,9 @@ def mbranch_likely : Flag<["-"], "mbranch-likely">, Group<m_Group>,
19921992
IgnoredGCCCompat;
19931993
def mno_branch_likely : Flag<["-"], "mno-branch-likely">, Group<m_Group>,
19941994
IgnoredGCCCompat;
1995+
def mindirect_jump_EQ : Joined<["-"], "mindirect-jump=">,
1996+
Group<m_Group>,
1997+
HelpText<"Change indirect jump instructions to inhibit speculation">;
19951998
def mdsp : Flag<["-"], "mdsp">, Group<m_Group>;
19961999
def mno_dsp : Flag<["-"], "mno-dsp">, Group<m_Group>;
19972000
def mdspr2 : Flag<["-"], "mdspr2">, Group<m_Group>;

lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,22 @@ namespace {
6161

6262
static QualType getType(APValue::LValueBase B) {
6363
if (!B) return QualType();
64-
if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>())
64+
if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>()) {
6565
// FIXME: It's unclear where we're supposed to take the type from, and
66-
// this actually matters for arrays of unknown bound. Using the type of
67-
// the most recent declaration isn't clearly correct in general. Eg:
66+
// this actually matters for arrays of unknown bound. Eg:
6867
//
6968
// extern int arr[]; void f() { extern int arr[3]; };
7069
// constexpr int *p = &arr[1]; // valid?
71-
return cast<ValueDecl>(D->getMostRecentDecl())->getType();
70+
//
71+
// For now, we take the array bound from the most recent declaration.
72+
for (auto *Redecl = cast<ValueDecl>(D->getMostRecentDecl()); Redecl;
73+
Redecl = cast_or_null<ValueDecl>(Redecl->getPreviousDecl())) {
74+
QualType T = Redecl->getType();
75+
if (!T->isIncompleteArrayType())
76+
return T;
77+
}
78+
return D->getType();
79+
}
7280

7381
const Expr *Base = B.get<const Expr*>();
7482

lib/Basic/Targets/AArch64.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,40 @@ ArrayRef<const char *> AArch64TargetInfo::getGCCRegNames() const {
299299
}
300300

301301
const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = {
302-
{{"w31"}, "wsp"}, {{"x29"}, "fp"}, {{"x30"}, "lr"}, {{"x31"}, "sp"},
302+
{{"w31"}, "wsp"},
303+
{{"x31"}, "sp"},
304+
// GCC rN registers are aliases of xN registers.
305+
{{"r0"}, "x0"},
306+
{{"r1"}, "x1"},
307+
{{"r2"}, "x2"},
308+
{{"r3"}, "x3"},
309+
{{"r4"}, "x4"},
310+
{{"r5"}, "x5"},
311+
{{"r6"}, "x6"},
312+
{{"r7"}, "x7"},
313+
{{"r8"}, "x8"},
314+
{{"r9"}, "x9"},
315+
{{"r10"}, "x10"},
316+
{{"r11"}, "x11"},
317+
{{"r12"}, "x12"},
318+
{{"r13"}, "x13"},
319+
{{"r14"}, "x14"},
320+
{{"r15"}, "x15"},
321+
{{"r16"}, "x16"},
322+
{{"r17"}, "x17"},
323+
{{"r18"}, "x18"},
324+
{{"r19"}, "x19"},
325+
{{"r20"}, "x20"},
326+
{{"r21"}, "x21"},
327+
{{"r22"}, "x22"},
328+
{{"r23"}, "x23"},
329+
{{"r24"}, "x24"},
330+
{{"r25"}, "x25"},
331+
{{"r26"}, "x26"},
332+
{{"r27"}, "x27"},
333+
{{"r28"}, "x28"},
334+
{{"r29", "x29"}, "fp"},
335+
{{"r30", "x30"}, "lr"},
303336
// The S/D/Q and W/X registers overlap, but aren't really aliases; we
304337
// don't want to substitute one of these for a different-sized one.
305338
};

lib/Basic/Targets/Mips.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
5454
enum DspRevEnum { NoDSP, DSP1, DSP2 } DspRev;
5555
bool HasMSA;
5656
bool DisableMadd4;
57+
bool UseIndirectJumpHazard;
5758

5859
protected:
5960
bool HasFP64;
@@ -64,7 +65,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
6465
: TargetInfo(Triple), IsMips16(false), IsMicromips(false),
6566
IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
6667
IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
67-
DspRev(NoDSP), HasMSA(false), DisableMadd4(false), HasFP64(false) {
68+
DspRev(NoDSP), HasMSA(false), DisableMadd4(false),
69+
UseIndirectJumpHazard(false), HasFP64(false) {
6870
TheCXXABI.set(TargetCXXABI::GenericMIPS);
6971

7072
setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -338,6 +340,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
338340
IsAbs2008 = false;
339341
else if (Feature == "+noabicalls")
340342
IsNoABICalls = true;
343+
else if (Feature == "+use-indirect-jump-hazard")
344+
UseIndirectJumpHazard = true;
341345
}
342346

343347
setDataLayout();

lib/Driver/ToolChains/Arch/Mips.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,28 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
343343
AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
344344
"nomadd4");
345345
AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt");
346+
347+
if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) {
348+
StringRef Val = StringRef(A->getValue());
349+
if (Val == "hazard") {
350+
Arg *B =
351+
Args.getLastArg(options::OPT_mmicromips, options::OPT_mno_micromips);
352+
Arg *C = Args.getLastArg(options::OPT_mips16, options::OPT_mno_mips16);
353+
354+
if (B && B->getOption().matches(options::OPT_mmicromips))
355+
D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
356+
<< "hazard" << "micromips";
357+
else if (C && C->getOption().matches(options::OPT_mips16))
358+
D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
359+
<< "hazard" << "mips16";
360+
else if (mips::supportsIndirectJumpHazardBarrier(CPUName))
361+
Features.push_back("+use-indirect-jump-hazard");
362+
else
363+
D.Diag(diag::err_drv_unsupported_indirect_jump_opt)
364+
<< "hazard" << CPUName;
365+
} else
366+
D.Diag(diag::err_drv_unknown_indirect_jump_opt) << Val;
367+
}
346368
}
347369

348370
mips::IEEE754Standard mips::getIEEE754Standard(StringRef &CPU) {
@@ -447,3 +469,20 @@ bool mips::shouldUseFPXX(const ArgList &Args, const llvm::Triple &Triple,
447469

448470
return UseFPXX;
449471
}
472+
473+
bool mips::supportsIndirectJumpHazardBarrier(StringRef &CPU) {
474+
// Supporting the hazard barrier method of dealing with indirect
475+
// jumps requires MIPSR2 support.
476+
return llvm::StringSwitch<bool>(CPU)
477+
.Case("mips32r2", true)
478+
.Case("mips32r3", true)
479+
.Case("mips32r5", true)
480+
.Case("mips32r6", true)
481+
.Case("mips64r2", true)
482+
.Case("mips64r3", true)
483+
.Case("mips64r5", true)
484+
.Case("mips64r6", true)
485+
.Case("octeon", true)
486+
.Case("p5600", true)
487+
.Default(false);
488+
}

lib/Driver/ToolChains/Arch/Mips.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
5353
bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,
5454
StringRef CPUName, StringRef ABIName,
5555
mips::FloatABI FloatABI);
56+
bool supportsIndirectJumpHazardBarrier(StringRef &CPU);
5657

5758
} // end namespace mips
5859
} // end namespace target

test/CodeGen/aarch64-inline-asm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,23 @@ void test_constraint_Q(void) {
5454
asm("ldxr %0, %1" : "=r"(val) : "Q"(var));
5555
// CHECK: call i32 asm "ldxr $0, $1", "=r,*Q"(i64* @var)
5656
}
57+
58+
void test_gcc_registers(void) {
59+
register unsigned long reg0 asm("r0") = 0;
60+
register unsigned long reg1 asm("r1") = 1;
61+
register unsigned int reg29 asm("r29") = 2;
62+
register unsigned int reg30 asm("r30") = 3;
63+
64+
// Test remapping register names in register ... asm("rN") statments.
65+
// rN register operands in these two inline assembly lines
66+
// should get renamed to valid AArch64 registers.
67+
asm volatile("hvc #0" : : "r" (reg0), "r" (reg1));
68+
// CHECK: call void asm sideeffect "hvc #0", "{x0},{x1}"
69+
asm volatile("hvc #0" : : "r" (reg29), "r" (reg30));
70+
// CHECK: call void asm sideeffect "hvc #0", "{fp},{lr}"
71+
72+
// rN registers when used without register ... asm("rN") syntax
73+
// should not be remapped.
74+
asm volatile("mov r0, r1\n");
75+
// CHECK: call void asm sideeffect "mov r0, r1\0A", ""()
76+
}

0 commit comments

Comments
 (0)