Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -657,6 +657,8 @@ // possible. if (!A && !B) return true; + if (Res.getConstant() == 0 && (!A || !B)) + return true; } } Index: test/CodeGen/X86/macho-alias-of-alias.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/macho-alias-of-alias.ll @@ -0,0 +1,14 @@ +; RUN: llc -filetype=obj < %s +; PR33316 + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.12.0" + +@a = private constant i8 42 +@b = private alias i8, i8* @a +@c = private alias i8, i8* @b + +define i8* @f(i64 %x) { + %y = getelementptr i8, i8* @c, i64 %x + ret i8* %y +} Index: test/MC/MachO/variable-exprs.s =================================================================== --- test/MC/MachO/variable-exprs.s +++ test/MC/MachO/variable-exprs.s @@ -110,8 +110,8 @@ // CHECK-I386: 0x2C 0 2 0 GENERIC_RELOC_VANILLA 0 __data // CHECK-I386: 0x28 0 2 0 GENERIC_RELOC_VANILLA 0 __data // CHECK-I386: 0x24 0 2 1 GENERIC_RELOC_VANILLA 0 d3 -// CHECK-I386: 0x20 0 2 1 GENERIC_RELOC_VANILLA 0 d2 -// CHECK-I386: 0x1C 0 2 1 GENERIC_RELOC_VANILLA 0 d +// CHECK-I386: 0x20 0 2 1 GENERIC_RELOC_VANILLA 0 d{{$}} +// CHECK-I386: 0x1C 0 2 1 GENERIC_RELOC_VANILLA 0 d{{$}} // CHECK-I386: 0x18 0 2 n/a GENERIC_RELOC_VANILLA 1 0x5 // CHECK-I386: 0x14 0 2 0 GENERIC_RELOC_VANILLA 0 __data // CHECK-I386: 0x10 0 2 0 GENERIC_RELOC_VANILLA 0 __data @@ -319,8 +319,8 @@ // CHECK-X86_64: 0x2C 0 2 1 X86_64_RELOC_UNSIGNED 0 g // CHECK-X86_64: 0x28 0 2 1 X86_64_RELOC_UNSIGNED 0 f // CHECK-X86_64: 0x24 0 2 1 X86_64_RELOC_UNSIGNED 0 d3 -// CHECK-X86_64: 0x20 0 2 1 X86_64_RELOC_UNSIGNED 0 d2 -// CHECK-X86_64: 0x1C 0 2 1 X86_64_RELOC_UNSIGNED 0 d +// CHECK-X86_64: 0x20 0 2 1 X86_64_RELOC_UNSIGNED 0 d{{$}} +// CHECK-X86_64: 0x1C 0 2 1 X86_64_RELOC_UNSIGNED 0 d{{$}} // CHECK-X86_64: 0x18 0 2 1 X86_64_RELOC_UNSIGNED 0 a // CHECK-X86_64: 0x14 0 2 1 X86_64_RELOC_UNSIGNED 0 e // CHECK-X86_64: 0x10 0 2 1 X86_64_RELOC_UNSIGNED 0 b